src.dcss.state.game

Module Contents

Classes

GameState

This file stores the state class that is used to keep track of

class src.dcss.state.game.GameState

This file stores the state class that is used to keep track of the current state of the dcss game

ID = 0
update(msg_from_server)

Updates the game state object with a message from the webserver.

Parameters:

msg_from_server (dict) – message from the server

set_current_menu(menu: dcss.state.menu.Menu)
get_current_menu()
get_player_stats_vector(verbose=False)

The following player stats are returned by this function:

Vector Index

Description of Data

Data Type if available

0

health

Int

1

health_max

Int

2

health_max_real

Int

3

mana_points

Int

4

mana_points_max

Int

5

mana_points_real

Int

6

AC

Int

7

EV

Int

8

SH

Int

9

Str

Int

10

Str max

Int

11

Int

Int

12

Int max

Int

13

Dex

Int

14

Dex max

Int

15

XL

Int

16

Experience until next level

0-100 percentage

14

God

Int

15

Piety Level

Int

16

Spell slots left

Int

17

gold

Int

18

rFire

Int

19

rCold

Int

20

rNeg

Int

21

rPois

Int

22

rElec

Int

23

rCorr

Int

24

MR

Int

25

Stealth

Int

26

HPRegen per turn

Float

27

MPRegen per turn

Float

28

See invisible

Boolean

30

Faith

Boolean

31

Spirit

Boolean

32

Reflect

Boolean

33

Harm

Boolean

34

game turns

Float

35

game time

Float

36

attack speed

Int

37

movement speed

Int

169

Player Place (Dungeon, Vaults, etc.)

Boolean

38

Agile status effect

Boolean

39

Antimagic status effect

Boolean

40

Augmentation status effect

Boolean

41

Bad Forms status effect

Boolean

42

Berserk status effect

Boolean

170

Unable to Berserk status effect

Boolean

43

Black Mark status effect

Boolean

44

Blind status effect

Boolean

45

Brilliant status effect

Boolean

46

Charm status effect

Boolean

47

Confusing Touch status effect

Boolean

48

Confusion status effect

Boolean

49

Constriction status effect

Boolean

50

Cooldowns status effect

Boolean

51

Corona status effect

Boolean

52

Corrosion status effect

Boolean

53

Darkness status effect

Boolean

54

Dazed status effect

Boolean

55

Death Channel status effect

Boolean

56

Death’s Door status effect

Boolean

57

Deflect Missiles status effect

Boolean

58

Disjunction status effect

Boolean

59

Divine Protection status effect

Boolean

60

Divine Shield status effect

Boolean

61

Doom Howl status effect

Boolean

62

Drain status effect

Boolean

63

Engorged status effect

Boolean

64

Engulf status effect

Boolean

65

Fast+Slow status effect

Boolean

66

Fear status effect

Boolean

67

Finesse status effect

Boolean

68

Fire Vulnerable status effect

Boolean

69

Flayed status effect

Boolean

70

Flight status effect

Boolean

71

Frozen status effect

Boolean

72

Haste status effect

Boolean

73

Heavenly Storm status effect

Boolean

74

Held status effect

Boolean

75

Heroism status effect

Boolean

76

Horrified status effect

Boolean

77

Inner Flame status effect

Boolean

78

Invisibility status effect

Boolean

79

Lava status effect

Boolean

80

Leda’s Liquefaction status effect

Boolean

81

Leda’s Liquefaction status effect

Boolean

82

Magic Contamination status effect

Boolean

83

Mark status effect

Boolean

84

Mesmerised status effect

Boolean

85

Might status effect

Boolean

86

Mirror Damage status effect

Boolean

87

No Potions status effect

Boolean

88

No Scrolls status effect

Boolean

89

Olgreb’s Toxic Radiance status effect

Boolean

90

Orb status effect

Boolean

91

Ozocubu’s Armour status effect

Boolean

92

Paralysis status effect

Boolean

93

Petrifying/Petrified status effect

