Skip to content

RandomAgent

Charlie Ringer edited this page Apr 28, 2017 · 3 revisions

Description:

A random AI which just selects a move at random, useful only as a bench mark for the other methods.To use.

  • Create a class which inherits from AI State.
  • Construct this using one of the supplied constructors.
  • When you are ready to calculate the next move pass the current state into run()
  • The AI will run on a sperate thread so keep checking back to see if the done flag is true. (The AI runs on a separate thread to decouple it from your code.)
  • Once the AI is done and you have retrieved the next state from next call reset() to reset the AI.

Constructors:

Name Description
RandomAgent() Constructs a random AI

Methods:

Return Type Name Description
void run(AIState initalState) Starts the AI with a supplied starting state.
void reset() Used once the next move have been retrieved to reset the AI ready for the next iteration

Fields:

Type Name Description
bool done True if the AI has finished thinking, false otherwise
bool started True if this AI iteration has started
AIState next The next move, represented in an AI state. Null if the AI is thinking

Clone this wiki locally