-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI.h
More file actions
67 lines (61 loc) · 2.17 KB
/
AI.h
File metadata and controls
67 lines (61 loc) · 2.17 KB
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
#ifndef __AI_H
#define __AI_H
#include <stdint.h>
#include "common.h"
#include "board.h"
#define SetBit(A,k) ((A)[((k)/32)] |= (1 << ((k)%32)))
#define ClearBit(A,k) ((A)[((k)/32)] &= ~(1 << ((k)%32)))
#define TestBit(A,k) ((A)[((k)/32)] & (1 << ((k)%32)))
typedef struct AI_instance {
int move_nr;
int nr_wins, nr_losses, nr_games_played;
float positive_reward;
int generation;
int **brain;
int nr_ports;
int nr_synapsis;
int board_size;
int *port_type;
int nr_porttypes;
int **activation_count;
int *invert;
int **separation;
int *separation_count;
int **state_separation;
int *state_separation_count;
int *output_tag;
int zero_rate;
int one_rate;
int port_type_rate;
int unused_rate;
int output_rate;
int r_output_rate;
int separation_rate;
int state_separation_rate;
int separation_threshold;
int state_separation_threshold;
int *used_port;
int output_exponent;
int low_port;
int high_port;
} __attribute__((packed)) AI_instance_t;
extern AI_instance_t *ai_new(int nr_ports);
extern AI_instance_t *load_ai(char *file);
extern int dump_ai(char *file, AI_instance_t *ai);
extern void ai_free(AI_instance_t *ai);
extern int _get_best_move(AI_instance_t *ai, board_t * board);
extern int do_best_move(AI_instance_t *ai, board_t * board, struct uci *uci_iface);
extern void punish(AI_instance_t *ai);
extern void reward(AI_instance_t *ai);
extern void draw(AI_instance_t *ai, board_t * board);
extern float get_score(AI_instance_t *ai);
extern int mutate(AI_instance_t *a1, AI_instance_t *a2, int print, int print_stats);
extern void clear_score(AI_instance_t *ai);
extern int do_nonrandom_move(board_t *board, struct uci *uci_iface);
extern int do_random_move(board_t *board, struct uci *uci_iface);
extern int do_move_random_piece(board_t *board, struct uci *uci_iface);
extern int do_move_piece(board_t *board, enum moves_index piece_type, struct uci *uci_iface);
extern int do_pseudo_random_move(board_t *board, struct uci *uci_iface);
extern int do_piece_random_move(board_t *board, struct uci *uci_iface);
extern int eval_curcuit(piece_t *board, AI_instance_t *ai);
#endif