ColorShapeLinks AI
An AI competition for the IEEE Conference on Games 2021
AbstractThinker Class Referenceabstract

The actual AI code of specific AIs should be placed in classes which extend this class. More...

+ Inheritance diagram for AbstractThinker:
+ Collaboration diagram for AbstractThinker:

Public Member Functions

virtual void Setup (string str)
 Setup thinker. More...
 
abstract FutureMove Think (Board board, CancellationToken ct)
 Perform a move. More...
 
override string ToString ()
 Returns a short string description of the AI. More...
 

Protected Member Functions

void OnThinkingInfo (string info)
 Outputs thinking information. More...
 

Properties

int Rows [get]
 Number of board rows. More...
 
int Cols [get]
 Number of board columns. More...
 
int WinSequence [get]
 How many pieces in sequence to find a winner. More...
 
int RoundsPerPlayer [get]
 Number of initial round pieces per player. More...
 
int SquaresPerPlayer [get]
 Number of initial square round pieces per player More...
 
int TimeLimitMillis [get]
 Time limit for the AI to play. More...
 

Events

Action< string > ThinkingInfo
 Event raised when thinkers produce information while thinking. More...
 

Detailed Description

The actual AI code of specific AIs should be placed in classes which extend this class.

Member Function Documentation

◆ OnThinkingInfo()

void OnThinkingInfo ( string  info)
inlineprotected

Outputs thinking information.

Parameters
infoString containing the thinking information.

In the Unity frontend this information is shown in Unity's console, while in the console frontend it is forwarded to the registered thinker listeners (which by default print to the terminal).

This method raises the ThinkingInfo event in order to output thinking information. Thinkers should use this method instead of raising the event directly.

◆ Setup()

virtual void Setup ( string  str)
inlinevirtual

Setup thinker.

Parameters
strString containing setup parameters, should be parsed by the concrete AI thinker.

By default, this method does nothing and its implementation by the concrete thinkers is entirely optional.

Reimplemented in HumanThinker, RandomMemoryHoarderThinker, RandomAIThinker, MinimaxAIThinker, and BadMoveAIThinker.

◆ Think()

abstract FutureMove Think ( Board  board,
CancellationToken  ct 
)
pure virtual

Perform a move.

Parameters
boardThe game board.
ctA cancellation token.
Returns
The move to be performed.

The main thread may ask the thinker to stop thinking. As such, this method should frequently test if a cancellation request was made to the cancellation token (ct ). If so, it should return immediately with no move performed, as exemplified in the following code:

if (ct.IsCancellationRequested) return FutureMove.NoMove;
See also
IThinker.Think

Implements IThinker.

Implemented in HumanThinker, SequentialAIThinker, RandomMemoryHoarderThinker, RandomAIThinker, MinimaxAIThinker, and BadMoveAIThinker.

◆ ToString()

override string ToString ( )
inline

Returns a short string description of the AI.

By default, the namespace is removed, as well as the "thinker" or "aithinker" or "thinkerai" suffixes.

Returns
A short string description of the AI.

Property Documentation

◆ Cols

int Cols
getprotected

Number of board columns.

◆ RoundsPerPlayer

int RoundsPerPlayer
getprotected

Number of initial round pieces per player.

◆ Rows

int Rows
getprotected

Number of board rows.

◆ SquaresPerPlayer

int SquaresPerPlayer
getprotected

Number of initial square round pieces per player

◆ TimeLimitMillis

int TimeLimitMillis
getprotected

Time limit for the AI to play.

◆ WinSequence

int WinSequence
getprotected

How many pieces in sequence to find a winner.

Event Documentation

◆ ThinkingInfo

Action<string> ThinkingInfo

Event raised when thinkers produce information while thinking.

  • Listeners receive a string containing the thinking information.
  • It is not mandatory that thinkers produce any information while thinking.
See also
IThinker.ThinkingInfo

The documentation for this class was generated from the following file: