Table of Contents

Class GroupExpander

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

This agent attempts to expand its groups most of the time. It figures out which move it can take that will provide it with the most new liberties.

Each move, however, it has the chance to randomly make a move that does not expand its liberties.

public class GroupExpander : IAgent
Inheritance
GroupExpander
Implements
Inherited Members

Remarks

Potential improvements here could include prioritizing groups that only have one liberty but which could gain more, rather than groups which would offer the most new liberties. Also, in theory,

Constructors

GroupExpander(SpaceState, double, double, double)

This agent attempts to expand its groups most of the time. It figures out which move it can take that will provide it with the most new liberties.

Each move, however, it has the chance to randomly make a move that does not expand its liberties.

public GroupExpander(SpaceState color, double randomChance = 0.15, double libertyWeight = 1.5, double captureWeight = 1)

Parameters

color SpaceState
randomChance double

The likelihood as a fraction of 1.0 that the agent will make a random move instead of attempting to expand its liberties.

libertyWeight double
captureWeight double

Remarks

Potential improvements here could include prioritizing groups that only have one liberty but which could gain more, rather than groups which would offer the most new liberties. Also, in theory,

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.