-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
8,904 additions
and
20,611 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
*.d | ||
*.o | ||
*.obj | ||
*.out | ||
*.a | ||
*.res | ||
*.lib | ||
*.dll | ||
*.exe | ||
*.pyc | ||
*.pyd | ||
*.dat | ||
|
||
*.depend | ||
*.layout | ||
*.log | ||
*.stackdump | ||
|
||
out* | ||
*temp* | ||
|
||
data/data.cc | ||
!data/pattern.dat | ||
|
||
*.dot | ||
optimize/*.png | ||
optimize/*/*.png | ||
|
||
single/*.cc | ||
|
||
!optimize/*.exe | ||
!optimize/*/*.exe | ||
|
||
python/reversi.py | ||
python/*wrap.* | ||
|
||
wxsmith/*.xrc | ||
|
||
doc/* | ||
*.d | ||
*.o | ||
*.obj | ||
*.out | ||
*.a | ||
*.so | ||
*.res | ||
*.lib | ||
*.dll | ||
*.exe | ||
*.pyc | ||
*.pyd | ||
*.dat | ||
|
||
*.depend | ||
*.layout | ||
*.log | ||
*.stackdump | ||
|
||
*reversi | ||
|
||
out* | ||
*temp* | ||
|
||
data/data.cc | ||
!data/pattern.dat | ||
|
||
*.dot | ||
profile/*.png | ||
|
||
*merge.cc | ||
|
||
python/reversi.py | ||
python/*wrap.* | ||
python/image/* | ||
|
||
doc/* | ||
|
||
build/* | ||
!build/CMakeLists.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,61 @@ | ||
## Reversi | ||
|
||
### Screenshot | ||
![](./image/reversi.png) | ||
|
||
### Overview | ||
Reversi (also called Othello) is a kind of strategy board game which involves play by two parties on an eight-by-eight square grid. For details of reversi please go to [https://en.wikipedia.org/wiki/Reversi](https://en.wikipedia.org/wiki/Reversi). | ||
|
||
This reversi project is my simple work. The kernel is written in C++11 whith a bit inline assembly. Script language Python and TCL can be embeded to ease the interaction with users. The GUI is built with wxwidgets. It can be written in C++ or python. The sources of this project can be merged in to a single file and submitted to [Botzone](https://botzone.org) which is a online platform for competition of differnt bots made by students and other programming learners. | ||
|
||
### Build reversi | ||
|
||
- Prerequisites | ||
- Essential | ||
- A decent C++ compiler | ||
C++11 must be supported by this version of compiler. The project will not use inline assembly when compiled by Visual Studio as MS compiler supports neither 64-bit inline assembly nor AT&T flavor syntax. | ||
- Optional | ||
- CodeBlocks or Cbp2make (if you want to utilize the .cbp codeblocks project file to build this project) | ||
- TCL (if you want to embed tool command language) | ||
- wxWidgets (required by the GUI version written in C++) | ||
- python (required by the GUI version written in Python and some simple scripts) | ||
- swig (required by the GUI version written in Python) | ||
- wxPython (required by the GUI version written in Python) | ||
|
||
Personally, I've only built the project on 64-bit windows and cygwin but I believe it can migrate to other platforms. | ||
|
||
- Build reversi with only basic functions | ||
2. Create a C++ project. | ||
3. Add following files to your project. | ||
type.h type.cc reversi.h reversi.cc flip.cc search.h search.cc pattern.h pattern.cc (game.h game.cc) | ||
4. Write your main.cc source file with "reversi.h" ("game.h") included. | ||
5. Compile it. | ||
|
||
- Build reversi which can be executed on [Botzone](https://botzone.org) | ||
1. Open reversi_json.cbp with CodeBlocks or use cbp2make.exe to generate makefile on your own platform. | ||
2. Compile it. | ||
|
||
To submit it to Botzone, several sources have to be merged into a single file. If you have python installed, run the script ./single/merge.py and main_merge.cc will be generated automatically. | ||
|
||
- Build reversi with tcl embeded | ||
1. Install TCL, Boost. Download cpptcl. | ||
2. Open reversi.cbp with CodeBlocks or use cbp2make.exe to generate makefile on your own platform. | ||
3. Change the paths of libraries. | ||
4. Compile it. | ||
|
||
- Build reversi GUI version with tcl embeded | ||
1. Install TCL, Boost, wxwidgets. Download cpptcl. | ||
2. Open reversi_gui.cbp with CodeBlocks or use cbp2make.exe to generate makefile on your own platform. | ||
3. Change the paths of libraries. | ||
4. Compile it. | ||
|
||
- Build reversi python GUI version (apparently there's no need to embed tcl anymore) | ||
1. Install python, swig, wxpython. | ||
2. Run cmd/shell. | ||
3. Enter the directory $(REVERSI_PROJECT)/python/ | ||
4. Type following command. | ||
`swig -python -c++ -threads reversi.i` | ||
`python setup.py build_ext --inplace --compiler=mingw32` | ||
Note: `--compiler=mingw32` has to be changed according to your compiler. | ||
If it's built successfully, dynamic link library _reversi.pyd or _reversi.dll or _reversi.so should be generated and main.py can be executed. | ||
|
||
### Development | ||
|
||
reversi.h: class board | ||
│ board::flip() | ||
│ board::score() | ||
│ board::search() | ||
│ ... | ||
│ | ||
└───game.h: class game | ||
│ │ | ||
│ └───reversi_tcl.h | ||
│ │ │ | ||
│ │ └───main.cc (C++ tcl console project) | ||
│ │ │ | ||
│ │ └───reversi_gui.h: class game_gui | ||
│ │ │ | ||
│ │ └───reversi_guiMain.h: class reversi_guiFrame (C++ tcl GUI project) | ||
│ │ | ||
│ └───reversi_gui.py: class game_gui | ||
│ │ | ||
│ └───main.py (python GUI project) | ||
│ | ||
└───main_json.cc (Botzone online project) | ||
## Reversi | ||
|
||
### Screenshot | ||
![](./image/reversi.png) | ||
|
||
### Overview | ||
Reversi (also called Othello) is a kind of strategy board game which involves play by two parties on an eight-by-eight square grid. For details of reversi please go to [https://en.wikipedia.org/wiki/Reversi](https://en.wikipedia.org/wiki/Reversi). | ||
|
||
This reversi project is my simple work. The kernel is written in C++11 whith a bit inline assembly. The GUI is witten in python. The sources of this project can be merged in to a single file and submitted to [Botzone](https://botzone.org) which is a online platform for competition of differnt bots made by students and other programming learners. | ||
|
||
### Build | ||
|
||
- Prerequisites | ||
- A decent C++ compiler | ||
C++11 must be supported by this compiler. Inline assembly will not be used when compiled by Visual Studio as MS compiler supports neither 64-bit inline assembly nor AT&T flavor syntax. | ||
- [Python3](https://www.python.org/) (required by the GUI written in Python and some simple scripts) | ||
- [swig](http://swig.org/) (required by the GUI written in Python) | ||
- [wxPython](https://www.wxpython.org/) (required by the GUI written in Python) | ||
- [CMake](https://cmake.org/) | ||
|
||
- Build reversi with GUI | ||
1. Compile the source code and generate dynamic link library _reversi.so | ||
`cd build` | ||
`cmake .` (To generate MinGW Makefiles on windows, it should be `cmake -G"MinGW Makefiles" .`) | ||
`make` | ||
`cd ..` | ||
2. Execute the project | ||
`cd python` | ||
`python3 main.py` | ||
|
||
- Build reversi for [Botzone](https://botzone.org) | ||
1. Enter the directory botzone/ | ||
`cd botzone` | ||
2. Merge sources into a single file "main_merge.cc" | ||
`python3 merge.py` | ||
|
||
### Development | ||
|
||
- File Structure | ||
|
||
cpp/reversi.h: class board | ||
│ cpp/flip.cc board::flip() | ||
│ cpp/reversi.cc | ||
│ cpp/search.cc board::search() | ||
│ ... | ||
│ | ||
└───python/game.py: class game | ||
│ │ | ||
│ └───python/main.py (python GUI project) | ||
│ | ||
└───botzone/main.cc (Botzone online project) | ||
|
||
- Profile (only available on UNIX-like systems) | ||
- Prerequisites | ||
- [graphiz](https://www.graphviz.org/) | ||
- [gprof2dot](https://github.com/jrfonseca/gprof2dot) | ||
|
||
1. Enter the directory profile/ | ||
`cd profile` | ||
2. Compile the source code and generate files "prof.log" "test.png" | ||
`make` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data |
Oops, something went wrong.