CookieCat

an educational open source chess program by Steven Edwards designed for pedagogical purposes, written in Free Pascal. CookieCat evolved from the earlier **Bozochess** project announced in October 2011, renamed in December 2011 , and first released in January 2012 under the [|permissive] [|BSD License]. However, Steven's wish that his CookieCat should be easily searchable on the net without too many false positives didn't fulfill when [|Steven Universe] came up with a fictional character and ice cream in 2013. || toc =Description= CookieCat utilizes bitboards as basic data structure to represent the board. Inside CookieCat's source code, there are three groups of routines named after some of Steven's [|feline] companions. There are the **Lucky** positional evaluator routines, the **Smokey** mate finder routines, and the **Spooky** general search routines. The names were chosen not so much to be cute, but rather to make it easier for others to identify the program's functional organization. CookieCat features five hash-tables, beside the main transposition table, an endgame tablebase cache, a pawn hash table, evaluation hash table, and a dedicated perft hash table, and can further probe an opening book and Edwards' tablebases. 
 * Home * Engines * CookieCat**
 * [[image:spooky.jpg link="http://4.bp.blogspot.com/-e-zuCaeA7No/T5bmrS8kvtI/AAAAAAAAFic/n0gPYVR82PU/s1600/smokey19350407+Smokey+Stover+First+Spooky+Bill+Holman.jpg"]] ||~ || **CookieCat**,
 * Spooky ||~ ||^ ||

Bitboard Infrastructure
Bitboards are defined as union ([|variable structure]) of four 16-bit words and one 64 bit value: code format="pascal" bbtype = record case Boolean of         False: (wvec: array [bbwtype] of bbwspantype); { Array of bitboard words } True: (bv64: ui64type)                        { Unsigned 64 bit value } end; code Population count and BitScan rely on 16-bit lookups: code format="pascal" function BbCount(var bb: bbtype): cctype; inline; var myresult: cctype; bbw: bbwtype; begin with bb do     begin myresult := 0; for bbw := bbwmin to bbwmax do         myresult := myresult + bitcountvec[wvec[bbw]] end; BbCount := myresult end; { BbCount }

function BbFirstSq(var bb: bbtype): sqxtype; inline; var myresult: sqxtype; bbwindex: Integer; wordfirstbit: Integer; begin with bb do     begin myresult := sqnil; bbwindex := 0; while (myresult = sqnil) and (bbwindex < bbwlen) do         begin wordfirstbit := bitfirstvec[wvec[bbwindex]]; if wordfirstbit >= 0 then myresult := sqxtype(wordfirstbit + (bbwindex * bbwbitlen)) else Inc(bbwindex) end end; BbFirstSq := myresult end; { BbFirstSq } code

Spooky
CookieCat's search dubbed **Spooky** is implemented as iterative search using a [|finite-state machine] as nested procedure inside SpookyFindMove, which structure is outlined in following snippet: code format="pascal" { ***** Spooky search routines ***** } procedure SpookyFindMove(var ssc: ssctype); procedure SpookyPrepareRoot; procedure SpookyIterationSequence; procedure SpookyIterate; procedure SpookySearch; procedure SpookyLimitTestNode; procedure SpookyMovePick; procedure SpookyOrderMoves; procedure SpookyPickThis(index: Integer); procedure SpookyMinimax; begin { SpookySearch } with ssc do           while pirvec[ply].nss <> nssexit do              case pirvec[ply].nss of                nssplystart:    { Search state: Initialize processing at this node } nssfirdrawtest: { Search state: Draw tests for fiftymoves/insufficient/repetition } nsstbprobe:    { Search state: Probe the tablebases } nssstandtest:  { Search state: Gainer (QSearch ed.) search stand-pat evaluation and test } nssgenerate:   { Search state: Move generation } nssmovepick:   { Search state: Move pick } nssexecute:    { Search state: Execute the move and advance one ply } nssretract:    { Search state: Retreat one ply and retract the move } nsspostscan:   { Search state: Post move scan operations } nssplyfinish:  { Search state: Final processing for this node } end; { SpookySearch } end; { SpookyIterate } end; { SpookyIterationSequence } end; { SpookyFindMove } code

Smokey
code format="pascal" { ***** Smokey mate finder routines ***** } procedure SmokeyFindMate(var ssc: ssctype; fmvc: Integer); procedure SmokeySearch; procedure SmokeyApplyKillerBonus; begin with ssc do       while pirvec[ply].nss <> nssexit do          case pirvec[ply].nss of            nssplystart: nsstermtest: nssgenerate: nssmovepick: nssexecute: nssretract: nsspostscan: end; { SmokeySearch } end; { SmokeyFindMate } code
 * Smokey** is CookieCat's iterative mate finder with nested procedures outlined below:

Lucky

 * Lucky**, CookieCat's evaluation function with evaluation hash table and pawn hash table considers material, pawn structure with focus on passed pawns, and piece mobility.

=Download=
 * [[File:CookieCat.tar]]

=See also=
 * Bobcat
 * Chess 0.5
 * Comics
 * Mammal
 * Murka
 * Myopic
 * Spector
 * Symbolic
 * WildCat

=Forum Posts=

2011
> [|Release date target] by Steven Edwards, CCC, October 16, 2011 > [|The name change] by Steven Edwards, CCC, December 16, 2011
 * [|Announcement: The Bozochess Project] by Steven Edwards, CCC, October 05, 2011
 * [|BozoChess Monday release schedule] by Steven Edwards, CCC, December 12, 2011
 * [|Number sequence puzzle] by Steven Edwards, CCC, December 16, 2011 » Endgame Tablebases
 * [|CookieCat Monday release schedule] by Steven Edwards, CCC, December 19, 2011
 * [|Tablebase class name list available] by Steven Edwards, CCC, December 19, 2011 » Endgame Tablebases
 * [|CookieCat sample games] by Steven Edwards, CCC, December 24, 2011
 * [|CookieCat goes mulithreaded] by Steven Edwards, CCC, December 31, 2011 » Perft

2012 ...

 * [|CookieCat's opening book implementation] by Steven Edwards, CCC, January 05, 2012 » Opening Book
 * [|CookieCat's pawn structure code] by Steven Edwards, CCC, January 07, 2012
 * [|CookieCat's early search termination] by Steven Edwards, CCC, January 07, 2012
 * [|CookieCat and Cookie Cat] by Steven Edwards, CCC, January 08, 2012
 * [|CookieCat source via the net] by Steven Edwards, CCC, January 26, 2012
 * [|CookieCat and perft] by Steven Edwards, CCC, October 14, 2012
 * [|For a limited time, two sources] by Steven Edwards, CCC, January 22, 2013 » Myopic

=External Links=
 * [|Cookie from Wikipedia]
 * [|Cat from Wikipedia]
 * [|Lucky from Wikipedia]
 * [|Smokey from Wikipedia]
 * [|Smokey Stover from Wikipedia]
 * [|Spooky from Wikipedia]

=References= =What links here?= include page="CookieCat" component="backlinks" limit="80"
 * Up one level**