Skip to content

history.py

Damon Getsman edited this page Nov 18, 2018 · 1 revision

history.py contains the object that we are using instances of in order to save various aspects of the game's state for later processing. At this point, I'm very much considering (instead of just using this object for a single previous turn's information) using a list of these objects in order to be able to access at least myglobals.Const.Initial_Scoot_Distance turns from the past. Of course, whenever deep learning kicks in, it'll probably be useful to have the entire game's state at each turn available; not sure if that'll be something we can pull in another way via game_map or something, or if we'll have to use these. Probably a combination of both, actually.

Information on the object contained within follows:

ShipHistory

ShipHistory is simply an object holding the following per-turn values for each ship. The myglobals.Variables.current_assignments dict holds ShipHistory objects, each indexed by the ship.id. This will be changing in the future to allow more than one turn to be saved in the history for better processing and potentially debugging.

object details

fields

  • id - (yeah, it may be redundant, but we may need it for future revisions)
  • location - Position on the game_map
  • destination - Position on the game_map that we're trying to get to, or are already at
  • turnstamp - the turn at which these parameters were last modified
  • primary_mission - one of the myglobals.Missions.* enum values; note that the methodology used here may well change very soon
  • secondary_mission - primarily used for flagging when a ship is myglobals.Missions.in_transit, as opposed to actually at its destination and carrying out its mission

instance methods

  • is_initialized() - returns boolean to signify whether or not this object has been initialized for a ship yet
  • is_alive() - returns False if the ship has been destroyed, else True
  • __init__() - does the usual init stuff, requiring all fields to be passed values for initialization
  • set_ldps() - sets ship location, destination, and primary/secondary mission values
  • set_loc() - sets ship location
  • set_dest() - sets ship destination
  • prune_current_assignments() - runs through the current_assignments list, determining which ships have been destroyed, and then returns the list of those ids to the caller
Clone this wiki locally