Boolean

94

Poison status effect

Boolean

95

Powered by Death status effect

Boolean

96

Quad Damage status effect

Boolean

97

Recall status effect

Boolean

98

Regenerating status effect

Boolean

99

Repel Missiles status effect

Boolean

100

Resistance status effect

Boolean

101

Ring of Flames status effect

Boolean

102

Sapped Magic status effect

Boolean

103

Scrying status effect

Boolean

104

Searing Ray status effect

Boolean

105

Serpent’s Lash status effect

Boolean

106

Shroud of Golubria status effect

Boolean

107

Sickness status effect

Boolean

108

Silence status effect

Boolean

109

Silence status effect

Boolean

110

Sleep status effect

Boolean

111

Slimify status effect

Boolean

112

Slow status effect

Boolean

113

Sluggish status effect

Boolean

114

Starving status effect

Boolean

115

Stat Zero status effect

Boolean

116

Sticky Flame status effect

Boolean

117

Still Winds status effect

Boolean

118

Swiftness status effect

Boolean

119

Teleport Prevention status effect

Boolean

120

Teleport status effect

Boolean

121

Tornado status effect

Boolean

122

Transmutations status effect

Boolean

123

Umbra status effect

Boolean

124

Vitalisation status effect

Boolean

125

Vulnerable status effect

Boolean

126

Water status effect

Boolean

127

Weak status effect

Boolean

128

Acute Vision mutation

Boolean

129

Antennae mutation

Boolean

130

Beak mutation

Boolean

131

Big Wings mutation

Boolean

132

Blink mutation

Boolean

133

Camouflage mutation

Boolean

134

Clarity mutation

Boolean

135

Claws mutation

Boolean

136

Cold Resistance mutation

Boolean

137

Electricity Resistance mutation

Boolean

138

Evolution mutation

Boolean

139

Fangs mutation

Boolean

140

Fire Resistance mutation

Boolean

141

High MP mutation

Boolean

142

Hooves mutation

Boolean

143

Horns mutation

Boolean

144

Icy Blue Scales mutation

Boolean

145

Improved Attributes mutation

Boolean

146

Iridescent Scales mutation

Boolean

147

Large Bone Plates mutation

Boolean

148

Magic Resistance mutation

Boolean

149

Molten Scales mutation

Boolean

150

Mutation Resistance mutation

Boolean

151

Passive Mapping mutation

Boolean

152

Poison Breath mutation

Boolean

153

Poison Resistance mutation

Boolean

154

Regeneration mutation

Boolean

155

Repulsion Field mutation

Boolean

156

Robust mutation

Boolean

157

Rugged Brown Scales mutation

Boolean

158

Shaggy Fur mutation

Boolean

159

Slimy Green Scales mutation

Boolean

160

Stinger mutation

Boolean

161

Strong Legs mutation

Boolean

162

Talons mutation

Boolean

163

Tentacle Spike mutation

Boolean

164

Thin Metallic Scales mutation

Boolean

165

Thin Skeletal Structure mutation

Boolean

166

Tough Skin mutation

Boolean

167

Wild Magic mutation

Boolean

168

Yellow Scales mutation

Boolean

Returns:

A list of features representing the player’s stats

get_player_inventory_vector()

Player has 52 inventory slots corresponding to each lowercase and uppercase letter of the English alphabet.

Each item is represented by a vector of size 7:

Vector Index

Description of Data

Data Type if available

0

Item type

1

quantity

Int

2

Item Bonus

Int

3

Is Equipped

Boolean

4

First property

5

Second property

6

Third property

Returns:

a list of size 364 (52 inventory items each represented with 7 features shown above)

get_player_spells_vector()

Player has a maximum of 21 spell slots for spells to be learned.

Each of these 21 spells slots is represented by a vector of 3 values:

Vector Index

Description of Data

Data Type if available

0

Spell ID.

Int repr. spell ID

1

Spell SkillName

Int repr. skill ID

2

Spell SkillName #2

