Skip to content

Computer Players

Ben-Ryder edited this page Feb 22, 2020 · 4 revisions

Computer Players

Computer players are currently being developed in GH-2_computer-players.

This wiki page contains a TODO list and documentation about how the computer players algorithm works.

TODO

NOTE: This todo list is in reverse chronological order.

  • Add checkbox to new game menu to select if a player should be computer controlled, ensuring at least one player is human.
  • Finish implementing the simple algorithm below for computer players.
  • Create this wiki as somewhere to write docs and this todo list.
  • Sort out dev and feature branch for starting the work.

Documentation

There are five main actions a player can do:

  • spawning new units
  • moving units
  • attacking enemy units
  • conquering cities
  • upgrading cities

Pseudo Code Algorithm

The pseudo code algorithm for a computer players turn:

FOR each current Unit
  IF Unit in City
    conquer City
  IF enemy/unoccupied City in movement range of the Unit AND the Unit can move into it
    move into City
  ELSE
    move a square towards nearest enemy/unoccupied City
  attack the weakest enemy Unit in attack range

FOR each City
  spawn a random Unit that is affordable
FOR each City
  get an upgrade

To start with I am implementing a relatively simple algorithm, so I'm not attempting to implement any tactics to react to the enemies actions, as a human player instinctively does.

Clone this wiki locally