gym_nethack package

Submodules

gym_nethack.agents module

class gym_nethack.agents.TestAgent(test_policy=None, **kwargs)[source]

Bases: libs.rl.core.Agent

A Keras-RL agent for purely heuristic policies, i.e., no learning done, no neural network model required.

backward(reward, valid_action_indices, terminal)[source]

Updates the agent after having executed the action returned by forward. If the policy is implemented by a neural network, this corresponds to a weight update using back-prop.

# Argument
reward (float): The observed reward after executing the action returned by forward. terminal (boolean): True if the new state of the environment is terminal.
# Returns
List of metrics values
compile()[source]

Compiles an agent and the underlaying models to be used for training and testing.

# Arguments
optimizer (keras.optimizers.Optimizer instance): The optimizer to be used during training. metrics (list of functions lambda y_true, y_pred: metric): The metrics to run during training.
forward(observation, valid_action_indices)[source]

Takes the an observation from the environment and returns the action to be taken next. If the policy is implemented by a neural network, this corresponds to a forward (inference) pass.

# Argument
observation (object): The current observation from the environment.
# Returns
The next action to be executed in the environment.
policy

gym_nethack.configs module

gym_nethack.conn module

gym_nethack.conn.kill_nh(socket)[source]
gym_nethack.conn.launch_nh(socket)[source]
gym_nethack.conn.rcv_msg(socket)[source]
gym_nethack.conn.send_msg(socket, msg)[source]

gym_nethack.fileio module

gym_nethack.fileio.append(arg, file, mode='a+')[source]
gym_nethack.fileio.get_dir_for_params(params, abbreviations)[source]
gym_nethack.fileio.read_line_list(file, ignore=[], load_float=True, add_txt=True)[source]

gym_nethack.misc module

gym_nethack.misc.dfs(start, passable_func, neighbor_func, min_neighbors=2, diag=False)[source]
gym_nethack.misc.distance_pt(A, B)[source]
gym_nethack.misc.get_maximal_rectangle(map_width, map_height, rect_points)[source]
gym_nethack.misc.is_straight_line_adjacent(initial, path, delta=2)[source]
gym_nethack.misc.print_log()[source]
gym_nethack.misc.save_log(*a, **k)[source]
gym_nethack.misc.to_matrix(l, n)[source]

gym_nethack.nhdaemon module

gym_nethack.nhdaemon.nh_daemon()[source]

gym_nethack.nhdata module

class gym_nethack.nhdata.Armor(name, type, material, buc, condition, enchantment, full_name)

Bases: tuple

buc

Alias for field number 3

condition

Alias for field number 4

enchantment

Alias for field number 5

full_name

Alias for field number 6

material

Alias for field number 2

name

Alias for field number 0

type

Alias for field number 1

class gym_nethack.nhdata.CMD[source]

Bases: object

APPLY = 'a'
CAST = 'Z'
CLOSE = 'c'
class DIR[source]

Bases: object

DOWN = '>'
E = 'l'
N = 'k'
NE = 'u'
NW = 'y'
S = 'j'
SE = 'n'
SW = 'b'
UP = '<'
W = 'h'
DROP = 'd'
EAT = 'e'
ENGRAVE = 'E'
EXCHANGE = 'x'
FIRE = 'f'
INVENTORY = '~'
KICK = '\x04'
MORE = ' '
OPEN = 'o'
PAY = 'p'
PICKUP = ','
PUTON = 'P'
QUAFF = 'q'
QUIVER = 'Q'
READ = 'r'
REMOVE = 'R'
SEARCH = 's'
class SPECIAL[source]

Bases: object

CHAT = '#chat'
DIP = '#dip'
FORCE = '#force'
INVOKE = '#invoke'
JUMP = '#jump'
LOOT = '#loot'
MONSTER = '#monster'
OFFER = '#offer'
PRAY = '#pray'
RIDE = '#ride'
RUB = '#rub'
SIT = '#sit'
TURN = '#turn'
WIPE = '#wipe'
TAKEOFF = 'T'
TELEPORT = '\x14'
THROW = 't'
WAIT = '.'
WEAR = 'W'
WIELD = 'w'
ZAP = 'z'
class gym_nethack.nhdata.Item(name, type, buc, full_name)

Bases: tuple

buc

Alias for field number 2

full_name

Alias for field number 3

name

Alias for field number 0

type

Alias for field number 1

class gym_nethack.nhdata.Potion(name, type, buc, use_type, full_name)

Bases: tuple

buc

Alias for field number 2

full_name

Alias for field number 4

name

Alias for field number 0

type

Alias for field number 1

use_type

Alias for field number 3

class gym_nethack.nhdata.Ring(name, type, buc, condition, enchantment, full_name)

Bases: tuple

buc

Alias for field number 2

condition

Alias for field number 3

enchantment

Alias for field number 4

full_name

Alias for field number 5

name

Alias for field number 0

type

Alias for field number 1

class gym_nethack.nhdata.Weapon(name, type, material, dsize, buc, condition, enchantment, full_name)

Bases: tuple

buc

Alias for field number 4

condition

Alias for field number 5

dsize

Alias for field number 3

enchantment

Alias for field number 6

full_name

Alias for field number 7

material

Alias for field number 2

name

Alias for field number 0

type

Alias for field number 1

gym_nethack.nhdata.equipped(inven_item)[source]
gym_nethack.nhdata.get_full_name(name, enchantment, condition, buc)[source]
gym_nethack.nhdata.get_role_for_title(title)[source]
gym_nethack.nhdata.wearing(inven_item)[source]
gym_nethack.nhdata.wielding(inven_item)[source]

gym_nethack.nhutil module

class gym_nethack.nhutil.Passage(first_room, first_position)[source]

Bases: object

Helper class to maintain info about map corridors and what rooms they lead to.

add_position(passage_pos)[source]
connect_room(room_pos)[source]
static merge(p1, p2)[source]
next_id = 0
class gym_nethack.nhutil.Room(nh)[source]

Bases: object

count_char(char)[source]
find_char(char)[source]
get_lined_positions(mpos)[source]
gym_nethack.nhutil.assert_setup(starting_items, inventory, cur_monster, top_line, monster_positions, stats, start_ac)[source]
gym_nethack.nhutil.get_cmd_from_delta(dx, dy)[source]
gym_nethack.nhutil.get_inventory(socket)[source]
gym_nethack.nhutil.get_stripped_itemname(inventory_name)[source]
gym_nethack.nhutil.item_match(item_name, inventory_name)[source]
gym_nethack.nhutil.save_nh_conf(proc_id, secret_rooms=False, character='Bar', race='Human', clvl=1, st=0, dx=0, mtype=None, create_mons=False, ac=999, inven=[], dlvl=1, lyc=None, stateffs=1, adj_mlvl=True, create_items=True, seed=-1)[source]
gym_nethack.nhutil.unpack_msg(msg, base_map, ignore_monsters=False, parse_ammo=True, update_base=True, parse_monsters=True)[source]
gym_nethack.nhutil.update_attrs(attr_line, attributes)[source]
gym_nethack.nhutil.update_stats(stat_line, stats)[source]

Module contents