You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<boldstyle="color:#ff6347;">**IMPORTANT NOTE**</bold> This module rely on two separate submodules. It is impossible to build the python library without them. Make sure use
to download both this repository and the necessary submodules.
9
4
10
-
If interaction with the [graphics interface](https://github.com/SuZero-5DChess/5dchess_client) is preferred, please install `flask` and `flask_socketio` via `pip`.
5
+
5dchess_engine is an engine for analysing 5D chess game. It can be used as a C++ library or a python library or javascript library. There are two ways to present a game: via cli or webpage.
6
+
7
+
### Try it online!
8
+
9
+
Visit <https://ftxi.github.io/5dchess_engine/>.
11
10
12
11
### Features
13
12
14
-
5dchess_engine is an engine for analysing 5D chess game. It can be used as a C++ library or a python library. There are two ways to present a game: via cli (no dependencies) or webpage (requires python, read "IMPORTANT NOTE" above).
15
13
16
14
This program supports reading arbitary 5d chess variant specified by 5dfen. For moves, it supports long algebraic notation (which looks like `(0T13)b6b5` for physical moves and `(-1T19)e8(0T18)f8` for superphysical moves) or simplified 5dpgn notation specified in [docs/pgn-bnf.txt](docs/pgn-bnf.txt).
17
15
@@ -27,59 +25,94 @@ From my testing, hc has a better worse case performance than naive, especially w
27
25
28
26
This program supports tree shaped traversal.
29
27
30
-
### Usage (MacOS, etc.)
31
-
32
-
33
-
```sh
34
-
mkdir build
35
-
cd build
36
-
cmake ..
37
-
make
38
-
```
28
+
### Usage
39
29
40
-
After that, *go to base directory* and run `host.py`. If the server starts smoothly, the chessboard can be found at <http://127.0.0.1:5000>.
30
+
The CMake program and a modern C++ complier (C++ 20 or newer) is required. On MacOS, Xcode is enough. On windows, I suggest Visual Studio Community version 2022.
41
31
42
-
### Usage (Windows)
32
+
There are a number of ways to use the program:
33
+
1. Use the static webpage hosted on github pages. See *Try it online* above.
34
+
2. Use command-line interface. No dependencies other than cmake and a c++ compiler. See *Build Test*.
35
+
3. Build python module and host a graphics interface server via python. Requires a python runtime with `flask` and `flask_socketio` installed. See *Build Python Module*.
36
+
4. Build javascript module and host the static webpage same as the online version. See *Build WASM*.
43
37
44
-
The CMake program and a modern C++ complier (C++ 20 or newer) is required. I suggest Visual Studio Community version 2022.
38
+
#### Build Tests
45
39
46
-
```cmd
40
+
```sh
47
41
mkdir build
48
42
cd build
49
-
cmake ..
43
+
cmake .. -DTEST=on -DCMAKE_BUILD_TYPE=Release
50
44
cmake --build .
51
45
```
46
+
The performance of this code depends significantly on compiler optimizations. Without optimization, the plain (unoptimized) version may run x6 ~ x7 times slower compared to the same code compiled with `-O3` optimization.
47
+
The flag `-DCMAKE_BUILD_TYPE=Release` above is used to enable optimizations.
52
48
53
-
The last step is same as above.
54
49
55
-
### Debugging/Command Line Interface
50
+
The command line tool will be built as `build/cli`. To use it, type `cli <option>`, press enter, and then input the game in 5dpgn (press control+D to complete). Current features of the command line tool including:
51
+
-`print`: print the final state of the game
52
+
-`count [fast|naive] [<max>]`: display number of avialible moves capped by <max>
53
+
-`all [fast|naive] [<max>]`: display all legal moves capped by `<max>`
54
+
-`checkmate [fast|naive]`: determine whether the final state is checkmate/stalemate
55
+
-`diff`: compare the output of two algorithms.
56
+
-`perftest [fast|naive]`: on each intermediate state, print 1 if it is checkmate/stalemate, 0 otherwise
57
+
56
58
It is possible to run the c++ part of the code without interacting with python or web interface at all. It also makes sense to use a modern programming IDE:
57
59
```sh
58
-
mkdir build_xcode
59
-
cdbuild_xcode
60
+
mkdir build-xcode
61
+
cdbuild-xcode
60
62
cmake .. -DTEST=on -GXcode
61
63
```
62
64
On Windows, the last line should be:
63
65
```cmd
64
66
cmake .. -DTEST=on -G"Visual Studio 17 2022"
65
67
```
66
68
67
-
The performance of this code depends significantly on compiler optimizations. Without optimization, the plain (unoptimized) version may run x6 ~ x7 times slower compared to the same code compiled with `-O3` optimization.
69
+
### Build Python Module
68
70
69
-
To enable optimizations, configure the build using:
71
+
<boldstyle="color:#ff6347;">**IMPORTANT NOTE**</bold> This module rely on two separate submodules. It is impossible to build the python library without them. Make sure use
to download both this repository and the necessary submodules.
76
+
77
+
If interaction with the [graphics interface](https://github.com/SuZero-5DChess/5dchess_client) is preferred, please install `flask` and `flask_socketio` via `pip`.
70
78
79
+
```sh
80
+
mkdir build
81
+
cd build
82
+
cmake .. -DPYMODULE=on -DCMAKE_BUILD_TYPE=Release
83
+
cmake --build .
71
84
```
72
-
cmake .. -DCMAKE_BUILD_TYPE=Release -DTEST=on
85
+
86
+
To use it, go to the base directory of this project and run `host.py`. Then, visit `http://127.0.0.1:5000` with your favourite browser.
The command line tool will be built as `build/cli`. To use it, type `cli <option>`, press enter, and then input the game in 5dpgn (press control+D to complete). Current features of the command line tool including:
76
-
-`print`: print the final state of the game
77
-
-`count [fast|naive] [<max>]`: display number of avialible moves capped by <max>
78
-
-`all [fast|naive] [<max>]`: display all legal moves capped by `<max>`
79
-
-`checkmate [fast|naive]`: determine whether the final state is checkmate/stalemate
80
-
-`diff`: compare the output of two algorithms
99
+
The static website is generated in the `/build-wasm/ui/`.
100
+
Note that simply double-clicking index.html will likely fail to initialize the JavaScript components due to [CORS (Cross-Origin Resource Sharing)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS) restrictions enforced by modern browsers when using the `file://` protocol.
81
101
102
+
To run the application correctly, you must serve the directory via a local web server. Use one of the following methods from within the `build-wasm/` folder:
82
103
104
+
If you have python installed:
105
+
```sh
106
+
python -m http.server 8080 --directory ui/
107
+
```
108
+
If the emsdk is already sourced in your environment:
109
+
```sh
110
+
emrun ui/
111
+
```
112
+
If you prefer [darkhttpd](https://github.com/emikulic/darkhttpd):
113
+
```sh
114
+
darkhttpd ui/
115
+
```
83
116
84
117
### Documentation
85
118
@@ -95,4 +128,6 @@ For more detail, please read [this page](docs/index.md).
0 commit comments