Int repr. skill ID

3

Spell SkillName #3

Int repr. skill ID

4

Failure Likelihood

Int 0-100

5

Spell Level

Int

Additionally, there are 118 spells that can be learned if the player has found a book item with a given spell, therefore we need an additional 118 slots in this vector representing whether each spell is available to be learned.

Returns:

a list of size 21*6 + 118.

get_player_abilities_vector()

There are 94 possible abilities a player may acquire. For each of these abilities, they are represented by the following vector:

Vector Index

Description of Data

Data Type if available

0

Ability is ID

Int repr. spell ID

1

Failure Likelihood

Int 0-100

2

Magic Point Cost

Boolean

3

Piety Point Cost

Boolean

4

Has Delay Cost

Boolean

5

Has Frailty Cost

Boolean

# TODO there are probably more costs (like health, etc) that should end up as additional rows in this table

Returns:

a list of size 94*6.

get_player_skills_vector()

Player has 31 skills that increase over time if the player is actively ‘training’ those skills.

Each skill is represented by a vector of size 3:

Vector Index

Description of Data

Data Type if available

0

Current value

Float

1

Training Percentage

Int (0-100)

2

Aptitude

Int

Returns:

a list of size 93

get_egocentric_LOS_map_data_vector(radius=7)

Returns a vector containing data on the tiles in a ((radius*2)+1)^2 square centered on the player.

See cell.py get_cell_vector() for a description of what is in each cell vector.

get_egocentric_level_map_data_vector()

Returns a vector containing data on the tiles on the player’s current level.

Uses the same tile representation of vectors of size 34 from get_egocentric_LOS_map_data()

Returns a vector with no upperbound if traveling through levels such as Abyss or Labyrinth. More realistically returns a vector ranging from a minimum size of 7,650 (225 LOS tiles * 34) up to possible sizes of 68,000+ (2000 tiles * 34).

get_all_map_data_vector()

Returns a vector containing data on the tiles the player has encountered so far in the game.

Uses the same tile representation of vectors of size 34 from get_egocentric_LOS_map_data()

Returns a vector with no upperbound if traveling through levels such as Abyss or Labyrinth. More realistically returns a vector ranging from a minimum size of 7,650 (225 LOS tiles * 34) up to possible sizes of 3,400,000+ (100,000 tiles * 34).

get_player_stats_pddl()

Returns PDDL 2.2 level 1 which DOES NOT include all aspects of numeric planning.

PDDL predicates that are provided via this function:

  • playerhealth

  • playermagicpoints

  • player_worshipping

  • player_piety

  • player_has_available_spell_slot

  • player_resist_fire

  • player_resist_cold

  • player_resist_neg

  • player_resist_pois

  • player_resist_elec

  • player_resist_corr

  • player_willpower

  • player_stealth

  • player_see_invis

  • player_faith_status

  • player_spirit_status

  • player_reflect_status

  • player_harm_status

  • player_movement_speed

  • player_attack_speed

  • playerplace

  • player_has_status_effect

  • player_has_mutation

Therefore the following player stats aren’t available.

Player Stat

Description of Data

Why not included?

AC

Represents Armour

Non-relative Int

EV

Represents Evasion

Non-relative Int

SH

Represents Shelf

Non-relative Int

Strength

Current value

Non-relative Int

Intelligence

Training Percentage

Non-relative Int

Dexterity

Aptitude

Non-relative Int

Returns a list of PDDL facts representing player stats

get_possible_actions_for_current_menu()
get_inventory_menu_choices()

Returns the menu choices for selecting an item in the inventory menu

get_player_inventory_pddl()

Returns a simple PDDL representation for inventory items that will describe items with the following predicates. Note that this function returns two data objects, first is a list of inventory object names and the second is a list of the pddl facts, as strings, about those objects.

Predicates currently supported: * equipped * cursed * item_bonus (refers to the +3 kinds of bonuses on items) * weapon, scroll, ammunition, potion, or armour (others may be discovered and then must be added here) * only_one_left or more_than_one_remaining

