|
reversi-core
A simple reversi library for C
|
Class for a reversi board. More...
#include <reversi.h>
Public Member Functions | |
| RevBoard * | revNewBoard () |
| Creates a new board. | |
| void | revFreeBoard (RevBoard *board) |
| Frees the memory of a board object. | |
| void | revInitBoard (RevBoard *board) |
| Initializes a board with the fixed four disks. | |
| void | revCopyBoard (RevBoard *src, RevBoard *trg) |
| Deep copy for board objects. | |
| RevDiskType | revGetCurrentPlayer (RevBoard *board) |
| Gets the current player. | |
| RevBitboard | revGetBitboard (RevBoard *board, RevDiskType disk_type) |
| Gets a bitboard of a player. | |
| void | revSetBitboard (RevBoard *board, RevDiskType disk_type, RevBitboard b) |
| Sets a bitboard of a player. | |
| int * | revGetBitboardAsArray (RevBoard *board, RevDiskType disk_type) |
| Gets a bitboard as an array of positions on a bitboard. | |
| int | revCountDisks (RevBoard *board, RevDiskType disk_type) |
| Gets the number of disks on a board for a player. | |
| RevDiskType | revGetWinner (RevBoard *board) |
| Returns which player has more disks on a board. | |
| void | revSetDisk (RevBoard *board, RevDiskType disk_type, int pos) |
| Sets a disk on a board. | |
| void | revSetDiskXY (RevBoard *board, RevDiskType disk_type, int x, int y) |
| Sets a disk on a board. | |
| RevDiskType | revGetDisk (RevBoard *board, int pos) |
| Gets a disk on a board. | |
| RevDiskType | revGetDiskXY (RevBoard *board, int x, int y) |
| Gets a disk on a board. | |
| RevBitboard | revGetMobility (RevBoard *board) |
| Gets mobility of the current player as a bitboard. | |
| int * | revGetMobilityAsArray (RevBoard *board) |
| Gets mobility of the current player as an array of integers. | |
| int | revGetMobilityCount (RevBoard *board) |
| Gets the number of legal moves for the current player. | |
| int | revHasLegalMoves (RevBoard *board) |
| Returns whether or not the current player has legal moves. | |
| int | revIsLegalMove (RevBoard *board, int pos) |
| Returns whether or not a move is legal. | |
| int | revIsLegalMoveXY (RevBoard *board, int x, int y) |
| Returns whether or not a move is legal. | |
| void | revPrintBoard (RevBoard *board) |
| Outputs a board to stdout. | |
| void | revPrintBoardWithMobility (RevBoard *board) |
| Outputs a board with mobility to stdout. | |
| void | revUpdateMobility (RevBoard *board) |
| Calculates mobility of the current player. | |
| void | revChangePlayer (RevBoard *board) |
| Changes the current player to the opposite player. | |
| RevBitboard | revMove (RevBoard *board, int pos) |
| Flips disks, changes the current player, and calculates mobility. | |
| RevBitboard | revMoveXY (RevBoard *board, int x, int y) |
| Flips disks, changes the current player, and calculates mobility. | |
| int | revGenMoveRandom (RevBoard *board) |
| Generates a random move. | |
| void | revMoveRandomToEnd (RevBoard *board) |
| Plays the game to the end randomly. | |
| int | revGenMoveMonteCarlo (RevBoard *board, int trials) |
| Calls revMoveRandomToEnd() many times for each legal move, and returns the best move that has the highest win rate. | |
Class for a reversi board.
| void revChangePlayer | ( | RevBoard * | board | ) |
Changes the current player to the opposite player.
| board | RevBoard instance |
Deep copy for board objects.
It copies a board src to another board trg.
| int revCountDisks | ( | RevBoard * | board, |
| RevDiskType | disk_type | ||
| ) |
Gets the number of disks on a board for a player.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| void revFreeBoard | ( | RevBoard * | board | ) |
Frees the memory of a board object.
| board | The board to free memory |
| int revGenMoveMonteCarlo | ( | RevBoard * | board, |
| int | trials | ||
| ) |
Calls revMoveRandomToEnd() many times for each legal move, and returns the best move that has the highest win rate.
| board | RevBoard instance |
| trials | How many times this function plays the game from the current state to the end. |
| int revGenMoveRandom | ( | RevBoard * | board | ) |
Generates a random move.
| board | RevBoard instance |
| RevBitboard revGetBitboard | ( | RevBoard * | board, |
| RevDiskType | disk_type | ||
| ) |
Gets a bitboard of a player.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| int * revGetBitboardAsArray | ( | RevBoard * | board, |
| RevDiskType | disk_type | ||
| ) |
Gets a bitboard as an array of positions on a bitboard.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| RevDiskType revGetCurrentPlayer | ( | RevBoard * | board | ) |
| RevDiskType revGetDisk | ( | RevBoard * | board, |
| int | pos | ||
| ) |
Gets a disk on a board.
| board | RevBoard instance |
| pos | a position on a bitboard. pos = x + y * 8 |
| RevDiskType revGetDiskXY | ( | RevBoard * | board, |
| int | x, | ||
| int | y | ||
| ) |
Gets a disk on a board.
| board | RevBoard instance |
| x | x-coordinate on a board. |
| y | y-coordinate on a board. |
| RevBitboard revGetMobility | ( | RevBoard * | board | ) |
Gets mobility of the current player as a bitboard.
| board | RevBoard instance |
| int * revGetMobilityAsArray | ( | RevBoard * | board | ) |
Gets mobility of the current player as an array of integers.
| board | RevBoard instance |
| int revGetMobilityCount | ( | RevBoard * | board | ) |
Gets the number of legal moves for the current player.
| board | RevBoard instance |
| RevDiskType revGetWinner | ( | RevBoard * | board | ) |
Returns which player has more disks on a board.
| board | RevBoard instance |
| int revHasLegalMoves | ( | RevBoard * | board | ) |
Returns whether or not the current player has legal moves.
| board | RevBoard instance |
TRUE if the current player has legal moves, FALSE otherwise. | void revInitBoard | ( | RevBoard * | board | ) |
Initializes a board with the fixed four disks.
| board | RevBoard instance |
| int revIsLegalMove | ( | RevBoard * | board, |
| int | pos | ||
| ) |
Returns whether or not a move is legal.
| board | RevBoard instance |
| pos | a position on a bitboard. pos = x + y * 8 |
TRUE if the move is legal, FALSE otherwise. | int revIsLegalMoveXY | ( | RevBoard * | board, |
| int | x, | ||
| int | y | ||
| ) |
Returns whether or not a move is legal.
| board | RevBoard instance |
| x | x-coordinate on a board. |
| y | y-coordinate on a board. |
TRUE if the move is legal, FALSE otherwise. | RevBitboard revMove | ( | RevBoard * | board, |
| int | pos | ||
| ) |
Flips disks, changes the current player, and calculates mobility.
| board | RevBoard instance |
| pos | a position on a bitboard. pos = x + y * 8 |
| void revMoveRandomToEnd | ( | RevBoard * | board | ) |
Plays the game to the end randomly.
| board | RevBoard instance |
| RevBitboard revMoveXY | ( | RevBoard * | board, |
| int | x, | ||
| int | y | ||
| ) |
Flips disks, changes the current player, and calculates mobility.
| board | RevBoard instance |
| x | x-coordinate on a board. |
| y | y-coordinate on a board. |
| RevBoard * revNewBoard | ( | ) |
Creates a new board.
| void revPrintBoardWithMobility | ( | RevBoard * | board | ) |
Outputs a board with mobility to stdout.
| board | RevBoard instance |
| void revSetBitboard | ( | RevBoard * | board, |
| RevDiskType | disk_type, | ||
| RevBitboard | b | ||
| ) |
Sets a bitboard of a player.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| b | a new bitboard |
| void revSetDisk | ( | RevBoard * | board, |
| RevDiskType | disk_type, | ||
| int | pos | ||
| ) |
Sets a disk on a board.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| pos | a position on a bitboard. pos = x + y * 8 |
| void revSetDiskXY | ( | RevBoard * | board, |
| RevDiskType | disk_type, | ||
| int | x, | ||
| int | y | ||
| ) |
Sets a disk on a board.
| board | RevBoard instance |
| disk_type | DISK_BLACK or DISK_WHITE |
| x | x-coordinate on a board. |
| y | y-coordinate on a board. |
| void revUpdateMobility | ( | RevBoard * | board | ) |
Calculates mobility of the current player.
You should call this method after editing bitboards. You can get the result with revGetMobility() or revGetMobilityAsArray().
| board | RevBoard instance |