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 unsigned int size;
21} go_board;
22
23typedef struct game_state
24{
25 go_board* board;
26 float komi;
27 bool black_turn;
28} game_state;
29
30
31go_board* create_board(unsigned int size);
32void delete_board(go_board* board);
33game_state* create_game(unsigned int size, float komi);
34void delete_game(game_state* game);
35
36bool check_bounds(go_board* board, unsigned int y, unsigned int x);
37char get_board_at(go_board* board, unsigned int y, unsigned int x);
38void set_board_at(go_board* board, unsigned int y, unsigned int x, char item);
39
40void kill_group(go_board* board, go_board* overlay);
41bool play_at(game_state* game, unsigned int y, unsigned int x);
42
43void print_board(go_board* board);
44void find_group(go_board* board, go_board* overlay, unsigned int y, unsigned int x);
45unsigned long count_liberties(go_board* board, go_board* overlay);
46
47
48
49
50
51#endif //SIMPLE_GO_H
52