simple-go.h
Raw
1#ifndef SIMPLE_GO_H
2#define SIMPLE_GO_H
3#include <stdlib.h>
4#include <stdint.h>
5#include <stdbool.h>
6#include <stdio.h>
7#include <assert.h>
8#include <string.h>
9
10#define BLACK 'b'
11#define WHITE 'w'
12#define EMPTY '.'
13#define GROUP '#'
14#define INVALID_FIELD '\0'
15#define COUNTED '+'
16
17typedef struct go_board
18{
19 char* field_array;
20 size_t size;
21} go_board;
22
23typedef struct game_state
24{
25 go_board* board;
26 bool black_turn;
27} game_state;
28
29
30go_board* create_board(size_t size);
31void delete_board(go_board* board);
32game_state* create_game(size_t size);
33void delete_game(game_state* game);
34
35bool check_bounds(go_board* board, size_t y, size_t x);
36char get_board_at(go_board* board, size_t y, size_t x);
37void set_board_at(go_board* board, size_t y, size_t x, char item);
38
39void kill_group(go_board* board, go_board* overlay);
40bool play_at(game_state* game, size_t y, size_t x);
41
42void print_board(go_board* board);
43void find_group(go_board* board, go_board* overlay, size_t y, size_t x);
44size_t count_liberties(go_board* board, go_board* overlay);
45
46
47
48
49
50#endif //SIMPLE_GO_H
51