- C++17をコンパイルできる環境
- Compiler which supports C++17 or upper
- Python (>=3)
- 作者はPython3.6で動作を確認しています。
- The author uses Python 3.6.
- 動かし方
- How to execute program.
$ git clone https://github.com/future731/2048AiProject.git
$ cd 2048AiProject
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ./main-
2048のAIは
ai/ai.cppにあるvoid init(), void initGame(), void chooseMove()という関数内を変更して書いてください。- You can improve the AI solver in function
void init(), void initGame(), void chooseMove()in fileai/ai.cpp
- You can improve the AI solver in function
-
board->boardArray()で盤面の状態を取得できます。const std::array<std::array<int, ROW_SIZE>, COL_SIZE>&型で取得することができます。- You can get board data by
board->boardArray(). The return type isconst std::array<std::array<int, ROW_SIZE>, COL_SIZE>&.
- You can get board data by
-
盤面データのそれぞれのマスは2の指数で与えられています。0は0を表します。
- The cells in the board data are the exponent of 2. 0 means the cell is blank.
-
盤面を上下左右に動かしたときの盤面はすでに計算されていて、
board->boardArrayIfUp(),board->boardArrayIfLeft(),board->boardArrayIfDown(),board->boardArrayIfRight()などで取得できます。- The four move cases are eagerly evaluated. You can get the future board data by functions
board->boardArrayIfUp(),board->boardArrayIfLeft(),board->boardArrayIfDown(),board->boardArrayIfRight().
- The four move cases are eagerly evaluated. You can get the future board data by functions
-
盤面を上下左右に動かしたときに追加で得られる点数もすでに計算されていて、
board->scoreIfUp(),board->scoreIfLeft(),board->scoreIfDown(),board->scoreIfRight()などで取得できます。- The scores are also eagerly evaluated. You can get the future board data by functions
board->scoreIfUp(),board->scoreIfLeft(),board->scoreIfDown(),board->scoreIfRight().
- The scores are also eagerly evaluated. You can get the future board data by functions
-
board->up(),board->left(),board->down(),board->right()の4種類でタイルをどちら側に動かすか操作してください。void ai()内で最後に呼ばれたものが動きとして採用されます。- Call
board->up(),board->left(),board->down()orboard->right()function invoid ai(). The next manipulation is decided by the latest called function among them.
- Call
- Version 1.0 (2018/07)
- 2048 basic game function is implemented.