From 08fcd58893b5ea754ebddbf63b2745dde34d4830 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sun, 8 Nov 2026 05:11:35 +0300 Subject: publish --- src/board.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/board.c (limited to 'src/board.c') diff --git a/src/board.c b/src/board.c new file mode 100644 index 0000000..fe798f7 --- /dev/null +++ b/src/board.c @@ -0,0 +1,36 @@ +#include "board.h" +#include "utils.h" + +void +board_init (struct board *board, uint32_t rows, uint32_t cols) +{ + bitarray_init (&board->bitarray, rows*cols); + board->rows = rows; + board->cols = cols; +} + +void +board_set (struct board *board, int32_t row, int32_t col, bool value) +{ + ASSERT (board); + + row = MOD (row, (int32_t) board->rows); + col = MOD (col, (int32_t) board->cols); + bitarray_set (&board->bitarray, row*board->cols + col, value); +} + +bool +board_get (struct board *board, int32_t row, int32_t col) +{ + ASSERT (board); + + row = MOD (row, (int32_t) board->rows); + col = MOD (col, (int32_t) board->cols); + return bitarray_get (&board->bitarray, row*board->cols + col); +} + +void +board_free (struct board *board) +{ + bitarray_free (&board->bitarray); +} -- cgit v1.3.1