Class: Sc2::Player::PreviousState
- Inherits:
-
Object
- Object
- Sc2::Player::PreviousState
- Defined in:
- lib/sc2ai/player/previous_state.rb
Overview
Container for the previous game state, based on current bot state Keep to one instance, but with variables to prevent large memory leaks
Instance Attribute Summary
Attributes included from Units
#all_seen_unit_tags, #all_units, #effects, #event_units_damaged, #event_units_destroyed, #neutral, #placeholders, #power_sources, #radar_rings, #structures, #units, #upgrades_completed
Attributes included from GameState
#chats_received, #data, #game_info, #game_info_loop, #game_loop, #observation, #result, #spent_minerals, #spent_supply, #spent_vespene, #status
Instance Method Summary collapse
-
#after_reset(bot) ⇒ Object
Override to modify previous frame after reset is complete.
-
#before_reset(bot) ⇒ Object
Override to modify the previous frame before being set to current.
-
#reset(bot) ⇒ Object
Sets the previous state of the bot using the last frame.
Methods included from Units
#ability_data, #can_afford?, #can_afford_upgrade?, #subtract_cost, #unit_ability_available?, #unit_data, #unit_group_from_tags, #unit_has_attribute?, #units_in_progress, #upgrade_completed?, #upgrade_data, #upgrade_in_progress?, #upgrades_in_progress
Methods included from GameState
#available_abilities, #common, #game_info_stale?, #on_status_change
Methods included from Connection::StatusListener
Instance Method Details
#after_reset(bot) ⇒ Object
Override to modify previous frame after reset is complete
45 46 47 |
# File 'lib/sc2ai/player/previous_state.rb', line 45 def after_reset(bot) # no op end |
#before_reset(bot) ⇒ Object
Override to modify the previous frame before being set to current
39 40 41 |
# File 'lib/sc2ai/player/previous_state.rb', line 39 def before_reset(bot) # no op end |
#reset(bot) ⇒ Object
Sets the previous state of the bot using the last frame
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sc2ai/player/previous_state.rb', line 14 def reset(bot) before_reset(bot) @all_units = bot.all_units @units = bot.units @structures = bot.structures @placeholders = bot.placeholders @neutral = bot.neutral @effects = bot.effects @power_sources = bot.power_sources @radar_rings = bot.radar_rings @status = bot.status @game_info = bot.game_info @observation = bot.observation @game_loop = bot.observation.game_loop @spent_minerals = bot.spent_minerals @spent_vespene = bot.spent_vespene @spent_supply = bot.spent_supply # Skipping unnecessary bloat: event_*, chats_received, ... after_reset(bot) end |