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