Daniel Gilder > Games-Go-Player > Games::Go::Player

Download:
Games-Go-Player-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.07   Source  

NAME ^

Games::Go::Player - plays a game of Go.

SYNOPSIS ^

This program generates a move on a Go board according to patterns that it learns from game records in SGF.

It puts patterns into a database (called pattern<colour><size>). Which databases are updated depends on $self->{_veclengths}. Pattern information is stored in a hash, where the key is the pattern, (compressed using vec) and the value contains a score for each point on the pattern from 0 to 255. A pattern point is either empty, black, white, or 'not on the board'

For an example script that instructs Player to learn from a particular directory, see pluserdir.pl in the scripts folder.

To play a move:

  my $move = $player->chooselegalmove($colour, $referee);
  $referee->play($colour, $move);
  $player->update($colour, $referee);

Or see kgspot.pl which is included in the scripts folder.

Before learning, the following parts of the 'new' method can (and in some cases, should) be edited:

$self->{_maxmove} For example, its probably not worth looking beyond move 10 when matching whole board 19x19 games.

$self->{_weakest} For example, if matching patterns from a 9 handicap game between a 3 kyu and a 12 kyu, you may want to disregard the moves of the 12kyu

The function loadratings can be tweaked as you see fit. For example, at the moment it gives a higher score to a move close to the centre of a pattern than one on the edge.

Debugging ^

The tiestats method can be called on a particular pattern file. It counts the number of patterns in the file, and how many are 'maxxed' ie Have a point in them that has been matched 255 times (and so are not updated again).

The retrieve method examines a pattern file for a particular pattern. The pattern is expressed as a string of 'o', 'x', '.' and '-' Where 'o' represents a white stone, 'x' a black one, '.' an empty point and '-' the edge of the board. eg '-----...-...-..x' represents the top left corner pattern -

---- -... -... -..x

For example:

use File::Basename; use Games::Go::Player;

my ($pathname, $pattern) = @_; my $player = new Player; my ($filename, $dirname) = fileparse($pathname); $filename =~ /(\d+)/; $player->size($1); $player->path($dirname); $player->tiestats($filename); $player->retrieve($pathname, $pattern) if defined $pattern;

Maintenance ^

The symmetrise method can be used to give a symmetrical pattern a symmetrical rating pattern. I suggest using it on databases when a large proportion of their patterns are maxxed.

BUGS/CAVEATS ^

There is a memory leak (?) in learn mode that gobbles up about 1Mb/minute on a 1.86GHz machine (which processes about 10 sgf files every 5 minutes). If you ask it to play on a boardsize that it has not learnt any patterns for, and it is Black in a handicap game, it will pass as its handicap moves(!). KGS doesn't seem to handle this situation well, and neither does this program.

Ideas ^

When learning, information on the closest move (in terms of the sequence of the game) could be stored. Have an additional piece of information in a pattern's ratings - how often this pattern has occurred after both players pass in a scored game.

AUTHOR (version 0.01) ^

Daniel Gilder

THANKS ^

To Ricardo Signes for explaining some of the workings of Games::Goban

syntax highlighting: