-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.cpp
60 lines (49 loc) · 1.28 KB
/
io.cpp
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
#include <stdio.h>
#include <cstdio>
#include "defs.h"
char *PrSq(const int sq) // returns a string representation of the square
{
static char SqStr[3];
int file = FilesBrd[sq];
int rank = RanksBrd[sq];
sprintf(SqStr, "%c%c", ('a' + file), ('1' + rank));
return SqStr;
}
char *PrMove(const int move)
{
static char MvStr[6];
int ff = FilesBrd[FROMSQ(move)];
int rf = RanksBrd[FROMSQ(move)];
int ft = FilesBrd[TOSQ(move)];
int rt = RanksBrd[TOSQ(move)];
int promoted = PROMOTED(move);
if (promoted)
{
char pchar = 'q';
if (IsKn(promoted))
{
pchar = 'n';
}
else if (IsRQ(promoted) && !IsBQ(promoted))
{
pchar = 'r';
}
else if (!IsRQ(promoted) && IsBQ(promoted))
{
pchar = 'b';
}
sprintf(MvStr, "%c%c%c%c%c", ('a' + ff), ('1' + rf), ('a' + ft), ('1' + rt), pchar);
}
else
{
sprintf(MvStr, "%c%c%c%c", ('a' + ff), ('1' + rf), ('a' + ft), ('1' + rt));
}
return MvStr;
}
void PrintMoveList(const S_MOVELIST *moveList)
{
for (int i = 0; i < moveList->count; i++)
{
std::cout << "Move: " << PrMove(moveList->moves[i].move) << " Score: " << moveList->moves[i].score << std::endl;
}
}