Skip to content

Commit

Permalink
Add SelfPlay, correct node statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
nionita committed Apr 29, 2017
1 parent 754e6f9 commit 71827b9
Show file tree
Hide file tree
Showing 9 changed files with 702 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Barbarossa-NB.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
searched nodes per second) is still far behind comparable engines written in C
or C++. Nevertheless Barbarossa can compete with many engines - as it can be
seen on the CCRL rating lists, where is it currently listed with a strength
of about 2200 ELO.
of more than 2300 ELO (the last release version, see below).

Barbarossa uses a few techniques which are well known in the computer chess scene:
\begin{compactitem}
Expand Down
60 changes: 58 additions & 2 deletions Barbarossa.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,64 @@ Executable Barbarossa
-fspec-constr-count=24
-funfolding-use-threshold=32
-fno-warn-tabs
-- -ddump-simpl -ddump-to-file -dsuppress-all -dsuppress-uniques
-- -ddump-opt-cmm -ddump-asm
CPP-Options: -DSMSTRICT
if flag(sse42)
GHC-Options: -msse4.2
if flag(ddump)
GHC-Options: -ddump-simpl -ddump-to-file -dsuppress-all -dsuppress-uniques
-ddump-opt-cmm -ddump-asm

Executable SelfPlay
Main-is: Main/SelfPlay.hs
Build-depends:
base >= 4.5,
array,
old-time,
containers,
filepath,
mtl,
parsec,
vector,
vector-algorithms,
random,
directory,
transformers,
QuickCheck,
text
Other-modules:
Eval.BasicEval,
Eval.Eval,
Eval.FileParams,
Hash.TransTab,
Hash.Zobrist,
Moves.Base,
Moves.BaseTypes,
Moves.BitBoard,
Moves.Board,
Moves.Fen,
Moves.GenMagics,
Moves.History,
Moves.Magics,
Moves.Moves,
Moves.Notation,
Moves.Pattern,
Moves.ShowMe,
Search.Albeta,
Search.AlbetaTypes,
Search.CStateMonad,
Struct.Config,
Struct.Context,
Struct.Status,
Struct.Struct,
Uci.UCI,
Uci.UciGlue
GHC-Options: -O2 -Wall
-funbox-strict-fields
-threaded
-rtsopts -with-rtsopts=-N3
-fspec-constr-count=24
-funfolding-use-threshold=32
-fno-warn-tabs
CPP-Options: -DSMSTRICT
if flag(sse42)
GHC-Options: -msse4.2
Expand Down
6 changes: 5 additions & 1 deletion Hash/TransTab.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE CPP #-}
module Hash.TransTab (
Cache, newCache, retrieveEntry, readCache, writeCache, newGener,
Cache, newCache, freeCache, retrieveEntry, readCache, writeCache, newGener,
-- checkProp
) where

Expand All @@ -12,6 +12,7 @@ import Data.Bits
import Data.Int
import Data.Word
import Foreign.Marshal.Array
import Foreign.Marshal.Alloc (free)
import Foreign.Storable
import Foreign.Ptr
import Data.Text.Unsafe (inlinePerformIO)
Expand Down Expand Up @@ -110,6 +111,9 @@ newCache mb = do
return Cache { mem = memc, lomask = lom, mimask = mim, zemask = complement mim, gener = 0 }
where cellMask = complement part3Mask -- for speed we keep both masks

freeCache :: Cache -> IO ()
freeCache = free . mem

generInc, generMsk :: Word64
generInc = 0x0100000000000000 -- 1 in first byte
generMsk = 0xFF00000000000000 -- to mask all except generation
Expand Down
13 changes: 8 additions & 5 deletions Main/Barbarossa.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ progName, progVersion, progVerSuff, progAuthor :: String
progName = "Barbarossa"
progAuthor = "Nicu Ionita"
progVersion = "0.5.0"
progVerSuff = "lmre"
progVerSuff = "self"

data Options = Options {
optConfFile :: Maybe String, -- config file
Expand Down Expand Up @@ -237,9 +237,10 @@ theReader = do
ctxLog DebugUci $ "Input: " ++ line
let euci = parseUciStr line
stop <- case euci of
Left _ -> do
Left erm -> do
ctxLog LogWarning $ "Input: " ++ line
ctxLog LogWarning $ "Parse: " ++ show euci
ctxLog LogWarning $ "Parse: " ++ show erm
answer $ infos $ "Parse: " ++ show erm
return False
Right uci -> interpret uci
unless stop theReader
Expand Down Expand Up @@ -524,14 +525,16 @@ searchTheTree draft mdraft timx tim tpm mtg rept lsc lpv rmvs = do
redp = reduceBegin $ realPly chg
start = srchStrtMs chg
used = currms - start
over = used >= mx
over = mx > 0 && used >= mx
onlyone = ms > 0 && length rmvsf == 1 && draft >= 4 -- only in normal play
draftmax = draft >= mdraft -- or maximal draft
mes = "Draft " ++ show draft ++ " Score " ++ show sc ++ " path " ++ show path
++ " ms " ++ show ms ++ " used " ++ show used
ctxLog LogInfo mes
ctxLog LogInfo $ "Time factors (reds/redp): " ++ show reds ++ " / " ++ show redp
(justStop, mxr) <- stopByChance (reds * redp) exte ms used mx draft ch totch ldCh
(justStop, mxr) <- if mx > 0
then stopByChance (reds * redp) exte ms used mx draft ch totch ldCh
else return (False, 0)
ctxLog LogInfo $ "compTime (ms/mx/mxr): " ++ show ms ++ " / " ++ show mx ++ " / " ++ show mxr
if draftmax || timint || over || onlyone || justStop
then do
Expand Down
Loading

0 comments on commit 71827b9

Please sign in to comment.