Commit | Line | Data |
---|---|---|
4ddf6f1a JB |
1 | /* |
2 | * ===================================================================================== | |
3 | * | |
4 | * Filename: othello.h | |
5 | * | |
6 | * Description: Header for othello board handling functions | |
7 | * | |
8 | * Version: 1.0 | |
9 | * Created: 25/04/2017 15:16:37 | |
10 | * Revision: none | |
11 | * Compiler: gcc | |
12 | * | |
13 | * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org | |
14 | * Organization: Piment Noir | |
15 | * | |
16 | * ===================================================================================== | |
17 | */ | |
18 | ||
19 | #ifndef OTHELLO_H | |
20 | #define OTHELLO_H | |
21 | ||
a80646b7 JB |
22 | #include <stdbool.h> |
23 | ||
2e5c1894 | 24 | #include "constants.h" |
54f1c58c | 25 | #include "list.h" |
2e5c1894 | 26 | |
45ce2fe3 | 27 | /* linked list of can play shots */ |
a80646b7 | 28 | struct shots_list_s { |
54f1c58c | 29 | struct list_head list; |
3de18b07 JB |
30 | unsigned int y; |
31 | unsigned int x; | |
a80646b7 | 32 | unsigned int type; /* can be white or black or hint allowed or hint_fordidden */ |
54f1c58c | 33 | }; |
74e2b93b JB |
34 | |
35 | unsigned int current_player(unsigned int round_count); | |
a8b54576 | 36 | unsigned int eval_winner(unsigned int nb_white, unsigned int nb_black); |
74e2b93b | 37 | |
a80646b7 JB |
38 | void zero_pawns(unsigned int pawn_array[board_size][board_size]); |
39 | void init_pawns(unsigned int pawn_array[board_size][board_size]); | |
3de18b07 JB |
40 | unsigned int get_box_value(unsigned int y, unsigned int x, unsigned int pawn_array[board_size][board_size]); |
41 | void set_pawn(unsigned int y, unsigned int x, unsigned int type, unsigned int pawn_array[board_size][board_size]); | |
74e2b93b | 42 | |
3de18b07 | 43 | bool is_box_type(unsigned int y, unsigned int x, unsigned int pawn_array[board_size][board_size], unsigned int type); |
54f1c58c | 44 | bool is_board_full(unsigned int pawn_array[board_size][board_size]); |
74e2b93b | 45 | |
a80646b7 JB |
46 | unsigned int count_pawns_type(unsigned int pawn_array[board_size][board_size], unsigned int type); |
47 | ||
3de18b07 JB |
48 | bool is_legal_shot(unsigned int y, unsigned int x, unsigned int current_player, unsigned int pawn_array[board_size][board_size]); |
49 | unsigned int valid_shot(unsigned int y, unsigned int x, unsigned int current_player, unsigned int pawn_array[board_size][board_size]); | |
2e5c1894 | 50 | |
9240af1a JB |
51 | void build_playable_shots_list(unsigned int current_player, struct shots_list_s* shots_list, unsigned int pawn_array[board_size][board_size]); |
52 | void free_shots_list(struct shots_list_s* shots_list); | |
53 | ||
4ddf6f1a | 54 | #endif /* OTHELLO_H */ |