Age | Commit message (Collapse) | Author |
|
|
|
Also deleted some dead code.
|
|
|
|
|
|
Use one loop for walking away from the move in each direction. Before
there was one loop for each direction, one after another. The other way
is probably slightly more efficient, but this seems quite a bit more
readable.
Also started working on applying the move diagonally, since both reversi
and othello seem to allow diagonal moves.
|
|
|
|
|
|
|
|
This will return zero for invalid moves, and non-zero for valid moves.
This means we can continue to use the result of this as a boolean.
Also created a new Scheme primitive which returns the number of tiles
flipped by a given move.
Created two strategies. One which picks the move that flips the most
tiles in the current turn, and one which flips the least.
|
|
This could be useful to create a machine learning AI, which uses the
final board for training.
Also bubble up the final score and present it at the end of the game.
|
|
* Move print_board function to board.c
* Move the move validation functions to move.c
|
|
|
|
* Moved board specific functions from othello.h to new othello_board.h
* Removed unused function pointer for player moves
* Added prototypes in headers for SCM functions, including
scm_get_current_player,
* Made get_winner accept a board and current player. This is useful for
predictions to see if some move would make the other player a winner.
* get_winner also writes the players scores to provided pointers.
|
|
|
|
* free_board should not return anything.
* is_valid_move and has_valid_moves accept a board.
* Implemented primitives for Scheme strategies to get the current
player, and to get the board, and the validity of a move.
* Removed game logic from is_valid_move. Instead simply apply the move
to a temp board, and see if the move worked.
* Created a very simple strategy for testing these primitives. It only
hardcodes the first move, and then fails since that move is no longer
valid.
|
|
Also was able to print the current board from scheme, so we should be
able to do basic analysis at least. Should add more primitives for use
from scheme.
|
|
|
|
This was how it originally was, but I changed it to use a global
variable instead. I want to be able to use the apply_move function in
the is_valid_move implementation, to have all the logic for checking if
a move is valid in one place.
Moved the apply_move function out of board.c, since it no longer
needs a direct reference to the board.
|
|
Also fixed a bug where we could have gone off the upper bounds of the
board.
|
|
|
|
Instead use the get_board() function to get a reference to the board.
|
|
|
|
Useful for creating reproducible build environments
Also bumped guile version to 3.0
Moved stdio.h include above readline includes.
|
|
Also removed unused function
|
|
|
|
Also made the apply_move function a bit more efficient, and return true
if the move was valid. This helps because we can simply use the
apply_move function for checking the validity of a move, rather than
having a seperate function do similar logic.
Use readline.h to read input from the user instead of getline. This adds
some quality-of-life improvements.
|
|
If the player is an AI one, it will point to a function that will return
the move from the AI. If the player is a human, it will point to a
function that will prompt the user for input.
|
|
We are not aiming for high portability with this program. Anywhere that
Guile is available, we should be able to access _GNU_SOURCE extensions.
|
|
This makes sure we don't accidentally overrun the board.
Also added a comment as to why we have the if statement in the
check_valid_direction macro.
|
|
|
|
|
|
|
|
The macro checks for the validity of a move in each direction.
|
|
It already returns 1 for player 1 and 2 for player 2.
|
|
|
|
|
|
|
|
The player_color type already is set to char, but this is a bit clearer
as to what the actual return values are
|
|
We wont need to mutate the board in the print function.
|
|
|