Older Version Newer Version

GerdIsenberg GerdIsenberg Nov 15, 2016

**[[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**,
an educational [[Open Source Engines|open source chess program]] by [[Steven Edwards]] designed for pedagogical purposes, written in [[Pascal#FreePascal|Free Pascal]] <ref>[[http://wiki.freepascal.org/Main_Page|Free Pascal wiki]]</ref>. CookieCat evolved from the earlier **Bozochess** project <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=40643&start=24|Release date target]] by [[Steven Edwards]], [[CCC]], October 16, 2011</ref> announced in October 2011 <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=40643|Announcement: The Bozochess Project]] by [[Steven Edwards]], [[CCC]], October 05, 2011</ref>, renamed in December 2011 <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=41430&start=4|The name change]] by [[Steven Edwards]], [[CCC]], December 16, 2011</ref>, and first released in January 2012 <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=42169|CookieCat source via the net]] by [[Steven Edwards]], [[CCC]], January 26, 2012</ref> under the [[https://en.wikipedia.org/wiki/Permissive_software_licence|permissive]] [[https://en.wikipedia.org/wiki/BSD_licenses|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 [[https://en.wikipedia.org/wiki/Steven_Universe|Steven Universe]] came up with a fictional character <ref>[[http://steven-universe.wikia.com/wiki/Cookie_Cat_(character)|Cookie Cat (character) | Steven Universe Wiki]]</ref> and ice cream <ref>[[http://steven-universe.wikia.com/wiki/Cookie_Cat|Cookie Cat | Steven Universe Wiki ]]</ref> in 2013. ||
|| Spooky <ref>Image from [[http://4.bp.blogspot.com/-e-zuCaeA7No/T5bmrS8kvtI/AAAAAAAAFic/n0gPYVR82PU/s1600/smokey19350407+Smokey+Stover+First+Spooky+Bill+Holman.jpg|The first Spooky and the fifth Smokey]] (April 7, 1935) from [[http://screwballcomics.blogspot.de/2012/04/how-smokey-stover-got-started-first.html|The Birth of Smokey Stover - First Puffs (1935)]], [[https://en.wikipedia.org/wiki/Bill_Holman_(cartoonist)|Bill Holman]] [[Various Classifications#Comics|Comics]], Copyright, 1935, by [[Chicago Tribune]], [[https://en.wikipedia.org/wiki/Tribune_Media_Services|New York News Syndicate Inc.]], supplied by [[https://www.blogger.com/profile/12144756085960502977|Carl Linich]], posted by [[https://plus.google.com/+PaulTumey|Paul Tumey]], April 24, 2012</ref> ||~ ||^ ||
[[toc]]
=Description=
CookieCat utilizes [[Bitboards|bitboards]] as basic data structure [[Board Representation|to represent]] the board. Inside CookieCat's source code <ref>Description is based on the source code - CookieCat.pas</ref>, there are three groups of routines named after some of Steven's [[https://en.wikipedia.org/wiki/Feline|feline]] companions. There are the **Lucky** [[Evaluation|positional evaluator]] routines, the **Smokey** [[Mate Search|mate finder]] routines, and the **Spooky** general [[Search|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 <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=41874|CookieCat and Cookie Cat]] by [[Steven Edwards]], [[CCC]], January 08, 2012</ref>. CookieCat features five [[Hash Table|hash-tables]], beside the [[Transposition Table|main transposition table]], an [[Endgame Tablebases|endgame tablebase]] cache, a [[Pawn Hash Table|pawn hash table]], [[Evaluation Hash Table|evaluation hash table]], and a dedicated [[Perft|perft hash table]], and can further probe an [[Opening Book|opening book]] <ref> [[http://www.talkchess.com/forum/viewtopic.php?t=41804|CookieCat's opening book implementation]] by [[Steven Edwards]], [[CCC]], January 05, 2012</ref> and [[Edwards' Tablebases|Edwards' tablebases]].
[[#Bitboard]]
==Bitboard Infrastructure==
[[Bitboards]] are defined as union ([[http://wiki.freepascal.org/Record#Variable_structure|variable structure]]) of four 16-bit [[Word|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]]
[[#Popcount]][[Population Count|Population count]] and [[#BitScan]][[BitScan]] rely on [[Population Count#Lookup|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|search]] dubbed **Spooky** is implemented as [[Iterative Search|iterative search]] using a [[https://en.wikipedia.org/wiki/Finite-state_machine|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==
**Smokey** is CookieCat's iterative [[Mate Search|mate finder]] with nested procedures outlined below:
[[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]]
==Lucky==
**Lucky**, CookieCat's [[Evaluation|evaluation]] function with [[Evaluation Hash Table|evaluation hash table]] and [[Pawn Hash Table|pawn hash table]] considers [[Material|material]], [[Pawn Structure|pawn structure]] with focus on [[Passed Pawn|passed pawns]] <ref>[[http://www.talkchess.com/forum/viewtopic.php?t=41842|CookieCat's pawn structure code]] by [[Steven Edwards]], [[CCC]], January 07, 2012</ref>, and [[Mobility|piece mobility]].

=Download=
<ref>Source code courtesy [[Steven Edwards]]</ref>
* [[File:CookieCat.tar]]

=See also=
* [[Bobcat]]
* [[Chess 0.5]]
* [[Various Classifications#Comics|Comics]]
* [[Various Classifications#Mammal|Mammal]]
* [[Murka]]
* [[Myopic]]
* [[Spector]]
* [[Symbolic]]
* [[WildCat]]

=Forum Posts=
==2011==
* [[http://www.talkchess.com/forum/viewtopic.php?t=40643|Announcement: The Bozochess Project]] by [[Steven Edwards]], [[CCC]], October 05, 2011
> [[http://www.talkchess.com/forum/viewtopic.php?t=40643&start=24|Release date target]] by [[Steven Edwards]], [[CCC]], October 16, 2011
* [[http://www.talkchess.com/forum/viewtopic.php?t=41430|BozoChess Monday release schedule]] by [[Steven Edwards]], [[CCC]], December 12, 2011
> [[http://www.talkchess.com/forum/viewtopic.php?t=41430&start=4|The name change]] by [[Steven Edwards]], [[CCC]], December 16, 2011
* [[http://www.talkchess.com/forum/viewtopic.php?t=41467|Number sequence puzzle]] by [[Steven Edwards]], [[CCC]], December 16, 2011 » [[Endgame Tablebases]] <ref>[[http://oeis.org/A018214|A018214 - OEIS | Alkane (or paraffin) numbers]]</ref>
* [[http://www.talkchess.com/forum/viewtopic.php?t=41522|CookieCat Monday release schedule]] by [[Steven Edwards]], [[CCC]], December 19, 2011
* [[http://www.talkchess.com/forum/viewtopic.php?t=41524|Tablebase class name list available]] by [[Steven Edwards]], [[CCC]], December 19, 2011 » [[Endgame Tablebases]]
* [[http://www.talkchess.com/forum/viewtopic.php?t=41583|CookieCat sample games]] by [[Steven Edwards]], [[CCC]], December 24, 2011
* [[http://www.talkchess.com/forum/viewtopic.php?t=41703|CookieCat goes mulithreaded]] by [[Steven Edwards]], [[CCC]], December 31, 2011 » [[Perft]]
==2012 ...==
* [[http://www.talkchess.com/forum/viewtopic.php?t=41804|CookieCat's opening book implementation]] by [[Steven Edwards]], [[CCC]], January 05, 2012 » [[Opening Book]]
* [[http://www.talkchess.com/forum/viewtopic.php?t=41842|CookieCat's pawn structure code]] by [[Steven Edwards]], [[CCC]], January 07, 2012
* [[http://www.talkchess.com/forum/viewtopic.php?t=41850|CookieCat's early search termination]] by [[Steven Edwards]], [[CCC]], January 07, 2012
* [[http://www.talkchess.com/forum/viewtopic.php?t=41874|CookieCat and Cookie Cat]] by [[Steven Edwards]], [[CCC]], January 08, 2012
* [[http://www.talkchess.com/forum/viewtopic.php?t=42169|CookieCat source via the net]] by [[Steven Edwards]], [[CCC]], January 26, 2012
* [[http://www.talkchess.com/forum/viewtopic.php?t=45568|CookieCat and perft]] by [[Steven Edwards]], [[CCC]], October 14, 2012
* [[http://www.talkchess.com/forum/viewtopic.php?t=46964|For a limited time, two sources]] by [[Steven Edwards]], [[CCC]], January 22, 2013 » [[Myopic]]

=External Links=
* [[https://en.wikipedia.org/wiki/Cookie|Cookie from Wikipedia]]
* [[https://en.wikipedia.org/wiki/Cat|Cat from Wikipedia]]
* [[https://en.wikipedia.org/wiki/Lucky|Lucky from Wikipedia]]
* [[https://en.wikipedia.org/wiki/Smokey|Smokey from Wikipedia]]
* [[https://en.wikipedia.org/wiki/Smokey_Stover|Smokey Stover from Wikipedia]]
* [[https://en.wikipedia.org/wiki/Spooky|Spooky from Wikipedia]]

=References=
<references />
=What links here?=
[[include page="CookieCat" component="backlinks" limit="80" ]]
**[[Engines|Up one level]]**