Games::OthelloGames::Othello is a Perl extension for modelling a game of Othello. | |
Download |
Games::Othello Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Daniel J. Wright
- Publisher web site:
- http://search.cpan.org/~dwright/
Games::Othello Tags
Games::Othello Description
Games::Othello is a Perl extension for modelling a game of Othello. Games::Othello is a Perl extension for modelling a game of Othello.SYNOPSIS use Games::Othello; my $game = Games::Othello->new(); while( !game->over ) { printf "It is presently %s's move", ($game->whos_move eq 'b') ? 'black', 'white'; my @possible_moves = values $game->possible_moves(); if ( ! @possible_moves ) { print "You have no moves available, you must pass. $game->pass_to_opponent; } else { foreach ( my $move ) @possible_moves ) { printf "You will take %d of your opponents chips if you place your chip on %d,%d", scalar @{ $move->{chips} }, $move->{x}, $move->{y}; } my ($locx, $locy) = get_move(); my $flipped = $game->place_chip( $locx, $locy ); } my $layout = $game->chip_layout(); foreach my $row ( @$layout ) { foreach my $pos ( @$row ) { printf '%3s', ($pos eq 'b') ? 'B' # Black occupied square. : ($pos eq 'w') ? 'W' # White occupied square. : ' ' # Un-occupied square. } print "nn"; } } my ($black_score, $white_score) = $game->score; Requirements: · Perl
Games::Othello Related Software