mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Reformat FEN construction
Simplify and shrink code. No functional change.
This commit is contained in:
parent
193741218c
commit
9d1151575d
1 changed files with 10 additions and 17 deletions
|
@ -331,32 +331,25 @@ void Position::set_castle_right(Color c, Square rfrom) {
|
||||||
const string Position::fen() const {
|
const string Position::fen() const {
|
||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
Square sq;
|
|
||||||
int emptyCnt;
|
|
||||||
|
|
||||||
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
|
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
|
||||||
{
|
{
|
||||||
emptyCnt = 0;
|
|
||||||
|
|
||||||
for (File file = FILE_A; file <= FILE_H; file++)
|
for (File file = FILE_A; file <= FILE_H; file++)
|
||||||
{
|
{
|
||||||
sq = file | rank;
|
Square sq = file | rank;
|
||||||
|
|
||||||
if (is_empty(sq))
|
if (is_empty(sq))
|
||||||
|
{
|
||||||
|
int emptyCnt = 1;
|
||||||
|
|
||||||
|
for ( ; file < FILE_H && is_empty(sq++); file++)
|
||||||
emptyCnt++;
|
emptyCnt++;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (emptyCnt > 0)
|
|
||||||
{
|
|
||||||
ss << emptyCnt;
|
ss << emptyCnt;
|
||||||
emptyCnt = 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
ss << PieceToChar[piece_on(sq)];
|
ss << PieceToChar[piece_on(sq)];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (emptyCnt > 0)
|
|
||||||
ss << emptyCnt;
|
|
||||||
|
|
||||||
if (rank > RANK_1)
|
if (rank > RANK_1)
|
||||||
ss << '/';
|
ss << '/';
|
||||||
|
|
Loading…
Add table
Reference in a new issue