https://dl.dropboxusercontent.com/u/316 ... t5movie.gz
Download, then:
Code: Select all
gzcat perft5movie.gz
Moderators: hgm, Rebel, chrisw
Code: Select all
gzcat perft5movie.gz
Code: Select all
gzcat perft5movie.gz
Soon I'll have Oscar ready for release and then you'll be able to fiddle with the movie generator, plus see a movie as it's being generated.mar wrote:Nice movie, a bit too long though And maybe I would change some of the colors (not much to choose from).
ANSI sequences are fun, reminds me of BBSes and old text mode games.
Code: Select all
// Perft movie routines
static void PmPutChar(Pm * const pmptr, const char ch)
{
// This routine is the gateway for outputing characters to the given perft movie.
fputc(ch, pmptr->vfptr);
}
static void PmPutStr(Pm * const pmptr, const char * const chptr)
{
// This routine outputs a string to the given ASCII movie file.
ui index = 0;
while (chptr[index] != '\0')
PmPutChar(pmptr, chptr[index++]);
}
static void PmPutEscSeq(Pm * const pmptr)
{
// This routine outputs an ASCII escape sequence prefix to the given perft movie.
PmPutStr(pmptr, "\x1b[");
}
static void PmPutEscSeqStr(Pm * const pmptr, const char * const str)
{
// This routine outputs an ASCII escape sequence prefix and a string to the given perft movie.
PmPutEscSeq(pmptr);
PmPutStr(pmptr, str);
}
static void PmAttributesReset(Pm * const pmptr)
{
// This routine outputs an attributes reset directive to the given perft movie.
PmPutEscSeqStr(pmptr, "0m");
}
static void PmClearDisplay(Pm * const pmptr)
{
// This routine outputs a clear display directive to the given perft movie.
PmPutEscSeqStr(pmptr, "2J");
}
static void PmClearToEOL(Pm * const pmptr)
{
// This routine outputs a clear to EOL directive to the given perft movie.
PmPutEscSeqStr(pmptr, "0K");
}
static void PmCursorOff(Pm * const pmptr)
{
// This routine turns off the cursor on the given perft movie.
PmPutEscSeqStr(pmptr, "?25l");
}
static void PmCursorOn(Pm * const pmptr)
{
// This routine turns on the cursor on the given perft movie.
PmPutEscSeqStr(pmptr, "?25h");
}
static void PmCursorMove(Pm * const pmptr, const ui row, const ui column)
{
// This routine outputs a cursor positioning directive to the given perft movie.
char cv[TextLineLen];
sprintf(cv, "%u;%uH", (row + 1), (column + 1));
PmPutEscSeqStr(pmptr, cv);
}
static void PmSetColors(Pm * const pmptr, const Ac acfore, const Ac acback)
{
// This routine outputs a color directive to the given perft movie.
char cv[TextLineLen];
sprintf(cv, "%u;%um", (acfore + 30), (acback + 40));
PmPutEscSeqStr(pmptr, cv);
}
static void PmPutMan(Pm * const pmptr, const Man man, const Sq sq)
{
// This routine outputs a chessman on a square to the given perft movie.
const File file = MapSqToFile(sq);
const Rank rank = MapSqToRank(sq);
Ac acfore, acback;
if ((rank & 1) == (file & 1))
acback = AcGreen;
else
acback = AcWhite;
if (IsManVacant(man))
acfore = AcBlack;
else
{
if (IsManWhite(man))
acfore = AcRed;
else
acfore = AcBlue;
};
PmCursorMove(pmptr, (RankLen - 1 - rank), (file * 2));
PmSetColors(pmptr, acfore, acback);
if (IsManVacant(man))
PmPutStr(pmptr, " ");
else
{
PmPutChar(pmptr, CvColorToChar[CvManToColor[man]]);
PmPutChar(pmptr, CvPieceToChar[CvManToPiece[man]]);
};
}
static void PmPutBoard(Pm * const pmptr, const Board * const boardptr)
{
// This routine outputs a chessboard to the given perft movie.
Rank rank;
for (rank = Rank8; rank >= Rank1; rank--)
{
File file;
for (file = FileA; file <= FileH; file++)
{
const Sq sq = MapFileRankToSq(file, rank);
const Man man = boardptr->manvec[sq];
PmPutMan(pmptr, man, sq);
};
};
}
static void PmPushMove(Pm * const pmptr, const Move move)
{
if (pmptr->mpcount < PmMoveLen)
{
SanRec sanrec;
SanRecLoadFromMove(&sanrec, move);
pmptr->cols[pmptr->mpcount] = pmptr->column;
PmCursorMove(pmptr, RankLen, pmptr->column);
PmAttributesReset(pmptr);
if (pmptr->mpcount > 0)
{
PmPutChar(pmptr, ' ');
pmptr->column++;
};
PmPutStr(pmptr, sanrec.chvec);
pmptr->column += StrLength(sanrec.chvec);
};
pmptr->mpcount++;
}
static void PmPopMove(Pm * const pmptr)
{
pmptr->mpcount--;
if (pmptr->mpcount < PmMoveLen)
{
pmptr->column = pmptr->cols[pmptr->mpcount];
PmCursorMove(pmptr, RankLen, pmptr->column);
PmAttributesReset(pmptr);
PmClearToEOL(pmptr);
};
}
static void PmUpdateBoard(Pm * const pmptr, const Board * const boardptr, const Move move)
{
const Mc mc = GetMc(move);
Sq sqvec[5];
Sq sq;
ui index = 0;
switch (mc)
{
case McReg:
sqvec[index++] = GetFrSq(move);
sqvec[index++] = GetToSq(move);
break;
case McEPC:
{
const Color other = CvColorToOtherColor[CvManToColor[GetFrMan(move)]];
const Sq vpsq = NextSq[CvColorToAdvDir[other]][GetToSq(move)];
sqvec[index++] = GetFrSq(move);
sqvec[index++] = GetToSq(move);
sqvec[index++] = GetToSq(vpsq);
};
break;
case McCQS:
case McCKS:
{
const Color color = CvManToColor[GetFrMan(move)];
const Castling castling = CvColorMcToCastling[color][mc];
sqvec[index++] = GetFrSq(move);
sqvec[index++] = GetToSq(move);
sqvec[index++] = CastInfo[castling].r0sq;
sqvec[index++] = CastInfo[castling].r1sq;
};
break;
case McPPN:
case McPPB:
case McPPR:
case McPPQ:
sqvec[index++] = GetFrSq(move);
sqvec[index++] = GetToSq(move);
break;
default:
break;
};
sqvec[index] = SqNil;
index = 0;
while (IsSqNotNil(sq = sqvec[index++]))
PmPutMan(pmptr, boardptr->manvec[sq], sq);
}
Code: Select all
-rw-r--r-- 1 sje staff 214694036 Sep 28 05:18 perft6movie.gz
-rw-r--r-- 1 sje staff 6059485118 Sep 28 09:47 perft7movie.gz
In Windows, I use 7-zip and get a file called amov (no extension)sje wrote:Download, then:Code: Select all
gzcat perft5movie.gz
It relies on ANSI escape codes; something that Windows does not implement. gzcat dumps amov to the terminal, resulting in a nice pretty perft movie.ernest wrote:In Windows, I use 7-zip and get a file called amov (no extension)sje wrote:Download, then:Code: Select all
gzcat perft5movie.gz
How do I play that "movie" ?