get_player_skills_pddl()

Skill names as objects are already provided in the PDDL domain file since they are constant across all characters and game modes.

Only PDDL facts about whether each skill has training off, low, or high is returned, and the current value of said skill using qualitative quantifiers of: ‘none’, ‘low’, ‘medium_low’, ‘medium’, ‘medium_high’, ‘high’, ‘maxed’

get_egocentric_LOS_map_data_pddl(radius=7)

Returns a list of PDDL facts representing the tiles around the player for the given radius. Information about tiles outside of this radius is not returned.

get_current_level_map_data_pddl()

Returns a list of PDDL facts representing the tiles in player’s current level. Information about tiles outside of the current level is not returned.

get_all_map_data_pddl()

Returns a list of PDDL facts for every tile encountered by the player thus far.

get_background_pddl()

Returns a static list of pddl facts, including all type instances and dungeon level connections.

shift_agent_x(change)

Performs an addition

TODO: Write documentation

shift_agent_y(change)

Performs an addition

TODO: Write documentation

get_cell_map()

Returns the cell map object.

Returns:

the object containing all information per cell of the DCSS game so far

Return type:

CellMap

_process_raw_state(s, last_key='')

TODO: Write documentation

process_menu_text(html_str)
_process_resistances(html_str)
_process_see_invis(html_str)
_process_hp_mp_regen(html_str)
_process_spell_slots(html_str)
_process_mutations(html_str)
_process_items_agent_location(message)
_process_single_spell(message)
_process_single_ability(message)
process_messages(data)
process_attack_move_speeds(s)
process_player(data)
process_player_status(status_list)
process_cursor(data)
process_describe_monster(data)

Process description of cells that describe monsters via the examine mode

get_pddl_current_state_player()
get_pddl_player_info()

Return player health information and other stats

get_pddl_current_state_cellmap(radius=10)
get_current_game_turn()
get_current_game_time()
player_radius_pddl_facts(radius)
all_pddl_facts()
get_all_map_objects_in_pddl()
write_pddl_current_state_to_file(filename, goals)

Filename is assumed to be a relevant filename from the folder that the main script is running

has_agent_died()
is_agent_too_terrified(reset=True)
agent_cannot_move(reset=True)
agent_just_leveled_up(reset=True)
process_inv(data)
process_equip(data)
process_quiver_item(data)
process_quiver_available(data)
get_cell_objs_from_raw_data(cells)
get_player_xy()
get_asp_str()
get_asp_comment_str()
get_training_asp_str()
get_player_cell()
get_tiles_around_player_radius(radius=1)

A radius of 0 is only the players tile A radius of 1 would be 9 tiles, including

  • players tile

  • all tiles 1 away (including diagonal) of the player’s tile

A radius of 2 would be 16+8+1 = 25 tiles (all tiles <= distance of 2 from player) etc…

Returns a factored state representation of the tiles around the player: Example w/ radius of 1 - 9 tiles including the player’s current position and all adjacent tiles in every cardinal direction - tiles are ordered in a clockwise orientation, starting with N, then NE, then E, etc - inner layers come before outer layers - each tile is represented as a factored state:

<objType,monsterLetter,hasCorpse,hereBefore>
  • objType = 0 is empty, 1 is wall, 2 is monster

  • monsterLetter = 27 if noMonster, 0-26 representing the alpha index of the first letter of mon name

  • hasCorpse = 0 if no edible corpse, 1 if edible corpse

  • hereBefore = 0 if first time player on this tile, 1 if player has already been here

Parameters:

radius – Int

Returns:

a factored state representation of the tiles around the player

draw_map()
draw_cell_map()
print_inventory()
get_inventory_vector()
_pretty_print(curr_state, offset=1, last_key='')
printstate()
get_map_obj()
convert_cells_to_map_obj(cells_str)

cells is the data of the map and nearby monsters and enemies received from the server

_process_skill_lines(skill_lines)