Class: Sc2::Player::Human
- Inherits:
-
Sc2::Player
- Object
- Sc2::Player
- Sc2::Player::Human
- Defined in:
- lib/sc2ai/player.rb
Overview
A human player for a Match
Constant Summary
Constants inherited from Sc2::Player
Instance Attribute Summary
Attributes inherited from Sc2::Player
#IDENTIFIED_RACES, #ai_build, #api, #callbacks_defined, #difficulty, #enable_feature_layer, #interface_options, #name, #opponent_id, #race, #realtime, #step_count, #timer, #type
Attributes included from GameState
#chats_received, #data, #game_info, #game_loop, #observation, #result, #spent_minerals, #spent_supply, #spent_vespene, #status
Instance Method Summary collapse
-
#initialize(race:, name:) ⇒ Human
constructor
A new instance of Human.
- #play ⇒ Object
Methods inherited from Sc2::Player
#callback_defined?, #connect, #create_game, #disconnect, #join_game, #leave_game, #prepare_start, #quit, #race_unknown?, #refresh_game_info, #refresh_state, #requires_client?, #set_enemy, #set_race_for_random, #started, #step_forward
Methods included from GameState
#available_abilities, #common, #on_status_change
Methods included from Connection::StatusListener
Constructor Details
#initialize(race:, name:) ⇒ Human
500 501 502 |
# File 'lib/sc2ai/player.rb', line 500 def initialize(race:, name:) super(race:, name:, type: Api::PlayerType::PARTICIPANT) end |
Instance Method Details
#play ⇒ Object
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/sc2ai/player.rb', line 504 def play loop do @api.step(@step_count) unless @realtime step_to_loop = @realtime ? game_loop + @step_count : nil response_observation = @api.observation(game_loop: step_to_loop) return if response_observation.nil? # Check if match has a result and callback on_player_result(response_observation.player_result) unless response_observation.player_result.empty? return @result unless @result.nil? break if @status != :IN_GAME end end |