Code cleanup on the shot validation path
[Project_algorithmic_C.git] / lib / othello.h
... / ...
CommitLineData
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
22#include <stdbool.h>
23
24#include "constants.h"
25#include "list.h"
26
27/* linked list of can play shots */
28struct shots_list_s {
29 struct list_head list;
30 int y;
31 int x;
32 unsigned int type; /* can be white or black or hint allowed or hint_fordidden */
33};
34
35unsigned int current_player(unsigned int round_count);
36unsigned int eval_winner(unsigned int nb_white, unsigned int nb_black);
37
38void zero_pawns(unsigned int pawn_array[board_size][board_size]);
39void init_pawns(unsigned int pawn_array[board_size][board_size]);
40unsigned int get_box_value(int y, int x, unsigned int pawn_array[board_size][board_size]);
41void set_pawn(int y, int x, unsigned int type, unsigned int pawn_array[board_size][board_size]);
42
43bool is_box_type(int y, int x, unsigned int pawn_array[board_size][board_size], unsigned int type);
44bool is_board_full(unsigned int pawn_array[board_size][board_size]);
45
46unsigned int count_pawns_type(unsigned int pawn_array[board_size][board_size], unsigned int type);
47
48bool is_legal_shot(int y, int x, unsigned int current_player, unsigned int pawn_array[board_size][board_size]);
49unsigned int valid_shot(int y, int x, unsigned int current_player, unsigned int pawn_array[board_size][board_size]);
50
51void build_playable_shots_list(unsigned int current_player, struct shots_list_s* shots_list, unsigned int pawn_array[board_size][board_size]);
52void free_shots_list(struct shots_list_s* shots_list);
53
54#endif /* OTHELLO_H */