-
Notifications
You must be signed in to change notification settings - Fork 0
/
players.h
99 lines (49 loc) · 1.97 KB
/
players.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef __PLAYERS_H
#define __PLAYERS_H
#include "logic.h"
struct edge_corner_weight {
unsigned int edge_weight;
unsigned int corner_weight;
};
union heuristic_config {
unsigned int edge_weight;
struct edge_corner_weight edge_corner_weight;
};
typedef union heuristic_config heuristic_config;
struct minimax_config {
int (*heuristic)(game*, heuristic_config);
heuristic_config hc;
unsigned int ply;
};
typedef struct minimax_config minimax_config;
union strategy_config {
minimax_config minimax_config;
};
typedef union strategy_config strategy_config;
/*returns the first valid move for a given turn*/
pos first_move(game* g, strategy_config unused);
/*prompts the user for a move, telling them if the move is invalid, and returns
the valid move*/
pos human(game* g, strategy_config unused);
/*returns a pos move, prioritizing corners over edges over interior pieces*/
pos immediate_tactics(game* g, strategy_config unused);
/*checks if the game is over, and returns the winner*/
int did_i_win(game* g, heuristic_config unused);
/*counts the number of pieces on the board, unweighted*/
int piece_counting(game* g, heuristic_config unused);
/*evaluates a game, weighting edges as specified by the heuristic_config*/
int prefer_edges(game* g, heuristic_config hc);
/*evaluates a game, weighting edges and corners as specified by the
heuristic_config*/
int prefer_edges_and_corners(game* g, heuristic_config hc);
/*given a game, looks ahead the specified number of plies (minimum 1 ply) and
returns the "optimal" pos*/
pos minimax(game* g, strategy_config sc);
/*makes a minimax_config given all of its fields*/
minimax_config make_mc(int (*heuristic)(game*, heuristic_config),
heuristic_config hc, unsigned ply);
/*takes in the value to be incremented, # rows - 1, # cols - 1, edge weight,
corner weight, position row, position col, and increments the value*/
void add_weight(unsigned* n, unsigned nr1, unsigned nc1, int ew, int cw,
unsigned pr, unsigned pc);
#endif