rsmc
Loading...
Searching...
No Matches
rsmc.h File Reference

Reversi stateless model in C - API. More...

#include "rsmc/abstractions.h"
#include "rsmc/core.h"
#include "rsmc/version.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

RsmcVersion rsmc_version (void)
 
RsmcBoard rsmc_get_start_position (void)
 
RsmcBoard rsmc_apply_move (RsmcBoard board, RsmcBitMask cell_bit_mask, RsmcPlayer player)
 Set piece and flip opponent's pieces if move is valid.
 
RsmcPlayersScore rsmc_get_players_score (RsmcBoard board)
 Calculates score of both players.
 
bool rsmc_is_move_valid (RsmcBoard board, RsmcBitMask cell_bit_mask, RsmcPlayer player)
 Checks if move is valid.
 
RsmcBitMap rsmc_get_valid_moves (RsmcBoard board, RsmcPlayer player)
 Finds all valid moves for given player.
 
RsmcGameState rsmc_get_game_state (RsmcBoard board)
 Analyzes current game state: finds player score and game status.
 

Detailed Description

Reversi stateless model in C - API.

Function Documentation

◆ rsmc_apply_move()

RsmcBoard rsmc_apply_move ( RsmcBoard  board,
RsmcBitMask  cell_bit_mask,
RsmcPlayer  player 
)

Set piece and flip opponent's pieces if move is valid.

Parameters
boardcurrent RsmcBoard.
cell_bit_maskRsmcBitMask of cell where you want to place a piece.
playerRsmcPlayer to move.
Returns
new RsmcBoard after move (or old if move is invalid).

◆ rsmc_get_game_state()

RsmcGameState rsmc_get_game_state ( RsmcBoard  board)

Analyzes current game state: finds player score and game status.

Parameters
boarda constant pointer to RsmcBoard.
Returns
current RsmcGameState.

◆ rsmc_get_players_score()

RsmcPlayersScore rsmc_get_players_score ( RsmcBoard  board)

Calculates score of both players.

Parameters
boardRsmcBoard.
Returns
RsmcPlayersScore which contains score for both players.

◆ rsmc_get_start_position()

RsmcBoard rsmc_get_start_position ( void  )

Returns board with Reversi start position.

Returns
RsmcStartPosition.

◆ rsmc_get_valid_moves()

RsmcBitMap rsmc_get_valid_moves ( RsmcBoard  board,
RsmcPlayer  player 
)

Finds all valid moves for given player.

Parameters
boardRsmcBoard.
playerRsmcPlayer to search valid moves for.
Returns
RsmcBitMap, where 1 represents valid moves.

◆ rsmc_is_move_valid()

bool rsmc_is_move_valid ( RsmcBoard  board,
RsmcBitMask  cell_bit_mask,
RsmcPlayer  player 
)

Checks if move is valid.

Parameters
boarda constant pointer to RsmcBoard.
cell_bit_maskRsmcBitMask of cell where you want to place a piece.
playerRsmcPlayer to check a move for.
Returns
true if move is valid, false if not (or coords / player is invalid)

◆ rsmc_version()

RsmcVersion rsmc_version ( void  )

rsmc version as uint32_t.

Returns
major, minor and patch in one number.