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