GithubHelp home page GithubHelp logo

khml / sanmoku Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 100 KB

Tic Tac Toe Program. Implemented by C++ and Python.

License: MIT License

C++ 47.61% Makefile 23.29% Shell 4.68% C 6.54% Python 16.91% CMake 0.96%

sanmoku's Introduction

Sanmoku

This is Tic Tac Toe Program. Implemented by C++ and Python.

Using pybind11, generate Python Sanmoku Module.

Required Library

LibTorch

build C++ src

# build
$ mkdir build && cd build
$ cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch ..
$ make 

execute args

./sanmoku train TrainingTimes(required) modelPath(option)
./sanmoku play modelPath(option)

train mode

$ ./sanmoku train 1

., ., .,
x, ., .,
., ., .,

., ., o,
x, ., .,
., ., .,

., ., o,
x, ., .,
., x, .,

., ., o,
x, ., .,
o, x, .,

., x, o,
x, ., .,
o, x, .,

., x, o,
x, o, .,
o, x, .,

game finished! result : o
Loss = 2.17941
Loss = 2.4002
Loss = 2.02983

play mode

$ ./sanmoku play

Pos index
0 1 2
3 4 5
6 7 8
color(o or x),pos (e.g. o3)

input = genx
., ., x,
., ., .,
., ., .,

input = geno
., o, x,
., ., .,
., ., .,

input = o4
., o, x,
., o, .,
., ., .,

input = genx
., o, x,
., o, .,
., x, .,

input = geno
., o, x,
., o, .,
o, x, .,

input = x8
., o, x,
., o, .,
o, x, x,

input = genx
., o, x,
., o, x,
o, x, x,

game finished! result : x

Training Sanmoku Player

Using PyTorch and Sanmoku Module, training Sanmoku Neural Network Player with Python.

c.f. sanmoku/cc/README.md

training Sanmoku Neural Network Player.

$ cd sanmoku/python

$ python play.py

execute log

