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::VeryEasy, ai_build: Api::AIBuild::RandomBuild, 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, #game_info_stale?, #on_status_change
Methods included from Connection::StatusListener
Constructor Details
#initialize(race:, difficulty: Api::Difficulty::VeryEasy, ai_build: Api::AIBuild::RandomBuild, name: "Computer") ⇒ Sc2::Computer
433 434 435 436 437 438 439 440 441 |
# File 'lib/sc2ai/player.rb', line 433 def initialize(race:, difficulty: Api::Difficulty::VeryEasy, ai_build: Api::AIBuild::RandomBuild, name: "Computer") difficulty = Api::Difficulty::VeryEasy if difficulty.nil? ai_build = Api::AIBuild::RandomBuild 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
450 451 452 |
# File 'lib/sc2ai/player.rb', line 450 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
445 446 447 |
# File 'lib/sc2ai/player.rb', line 445 def requires_client? false end |