-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.c
More file actions
70 lines (58 loc) · 1.58 KB
/
validate.c
File metadata and controls
70 lines (58 loc) · 1.58 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
68
69
70
#include "validate.h"
#include "board.h"
#include "evaluate.h"
#include <string.h>
#include <stdio.h>
int sqIs120(const int sq) {
return (sq>=0 && sq<120);
}
int pieceValidEmpty(const int pce) {
return (pce >= EMPTY && pce <= bK) ? 1 : 0;
}
int pceValidEmptyOffbrd(const int pce) {
return (pieceValidEmpty(pce) || pce == OFFBOARD);
}
int sqOnBoard(const int sq) {
return filesBrd[sq]==OFFBOARD ? 0 : 1;
}
int sideValid(const int side) {
return (side==WHITE || side == BLACK) ? 1 : 0;
}
int fileRankValid(const int fr) {
return (fr >= 0 && fr <= 7) ? 1 : 0;
}
int pieceValid(const int pce) {
return (pce >= wP && pce <= bK) ? 1 : 0;
}
void mirrorEvalTest(S_BOARD *pos) {
FILE *file = fopen("mirror.epd","r");
char lineIn [1024];
int ev1 = 0; int ev2 = 0;
int positions = 0;
if(file == NULL) {
printf("File Not Found\n");
return;
} else {
while(fgets (lineIn , 1024 , file) != NULL) {
parseFEN(lineIn, pos);
positions++;
ev1 = eval(pos);
mirrorBoard(pos);
ev2 = eval(pos);
if(ev1 != ev2) {
printf("\n\n\n");
parseFEN(lineIn, pos);
printBoard(pos);
mirrorBoard(pos);
printBoard(pos);
printf("\n\nMirror Fail:\n%s\n",lineIn);
getchar();
return;
}
if( (positions % 1000) == 0) {
printf("position %d\n",positions);
}
memset(&lineIn[0], 0, sizeof(lineIn));
}
}
}