2019-05-07 11:20:46,153 - INFO - start
2019-05-07 11:20:46,153 - DEBUG - 
. | . | . 
. | X | . 
. | . | .
2019-05-07 11:20:46,154 - DEBUG - 
. | O | . 
. | X | . 
. | . | .
2019-05-07 11:20:46,155 - DEBUG - 
. | O | X 
. | X | . 
. | . | .
2019-05-07 11:20:46,156 - DEBUG - 
O | O | X 
. | X | . 
. | . | .
2019-05-07 11:20:46,157 - DEBUG - 
O | O | X 
X | X | . 
. | . | .
2019-05-07 11:20:46,157 - DEBUG - 
O | O | X 
X | X | . 
O | . | .
2019-05-07 11:20:46,158 - DEBUG - 
O | O | X 
X | X | . 
O | X | .
2019-05-07 11:20:46,159 - DEBUG - 
O | O | X 
X | X | O 
O | X | .
2019-05-07 11:20:46,163 - DEBUG - 
O | O | X 
X | X | O 
O | X | X
2019-05-07 11:20:46,163 - INFO - result is DRAW
2019-05-07 11:20:46,163 - INFO - finish
2019-05-07 11:20:46,163 - INFO - start
2019-05-07 11:20:46,164 - DEBUG - 
. | X | . 
. | . | . 
. | . | .
2019-05-07 11:20:46,164 - DEBUG - 
. | X | . 
. | O | . 
. | . | .
2019-05-07 11:20:46,164 - DEBUG - 
. | X | . 
. | O | X 
. | . | .
2019-05-07 11:20:46,165 - DEBUG - 
. | X | O 
. | O | X 
. | . | .
2019-05-07 11:20:46,165 - DEBUG - 
. | X | O 
. | O | X 
. | X | .
2019-05-07 11:20:46,166 - DEBUG - 
O | X | O 
. | O | X 
. | X | .
2019-05-07 11:20:46,166 - DEBUG - 
O | X | O 
. | O | X 
. | X | X
2019-05-07 11:20:46,167 - DEBUG - 
O | X | O 
O | O | X 
. | X | X
2019-05-07 11:20:46,167 - DEBUG - 
O | X | O 
O | O | X 
X | X | X
2019-05-07 11:20:46,167 - INFO - result is DRAW
2019-05-07 11:20:46,167 - INFO - finish
2019-05-07 11:20:46,167 - INFO - start
2019-05-07 11:20:46,168 - DEBUG - 
. | . | . 
. | X | . 
. | . | .
2019-05-07 11:20:46,168 - DEBUG - 
O | . | . 
. | X | . 
. | . | .
2019-05-07 11:20:46,168 - DEBUG - 
O | . | . 
X | X | . 
. | . | .
2019-05-07 11:20:46,169 - DEBUG - 
O | . | . 
X | X | O 
. | . | .
2019-05-07 11:20:46,170 - DEBUG - 
O | . | . 
X | X | O 
X | . | .
2019-05-07 11:20:46,170 - DEBUG - 
O | . | O 
X | X | O 
X | . | .
2019-05-07 11:20:46,171 - DEBUG - 
O | . | O 
X | X | O 
X | X | .
2019-05-07 11:20:46,171 - DEBUG - 
O | . | O 
X | X | O 
X | X | O
2019-05-07 11:20:46,172 - INFO - result is O win
2019-05-07 11:20:46,172 - INFO - finish
2019-05-07 11:20:46,172 - INFO - start train
2019-05-07 11:20:46,173 - INFO - loss = 2.0868489742279053
2019-05-07 11:20:46,174 - INFO - start
2019-05-07 11:20:46,175 - DEBUG - 
. | . | . 
X | . | . 
. | . | .
2019-05-07 11:20:46,175 - DEBUG - 
. | . | . 
X | . | O 
. | . | .
2019-05-07 11:20:46,177 - DEBUG - 
. | . | . 
X | X | O 
. | . | .
2019-05-07 11:20:46,178 - DEBUG - 
O | . | . 
X | X | O 
. | . | .
2019-05-07 11:20:46,179 - DEBUG - 
O | . | X 
X | X | O 
. | . | .
2019-05-07 11:20:46,179 - DEBUG - 
O | . | X 
X | X | O 
. | O | .
2019-05-07 11:20:46,182 - DEBUG - 
O | X | X 
X | X | O 
. | O | .
2019-05-07 11:20:46,185 - DEBUG - 
O | X | X 
X | X | O 
. | O | O
2019-05-07 11:20:46,185 - DEBUG - 
O | X | X 
X | X | O 
X | O | O
2019-05-07 11:20:46,186 - INFO - result is DRAW
2019-05-07 11:20:46,186 - INFO - finish

sanmoku's People

Contributors

khml avatar

Stargazers

 avatar

Watchers

 avatar

sanmoku's Issues

How to make

I can't make sanmoku .

I am very sad ...

error code
"make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: ディレクトリ '/home/nakajima/aaa/sanmoku' に入ります
"make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/sanmoku
make[2]: ディレクトリ '/home/nakajima/aaa/sanmoku' に入ります
make[2]: *** 'build/Debug/GNU-MacOSX/_ext/247dccd/Board.o' に必要なターゲット '/Users/keiichi/NetBeansProjects/sanmoku/src/Board.cpp' を make するルールがありません. 中止.
make[2]: ディレクトリ '/home/nakajima/aaa/sanmoku' から出ます
nbproject/Makefile-Debug.mk:61: ターゲット '.build-conf' のレシピで失敗しました
make[1]: *** [.build-conf] エラー 2
make[1]: ディレクトリ '/home/nakajima/aaa/sanmoku' から出ます
nbproject/Makefile-impl.mk:39: ターゲット '.build-impl' のレシピで失敗しました
make: *** [.build-impl] エラー 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.