Skip to content

Commit

Permalink
Fig bugs, new code for larger data
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenPham committed Sep 22, 2018
1 parent fb0f643 commit 3d9c221
Show file tree
Hide file tree
Showing 220 changed files with 3,116 additions and 125 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
*.zip
.vs
x64
FelicityEgtb.xcodeproj/project.xcworkspace/xcshareddata
FelicityEgtb.xcodeproj/project.xcworkspace/xcuserdata/
Debug
FelicityEgtb.xcodeproj/project.xcworkspace/xcshareddata/*
FelicityEgtb.xcodeproj/project.xcworkspace/xcuserdata/*
FelicityEgtb.xcodeproj/project.xcworkspace/xcuserdata
Empty file modified FelicityEgtb.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Binary file not shown.
Empty file.
98 changes: 98 additions & 0 deletions FelicityEgtb.xcodeproj/xcuserdata/TonyPham.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,102 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/main.cpp"
timestampString = "559140013.47207"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "93"
endingLineNumber = "93"
landmarkName = "main(int argc, const char * argv[])"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/main.cpp"
timestampString = "559140013.472145"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "87"
endingLineNumber = "87"
landmarkName = "main(int argc, const char * argv[])"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/main.cpp"
timestampString = "559140013.472206"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "main(int argc, const char * argv[])"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/EgtbDb.cpp"
timestampString = "559140013.4722511"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "149"
endingLineNumber = "149"
landmarkName = "EgtbDb::getScore(const int* pieceList, Side side, AcceptScore accept)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/EgtbFile.cpp"
timestampString = "559185287.015555"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "403"
endingLineNumber = "403"
landmarkName = "EgtbFile::checkToLoadHeaderAndTable(Side side)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "source/EgtbFile.cpp"
timestampString = "559185287.015605"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "402"
endingLineNumber = "402"
landmarkName = "EgtbFile::checkToLoadHeaderAndTable(Side side)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
8 changes: 3 additions & 5 deletions FelicityEgtb.xcodeproj/xcuserdata/TonyPham.xcuserdatad/xcschemes/FelicityEgtb.xcscheme
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -43,10 +42,9 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "$PROJECT_DIR"
Expand Down
Empty file.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,45 @@ Now you may query scores (distance to mate) for any position. Your input could b
std::cout << "Queried, score: " << score << std::endl;


Search
--------
Serch in alphabeta function only, not in quescience function:

if not root node && the last move is capture && total attack pieces <= egtbDb.attackPieceCount {
int egtbScore = egtbDb.getScore(current board);
if (egtbScore != EGTB_SCORE_MISSING && egtbScore != EGTB_SCORE_UNKNOWN) {
if (egtbScore == EGTB_SCORE_DRAW) {
value = VALUE_DRAW;
} else {
value = VALUE_MATE - abs(egtbScore) - current_ply - 1;
if (score < 0) value = -value;
}
return value;
}


Notations
-----------
Felicity egtb uses following notations:
- k: king, a: advisor, e: elephant, r: rook, c: cannon, h: horse, p: pawn
- m: ministry (other name for elephant pieces) when number of elephants is from 0 to 2. This symbol is used to denote the endgame is a special one, applied our research to reduce file sizes significally.
- w: white, b: black


File extensions
-----------------
- .xtb: xiangqi tablebase, not compressed
- .ztb: xiangqi tablebase, compressed
- .znt: xiangqi tablebase, compressed, using our special techniques to reduce file sizes significally
- .ltb: lookup table, support for our special technique files
- .zlt: lookup table, compressed


UCI options
-------------
You may share Felicity egtb between engines. So far those may need only the path of the main folder of the egtb. That path can pass from UCI GUI via UCI option. We suggest to use the name "FelicityPath" for that option.


Compile
----------
If you use other C++ IDE such as Visual Studio, xCode, you need to creat a new project and add all our code with prefix Egtb and all file in lzma folder, set compile flags to C++11, then those IDEs can compile those source code automatically.
Expand Down
Empty file modified VisualStudio.sln
100644 → 100755
Empty file.
Empty file modified VisualStudio.vcxproj
100644 → 100755
Empty file.
Empty file modified VisualStudio.vcxproj.user
100644 → 100755
Empty file.
Empty file modified build.sh
100644 → 100755
Empty file.
Empty file modified demo1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added egtb/.DS_Store
Binary file not shown.
Empty file modified egtb/1/kcaamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkaaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcaamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkaaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kcmkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khaamkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khamkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/khmkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpaamkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpamkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkaab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkaaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkaaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkaeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkaeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kpmkeeb.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkaaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkaaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkaaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkab.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kraamkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/kramkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkaw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkeew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkew.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/krmkw.znb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkaaeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkaaeeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkaaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkab.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkaeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkaeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcaamkeeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkaaeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkaaeeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkaaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkab.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkaeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkaeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcamkeeb.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcmkaab.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcmkaaeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kcmkaaeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkaab.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkaaeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkaaeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkab.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkaeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkaeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkeeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khaamkw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khamkab.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khamkaeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khamkeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khamkw.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khmkab.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khmkaeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khmkb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/khmkeb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kpaamkab.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kpaamkw.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kpamkab.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kpamkw.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kpmkb.ltb
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkaaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkaaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkaaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkab.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kraamkw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/kramkw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkaw.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkeew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkew.zlt
100644 → 100755
Empty file.
Empty file modified egtb/1/lu/krmkw.ltb
100644 → 100755
Empty file.
Binary file added source/.DS_Store
Binary file not shown.
41 changes: 37 additions & 4 deletions source/Egtb.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

namespace egtb {
bool egtbVerbose = false;
int availableAttackerTotal = 0;

void toLower(std::string& str) {
for(int i = 0; i < str.size(); ++i) {
Expand Down Expand Up @@ -171,22 +172,54 @@ namespace egtb {
return res == SZ_OK ? (int)dstLen : -1;
}

i64 decompressAllBlocks(int blocksize, int blocknum, u32* blocktable, char *dest, i64 uncompressedlen, const char *src, i64 slen) {
i64 decompressAllBlocks(int blocksize, int blocknum, u8* blocktable, char *dest, i64 uncompressedlen, const char *src, i64 slen) {
auto *s = src;
auto p = dest;

// for(int i = 0; i < blocknum; i++) {
// int blocksz = (blocktable[i] & ~EGTB_UNCOMPRESS_BIT) - (i == 0 ? 0 : (blocktable[i - 1] & ~EGTB_UNCOMPRESS_BIT));
// int uncompressed = blocktable[i] & EGTB_UNCOMPRESS_BIT;
//
// if (uncompressed) {
// memcpy(p, s, blocksz);
// p += blocksz;
// } else {
// auto left = uncompressedlen - (i64)(p - dest);
// auto curBlockSize = (int)MIN(left, (i64)blocksize);
//
// auto originSz = decompress((char*)p, curBlockSize, s, blocksz);
// p += originSz;
// }
// s += blocksz;
// }

int blockTableItemSize = slen > EGTB_SMALL_COMPRESS_SIZE ? 5 : 4;
for(int i = 0; i < blocknum; i++) {
int blocksz = (blocktable[i] & ~EGTB_UNCOMPRESS_BIT) - (i == 0 ? 0 : (blocktable[i - 1] & ~EGTB_UNCOMPRESS_BIT));
int uncompressed = blocktable[i] & EGTB_UNCOMPRESS_BIT;
bool uncompressed = false;
int blocksz;
if (blockTableItemSize == 4) {
const u32* p = (u32*)blocktable;
blocksz = (p[i] & EGTB_SMALL_COMPRESS_SIZE) - (i == 0 ? 0 : (p[i - 1] & EGTB_SMALL_COMPRESS_SIZE));
uncompressed = (p[i] & EGTB_UNCOMPRESS_BIT) != 0;
} else {
const u8* p = blocktable + i * blockTableItemSize;
i64 sz1 = *((i64*)p) & EGTB_LARGE_COMPRESS_SIZE;
i64 sz0 = i == 0 ? 0 : (*((i64*)(p - blockTableItemSize)) & EGTB_LARGE_COMPRESS_SIZE);
blocksz = (int)(sz1 - sz0);
uncompressed = (*((i64*)p) & EGTB_UNCOMPRESS_BIT_FOR_LARGE_COMPRESSTABLE) != 0;
}

if (uncompressed) {
assert(i + 1 == blocknum || blocksz == blocksize);
memcpy(p, s, blocksz);
p += blocksz;
} else {
auto left = uncompressedlen - (i64)(p - dest);
// Size of uncompressed data (dest, not src)
auto left = uncompressedlen - (i64)(p - dest); assert(left > 0);
auto curBlockSize = (int)MIN(left, (i64)blocksize);

auto originSz = decompress((char*)p, curBlockSize, s, blocksz);
assert(originSz == curBlockSize || (i + 1 == blocknum && originSz > 0));
p += originSz;
}
s += blocksz;
Expand Down
11 changes: 8 additions & 3 deletions source/Egtb.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ namespace egtb {
const int W = 1;

const int EGTB_UNCOMPRESS_BIT = 1 << 31;
const int64_t EGTB_SMALL_COMPRESS_SIZE = (1LL << 31) - 1;
const int64_t EGTB_UNCOMPRESS_BIT_FOR_LARGE_COMPRESSTABLE = (1LL << 39);
const int64_t EGTB_LARGE_COMPRESS_SIZE = (EGTB_UNCOMPRESS_BIT_FOR_LARGE_COMPRESSTABLE - 1); // 7fffffffff

enum EgtbMemMode {
tiny, // load minimum data into memory
Expand Down Expand Up @@ -121,7 +124,7 @@ namespace egtb {
};

enum class EgtbType {
dtm, newdtm, lookup, none
dtm, newdtm, lookup, tmp, none
};

enum EgtbLoadStatus {
Expand All @@ -141,20 +144,22 @@ namespace egtb {
std::vector<std::string> listdir(std::string dirname);

int decompress(char *dst, int uncompresslen, const char *src, int slen);
i64 decompressAllBlocks(int blocksize, int blocknum, u32* blocktable, char *dest, i64 uncompressedlen, const char *src, i64 slen);
// i64 decompressAllBlocks(int blocksize, int blocknum, u32* blocktable, char *dest, i64 uncompressedlen, const char *src, i64 slen);
i64 decompressAllBlocks(int blocksize, int blocknum, u8* blocktable, char *dest, i64 uncompressedlen, const char *src, i64 slen);

extern const int egtbPieceListStartIdxByType[7];
extern const PieceType egtbPieceListIdxToType[16];

// set it to true if you want to print out more messages
extern bool egtbVerbose;
extern int availableAttackerTotal;

class Piece;
class Move;
class MoveList;
class EgtbFile;
class EgtbLookup;
class EgtbDb;
class _EgtbDb;
class EgtbBoard;
class EgtbKeyRec;
class EgtbKey;
Expand Down
Empty file modified source/EgtbBoard.cpp
100644 → 100755
Empty file.
7 changes: 5 additions & 2 deletions source/EgtbBoard.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ namespace egtb {
}
return stringStream.str();
}
bool isEmpty() const {
return end == 0;
}
};


class EgtbBoard {
private:
protected:
Piece pieces[90];

public:
Expand Down Expand Up @@ -231,7 +234,7 @@ namespace egtb {
return pieceList_isThereAttacker((const int *)pieceList);
}

private:
protected:
std::string toString() const;

void gen_addMove(MoveList& moveList, int from, int dest, bool capOnly) const;
Expand Down
18 changes: 13 additions & 5 deletions source/EgtbDb.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace egtb;
EgtbDb::EgtbDb() {
}

EgtbDb::EgtbDb(const std::string& folder, EgtbMemMode egtbMemMode) {
EgtbDb::EgtbDb(const std::string& folder, EgtbMemMode egtbMemMode){
preload(folder, egtbMemMode);
}

Expand Down Expand Up @@ -64,6 +64,10 @@ void EgtbDb::addFolder(const std::string& folderName) {
folders.push_back(folderName);
}

EgtbFile* EgtbDb::createEgtbFile() const {
return new EgtbFile();
}

EgtbFile* EgtbDb::getEgtbFile(const std::string& name) {
return nameMap[name];
}
Expand All @@ -82,7 +86,7 @@ void EgtbDb::preload(EgtbMemMode egtbMemMode, EgtbLoadMode loadMode) {
for (auto && path : vec) {
auto p = EgtbFile::getExtensionType(path);
if (p.first == EgtbType::dtm || p.first == EgtbType::newdtm) {
EgtbFile *egtbFile = new EgtbFile();
EgtbFile *egtbFile = createEgtbFile(); //new EgtbFile();
if (egtbFile->preload(path, egtbMemMode, loadMode)) {
auto pos = map.find(egtbFile->materialsignWB);
if (pos == map.end()) {
Expand Down Expand Up @@ -146,12 +150,12 @@ int EgtbDb::getScore(const int* pieceList, Side side, AcceptScore accept) {
return EGTB_SCORE_MISSING;
}

pEgtbFile->checkToLoadHeaderAndTable(side);
pEgtbFile->checkToLoadHeaderAndTable(Side::none); // load all sides
auto r = pEgtbFile->getKey(pieceList);
auto querySide = r.second ? getXSide(side) : side;
auto querySide = r.flipSide ? getXSide(side) : side;

if (pEgtbFile->header->isSide(querySide)) {
auto score = pEgtbFile->getScore(r.first, querySide);
auto score = pEgtbFile->getScore(r.key, querySide);
if ((score == EGTB_SCORE_WINNING && accept == AcceptScore::real) || score == EGTB_SCORE_UNKNOWN) {
score = pEgtbFile->lookup((const int *)pieceList, querySide);
}
Expand Down Expand Up @@ -196,6 +200,10 @@ int EgtbDb::getScore(const EgtbBoard& board, AcceptScore accept) {
return getScore((const int*)board.pieceList, board.side, accept);
}

int EgtbDb::getScore(const EgtbBoard& board, Side side, AcceptScore accept) {
return getScore((const int*)board.pieceList, side, accept);
}

int EgtbDb::getScore(const char* fenString, AcceptScore accept) {
EgtbBoard board;
board.setFen(fenString);
Expand Down
Loading

0 comments on commit 3d9c221

Please sign in to comment.