Table of Contents

Class RandomMoveAgent

Namespace
WeiqiSharp.Core.Agents
Assembly
WeiqiSharp.Core.dll

This agent will make a random legal Move if there are any on the board to make, or pass otherwise.

public class RandomMoveAgent : IAgent
Inheritance
RandomMoveAgent
Implements
Inherited Members

Constructors

RandomMoveAgent(SpaceState)

This agent will make a random legal Move if there are any on the board to make, or pass otherwise.

public RandomMoveAgent(SpaceState color)

Parameters

color SpaceState

The color of the Moves created by this agent.

Properties

Color

public SpaceState Color { get; init; }

Property Value

SpaceState

Methods

GetMove(Board)

Asks the agent to perform a move. An arbitrary amount of extra work can be done to implement this.

public Move GetMove(Board board)

Parameters

board Board

The current state of the board.

Returns

Move

The Move to be played on the board given.

Remarks

Note that the board itself can prevent the agent from making simple mistakes (suicide, e.g.). However, ko is not represented in the current state of the board, it is stored in, effectively, metadata that cannot easily be made available to the agent. As such, if the agent tries to make an illegal move, the GetMove(Board, IReadOnlyList<Move>) method will be called next, containing the illegal moves tried on this turn.

GetMove(Board, IReadOnlyList<Move>)

Asks the agent to perform a move. An arbitrary amount of extra work can be done to implement this.

public Move GetMove(Board board, IReadOnlyList<Move> invalidMoves)

Parameters

board Board

The current state of the board.

invalidMoves IReadOnlyList<Move>

A list of previously-tried invalid moves.

Returns

Move

The Move to be played on the board given.

Remarks

This overload should be used to inform the agent of invalid moves it has already taken. A prospective agent then doesn't need to keep track of the state of the board over time; it could just store the previous state it saw and build a hierarchical list of moves that would work for that state, then clear that when that board state is no longer necessary (when they get one that doesn't match it).

Note that the board itself can prevent the agent from making simple mistakes (suicide, e.g.). However, ko is not represented in the current state of the board, it is stored in, effectively, metadata that cannot easily be made available to the agent.