Class: Sc2::Player::Computer
- Inherits:
-
Sc2::Player
- Object
- Sc2::Player
- Sc2::Player::Computer
- Defined in:
- lib/sc2ai/player.rb
Overview
A Computer opponent using the game’s built-in AI for a Match
Constant Summary
Constants inherited from Sc2::Player
Instance Attribute Summary
Attributes inherited from Sc2::Player
#IDENTIFIED_RACES, #ai_build, #api, #difficulty, #enable_feature_layer, #interface_options, #name, #opponent_id, #race, #realtime, #step_count, #type
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
- #connect(host:, port:) ⇒ Object
- #initialize(race:, difficulty: Api::Difficulty::VERY_EASY, ai_build: Api::AIBuild::RANDOM_BUILD, name: "Computer") ⇒ Sc2::Computer constructor
-
#requires_client? ⇒ Boolean
Returns whether or not the player requires a sc2 instance.
Methods inherited from Sc2::Player
#create_game, #disconnect, #join_game, #leave_game, #race_unknown?, #refresh_game_info
Methods included from GameState
#available_abilities, #common, #on_status_change
Methods included from Connection::StatusListener
Constructor Details
#initialize(race:, difficulty: Api::Difficulty::VERY_EASY, ai_build: Api::AIBuild::RANDOM_BUILD, name: "Computer") ⇒ Sc2::Computer
463 464 465 466 467 468 469 470 471 |
# File 'lib/sc2ai/player.rb', line 463 def initialize(race:, difficulty: Api::Difficulty::VERY_EASY, ai_build: Api::AIBuild::RANDOM_BUILD, name: "Computer") difficulty = Api::Difficulty::VERY_EASY if difficulty.nil? ai_build = Api::AIBuild::RANDOM_BUILD if ai_build.nil? raise Error, "unknown difficulty: '#{difficulty}'" if Api::Difficulty.lookup(difficulty).nil? raise Error, "unknown difficulty: '#{ai_build}'" if Api::AIBuild.lookup(ai_build).nil? super(race:, name:, type: Api::PlayerType::COMPUTER, difficulty:, ai_build:) end |
Instance Method Details
#connect(host:, port:) ⇒ Object
480 481 482 |
# File 'lib/sc2ai/player.rb', line 480 def connect(host:, port:) raise Error, "Computer type can not connect to api" end |
#requires_client? ⇒ Boolean
Returns whether or not the player requires a sc2 instance
475 476 477 |
# File 'lib/sc2ai/player.rb', line 475 def requires_client? false end |