GithubHelp home page GithubHelp logo

puyoai / puyoai Goto Github PK

View Code? Open in Web Editor NEW
134.0 134.0 29.0 30.05 MB

AI for puyo

License: Other

HTML 0.12% CSS 0.07% JavaScript 0.94% C++ 96.13% Ruby 0.27% C 1.64% Shell 0.15% Batchfile 0.01% Python 0.68%

puyoai's Introduction

puyoai

Build Status

ぷよぷよ通のAIを書くためのフレームワークです。

実際に動いているAIの例: http://www.nicovideo.jp/watch/sm26167419

前提環境

OS

現状、Mac OS X と Ubuntu、Windows でビルドできることを確認しています。 また、32bit環境では全くテストしていません。

コンパイラ

C++14 がサポートされているコンパイラを使う必要があります。 Mac OSX や Linux では clang もしくは gcc を、Windows では Visual C++ を使うことが想定されています。

ハードウェア (CPU)

高速化のため、CPU に AVX 命令が載っていることを前提にしている箇所があります。 すなわち、2011 年〜 2012 年以降の CPU のみを対象にしています。 現状は AVX2 は前提にしていませんが、AVX2が使える場合はAVX2対応のコードがあり、AVX1版と比べて1.5倍〜2倍高速です。ただし、AVX2版のコードはgcc-4.7では全く性能がでないことが分かっているため、clangを使ってください。より新しいgccであれば直っているかもしれませんが、確認していません。

ビルド方法

必要なライブラリのインストール

全プラットフォーム共通

depot_tools をインストールしてください。PATH を通すのを忘れないように。

Linux

$ sudo apt-get install git clang
$ sudo apt-get install libprotobuf-dev libcurl4-nss-dev
$ sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev
$ sudo apt-get install libmicrohttpd-dev libffms2-dev libusb-1.0-0-dev

Mac (homebrew 前提)

Xcode、コマンドラインツール、homebrew をインストールしてください。 デフォルトで /usr/local/include などを見ないようになっている可能性がありますが、xcode-select --install を叩いておくと解決するはずです。

$ brew install pkg-config
$ brew install sdl2 SDL2_ttf SDL2_image ffmpeg libusb protobuf

Windows

Visual Studio 2017 をインストールしてください。

また、他プラットフォームと同様にビルドツールとして ninja を使いたい場合は VC 関係の設定を行うため以下の bat を各コマンドプロンプトで実行してください。

> %ProgramFiles%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat

レポジトリのダウンロード

  1. ターミナル、もしくはコマンドプロンプトで、適当なディレクトリ (e.g. ~/repos/puyoai) を作って移動し、そこで gclient config --unmanaged https://github.com/puyoai/puyoai コマンドを入力してください。.gclient ファイルがそのディレクトリに作られます。
  2. gclient sync コマンドを入力してください。必要なファイルなどがダウンロードされます。

For contributors note: puyoai レポジトリに push できる権限がある場合、gclient config は、次のようにしてください。

$ gclient config --unmanaged [email protected]:puyoai/puyoai

必要なライブラリの説明

GUI を付与したい場合、さらに次のライブラリが必要です。

http サーバーを利用して、GUIを付与することもできます。この場合、次のライブラリが必要です。

  • microhttpd

実機でAIを動かすなど、ビデオキャプチャーが必要な場合、さらに次のライブラリが必要です。

  • lib-usb1.0

ビルドのしかた Linux/Mac

$ cd ~/repos/puyoai/puyoai
$ gn gen --args="is_debug=false" out/Release
$ ninja -C out/Release

ただしこのままだと SDL が必要なものはビルドされません。

$ gn args out/Release

とするとエディタが立ち上がるので、

is_debug = false
use_capture = true
use_usb = true
use_gui = true
use_httpd = true
use_libcurl = true
use_tcp = true
use_curl = true

とすると、全部入りになります (2019-02-23 現在)。どのようなオプションがあるかは、build/BUILDCONFIG.gndeclare_args 内(複数あります)を参照してください。

is_debugtrue にすると、デバッグビルドになります。

ビルドのしかた Windows

> cd %HOME%\repos\puyoai\puyoai
> gn gen --args="is_debug=false" out/Release
> ninja -C out/Release

Linux/Mac で使えるコンフィグ option のうちいくつかは動きません。

もし Visual Studio の solution file を生成したい場合、

> cd %HOME%\repos\puyoai\puyoai
> gn gen --args="is_debug=false" --ide=vs out/Release

とすると、all.sln ファイルが out/Release 以下に生成されます。

How to run test

ビルドした後、

$ cd ~/repos/puyoai/puyoai
$ python build/run_unittest.py --build-dir=out/Debug

で全テスト走ります。

エラーがでた

もしかしたら、master ブランチが壊れているかもしれません。この場合、気づいたメンバーによってすぐに修復されます。 このドキュメントの先頭に貼ってあるCircleCIのバッジが PASSED になっていなければ、現状のコードは壊れています。 Issue List に問題を報告、もしくは Pull request を送ってください。

実行

$ cd out/Release
$ ./duel ./cpu/sample/sample ./cpu/sample_rensa/sample_rensa

duel は対戦サーバで、筐体のような役割を果たします。1 つ目の引数 sample は 1P 側を担当する AI、2 つ目の引数 sample_rensa は 2P 側を担当する AI です。 duel にオプションを渡すことで対戦速度を上げたり、ぷよの色を指定できたり、といろんな機能を引き出すことができます。ドキュメント化されていないものもありますが、

$ ./duel --help

とすると実装されている機能と必要なオプションが全部出てきます。とりあえずはそちらを参照してください。

ディレクトリの説明

  • doc/ ドキュメント
  • src/ 主なプログラムのソース。
  • build/ ビルド関連のスクリプトなど。意味のわかる方のみ使ってください。
  • arduino/ Wii 実機やアーケード基板と接続する際に使う、arduino関連のソース。
  • data/ フォントとか画像とか。
  • testdata/ キャプチャー用のテストデータ。
  • tools/ いろいろなツール類。なぜ src/ 以下じゃないのか?

puyoai's People

Contributors

colun avatar gecko655 avatar inosendo avatar mayah avatar munetoshi avatar ogiekako avatar pascaljp avatar peria avatar ryumas33 avatar shinh avatar takapt avatar tzik avatar uaua avatar yuricat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puyoai's Issues

syntek captured video is wider than somagic

The captured image with syntek driver is a bit wider than somagic. So we need to adjust BoundingBox. Can't we have the same width for syntek and somagic?

somagic has 32x32 for one puyo cell. However, syntek has 32.7 x 32 for one puyo cell.

Build failures with shinyak's code

Error message from cmake

-- Configuring done
CMake Error at cpu/CMakeLists.txt:20 (add_executable):
Cannot find source file:

player_info_test.cc

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
Call Stack (most recent call first):
cpu/shinyak/CMakeLists.txt:12 (cpu_add_executable)
cpu/shinyak/CMakeLists.txt:18 (shinyak_add_executable)
cpu/shinyak/CMakeLists.txt:36 (shinyak_add_test)

You can resolve this issue with adding your player_info_test.cc

cpu/test_lockit/*.cpp can be merged

cpu/test_lockit/*.cpp のファイルはほとんど違いがいないのでコンパイル時パラメータで振り分けられるようにするとメンテナンス性が上がる。

$ diff nidub.cpp rendaS9.cpp
21c21
< bool is_2dub_cpu = true;

---
> bool is_2dub_cpu = false;

$ diff nidub.cpp rendaGS9.cpp
8c8
< int e_t = 1;

---
> int e_t = 0;
11c11
< int y_t = 3;

---
> int y_t = 2;
14,15c14,15
< int o_t = 0;
< int p_t = 4;

---
> int o_t = 1;
> int p_t = 2;
18,21c18,21
< int takasa_point = 240; // G,S
< int ruiseki_point = 0; // T,S
< int renketu_bairitu = 4; // S
< bool is_2dub_cpu = true;

---
> int takasa_point = 240;
> int ruiseki_point = 6;
> int renketu_bairitu = 1;
> bool is_2dub_cpu = false;

global-buffer-overflow in CoreField::framesToDropNext

$ asan_symbolize ../ < cpu/peria/peria.err| c++filt                                                                                                                                                                 [~/github/puyo/ai/build]
=================================================================
==5131==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000453afc at pc 0x43d691 bp 0x7ffff99c6590 sp 0x7ffff99c6588
READ of size 4 at 0x000000453afc thread T0
    #0 0x43d690 in CoreField::framesToDropNext(Decision const&) const core_field.cc:195
    #1 0x433c9c in iterateAvailablePlansInternal(CoreField const&, KumipuyoSeq const&, std::vector<Decision, std::allocator<Decision> >&, int, int, int, int, std::function<void (RefPlan const&)>) plan.cc:99
    #2 0x4336f2 in Plan::iterateAvailablePlans(CoreField const&, KumipuyoSeq const&, int, std::function<void (RefPlan const&)>) plan.cc:141
    #3 0x430e1d in peria::Ai::think(int, PlainField const&, KumipuyoSeq const&) ai.cc:74
    #4 0x431a1f in AI::thinkFast(int, PlainField const&, KumipuyoSeq const&) ai.h:43
    #5 0x435940 in AI::runLoop() ai.cc:81
    #6 0x4301c9 in main main.cc:11
    #7 0x7f434d7e1ec4 in __libc_start_main libc-start.c:287
    #8 0x42ffec in _start ??:?
0x000000453afc is located 4 bytes to the left of global variable 'FRAMES_TO_DROP_FAST' from '/home/peria/github/puyo/ai/src/core/field/core_field.cc' (0x453b00) of size 60
0x000000453afc is located 36 bytes to the right of global variable 'FRAMES_TO_MOVE_HORIZONTALLY' from '/home/peria/github/puyo/ai/src/core/field/core_field.cc' (0x453ac0) of size 24
Shadow bytes around the buggy address:
  0x000080082700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080082710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080082720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080082730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080082740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x000080082750: 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9[f9]
  0x000080082760:00 00 00 00 00 00 00 04 f9 f9 f9 f9 00 00 00 00
  0x000080082770: 00 00 00 04 f9 f9 f9 f9 00 00 00 00 00 00 00 f9
  0x000080082780: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 00
  0x000080082790: 02 f9 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0000800827a0: 00 00 02 f9 f9 f9 f9 f9 00 00 00 00 05 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==5131==ABORTING

stack-buffer-overflow

$ asan_symbolize ../ < cpu/mayah/run.err | c++filt
=================================================================
==5818==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff84351534 at pc 0x45d13f bp 0x7fff843514d0 sp 0x7fff843514c8
READ of size 4 at 0x7fff84351534 thread T0
    #0 0x45d13e in void evalRensaHandWidthFeature<NormalScoreCollector>(NormalScoreCollector*, RefPlan const&, RensaTrackResult const&) evaluator_inl.h:403
    #1 0x45b584 in operator() evaluator_inl.h:512
    #2 0x45b098 in std::_Function_handler<void (CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&), void collectScore<NormalScoreCollector>(NormalScoreCollector*, std::vector<BookField, std::allocator<BookField> > const&, RefPlan const&, CoreField const&, int, int, Gazer const&)::{lambda(CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&)#1}>::_M_invoke(std::_Any_data const&, CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&) functional:2072
    #3 0x4984d5 in std::function<void (CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&)>::operator()(CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&) const functional:2464
    #4 0x497de5 in std::function<void (CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&)>::operator()(CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&) const functional:2464
    #5 0x4974ad in std::function<void (CoreField*, ColumnPuyoList const&)>::operator()(CoreField*, ColumnPuyoList const&) const functional:2464
    #6 0x49663e in RensaDetector::iteratePossibleRensasIteratively(CoreField const&, int, std::function<void (CoreField const&, RensaResult const&, ColumnPuyoList const&, ColumnPuyoList const&, RensaTrackResult const&, RensaRefSequence const&)>, RensaDetector::Mode) rensa_detector.cc:336
    #7 0x44ec68 in void collectScore<NormalScoreCollector>(NormalScoreCollector*, std::vector<BookField, std::allocator<BookField> > const&, RefPlan const&, CoreField const&, int, int, Gazer const&) evaluator_inl.h:526
    #8 0x44cc24 in Evaluator::eval(RefPlan const&, CoreField const&, int, int, Gazer const&) evaluator.cc:91
    #9 0x43c602 in operator() mayah_ai.cc:94
    #10 0x493e1b in std::function<void (RefPlan const&)>::operator()(RefPlan const&) const functional:2464
    #11 0x493fc8 in iterateAvailablePlansInternal(CoreField const&, KumipuyoSeq const&, std::vector<Decision, std::allocator<Decision> >&, int, int, int, int, std::function<void (RefPlan const&)>) plan.cc:122
    #12 0x4934b2 in Plan::iterateAvailablePlans(CoreField const&, KumipuyoSeq const&, int, std::function<void (RefPlan const&)>) plan.cc:141
    #13 0x438d85 in MayahAI::thinkPlan(int, CoreField const&, KumipuyoSeq const&, int, int) mayah_ai.cc:92
    #14 0x438397 in MayahAI::think(int, PlainField const&, KumipuyoSeq const&) mayah_ai.cc:66
    #15 0x49e64b in AI::runLoop() ai.cc:56
    #16 0x4362ce in main main.cc:20
    #17 0x7ffcbdb29ec4 in __libc_start_main libc-start.c:287
    #18 0x4360ec in _start ??:?
Address 0x7fff84351534 is located in stack of thread T0 at offset 52 in frame
    #0 0x45c39f in void evalRensaHandWidthFeature<NormalScoreCollector>(NormalScoreCollector*, RefPlan const&, RensaTrackResult const&) evaluator_inl.h:370
  This frame has 3 object(s):
    [32, 52) 'distanceCount'
    [96, 608) 'distance'
    [640, 1664) 'q'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
Shadow bytes around the buggy address:
  0x100070862250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100070862260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100070862270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100070862280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100070862290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1000708622a0: f1 f1 f1 f1 00 00[04]f4 f2 f2 f2 f2 00 00 00 00
  0x1000708622b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000708622c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000708622d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000708622e0: 00 00 00 00 00 00 00 00 00 00 00 00 f2 f2 f2 f2
  0x1000708622f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==5818==ABORTING

CoreField::vanish fails DCHECK() on ちぎり

Use an AI which inherits core/cilent/ai.h, and wait that it puts Puyos on ちぎり statement.

$ cat cpu/peria/peria.err
F1008 02:42:48.687206  6568 core_field.cc:341] Check failed: color(x, y) != PuyoColor::EMPTY 1 1
# # # # # # # #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
# Y R         #
#   Y Y R R   #
# # # # # # # #
  2 2 1 1 1 0
*** Check failure stack trace: ***
    @     0x7f58535521bd  google::LogMessage::Fail()
    @     0x7f585355494f  google::LogMessage::SendToLog()
    @     0x7f5853551dbb  google::LogMessage::Flush()
    @     0x7f58535551dd  google::LogMessageFatal::~LogMessageFatal()
    @           0x456068  CoreField::vanish<>()
    @           0x4560e4  CoreField::simulateWithTracker<>()
    @           0x454a8d  CoreField::simulate()
    @           0x44761b  AI::runLoop()
    @           0x433d7d  main
    @     0x7f5852576ec5  (unknown)
    @           0x43393d  (unknown)

Make PuyoColor enum class

PuyoColor is now enum, and sometimes char and string are abused to represent PuyoColor.
I'd like to make PuyoColor enum class so that we don't make mistakes.

Invalid access of ACCUMULATED_RENSA_SCORE in cpu/mayah/gazer.cc

newTotalChains or it->chains can be negative or greater than 19.

==27371==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000051f9f0 at pc 0x4e1e6c bp 0x7fff95385d60 sp 0x7fff95385d58
READ of size 4 at 0x00000051f9f0 thread T0
==27371==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
    #0 0x4e1e6b in Gazer::estimateMaxScore(int) const /usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/gazer.cc:170
    #1 0x4899c2 in MayahAI::makeMessageFrom(int, CoreField const&, KumipuyoSeq const&, int, Plan const&, double) const /usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/mayah_ai.cc:154
    #2 0x48765d in MayahAI::think(int, PlainField const&, KumipuyoSeq const&) /usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/mayah_ai.cc:68
    #3 0x4f610d in AI::runLoop() /usr/local/google/home/peria/github/puyo/ai/src/core/client/ai/ai.cc:100
    #4 0x4853bf in main /usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/main.cc:20
    #5 0x7fd39a85eec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287
    #6 0x48517c in _start ??:?

0x00000051f9f0 is located 48 bytes to the left of global variable 'typeinfo name for Gazer::updatePossibleRensas(CoreField const&, KumipuyoSeq const&)::$_0' from '/usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/gazer.cc' (0x51fa20) of size 64
  'typeinfo name for Gazer::updatePossibleRensas(CoreField const&, KumipuyoSeq const&)::$_0' is ascii string 'ZN5Gazer20updatePossibleRensasERK9CoreFieldRK11KumipuyoSeqE3$_0'
0x00000051f9f0 is located 0 bytes to the right of global variable 'ACCUMULATED_RENSA_SCORE' from '/usr/local/google/home/peria/github/puyo/ai/src/cpu/mayah/gazer.cc' (0x51f9a0) of size 80
SUMMARY: AddressSanitizer: global-buffer-overflow ??:0 ??

Enable C++14 features

やることリスト

  • どの辺のコンパイラ (バージョン, OS) をサポートするか設定する
    • 基本的に新しいのを優先するけど、dev モード前提みたいなのは辛い
  • CMakeLists.txt の update がどの程度必要か確認&変更する
    • 既存のコードの regression や build 状況などを確認&必要なら変更する

cpu/mayah triggers a DCHECK_NE()

$ cat cpu/mayah/run.err
num_threads = 1
F1016 00:50:39.662709 27762 core_field.cc:261] Check failed: c != PuyoColor::EMPTY (0 vs. 0) # # # # # # # #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
#             #
# # # # # # # #
  0 0 0 0 0 0
*** Check failure stack trace: ***
    @     0x7fa8510d61bd  google::LogMessage::Fail()
    @     0x7fa8510d894f  google::LogMessage::SendToLog()
    @     0x7fa8510d5dbb  google::LogMessage::Flush()
    @     0x7fa8510d91dd  google::LogMessageFatal::~LogMessageFatal()
    @           0x4bc233  CoreField::dropPuyoOn()
    @           0x4bb9ee  CoreField::dropKumipuyo()
    @           0x4a36a1  iterateAvailablePlansInternal()
    @           0x4a3033  Plan::iterateAvailablePlans()
    @           0x4a4516  RensaDetector::findFeasibleRensas()
    @           0x4986e3  Gazer::updateFeasibleRensas()
    @           0x498469  Gazer::gaze()
    @           0x4b5fe6  AI::enemyNext2Appeared()
    @           0x4b074d  AI::runLoop()
    @           0x43880b  main
    @     0x7fa8500faec5  (unknown)
    @           0x43836d  (unknown)

DCHECK failure

How to repro

$ ./duel/duel cpu/mayah/run.sh cpu/peria/run.sh

Error output follows

$  asan_symbolize < cpu/mayah/run.err| c++filt
F0730 09:47:46.314602 28754 puyo_set.h:71] Check failed: m_red + n < 16
*** Check failure stack trace: ***
    @     0x7f309886c1bd  google::LogMessage::Fail()
    @     0x7f309886e94f  google::LogMessage::SendToLog()
    @     0x7f309886bdbb  google::LogMessage::Flush()
    @     0x7f309886f1dd  google::LogMessageFatal::~LogMessageFatal()
    @           0x48b9c4  PuyoSet::add()
    @           0x49d2fb  PuyoSet::add()
    @           0x48af46  std::_Function_handler<>::_M_invoke()
    @           0x49bca6  _ZNSt17_Function_handlerIFvP9CoreFieldRK14ColumnPuyoListEZL26findPossibleRensasInternalISt8functionIFvRKS0_RK11RensaResultS4_S4_EEEvS9_S4_iiN13RensaDetector4ModeET_EUlS1_S4_E_E9_M_invokeERKSt9_Any_dataS1_S4_
    @           0x4974ae  findRensas()
    @           0x494e0b  findPossibleRensasInternal<>()
    @           0x495248  findPossibleRensasInternal<>()
    @           0x495248  findPossibleRensasInternal<>()
    @           0x495248  findPossibleRensasInternal<>()
    @           0x494b3c  RensaDetector::iteratePossibleRensas()
    @           0x489adc  Gazer::updatePossibleRensas()
    @           0x43b8fb  MayahAI::enemyNext2Appeared()
    @           0x49e99e  AI::runLoop()
    @           0x4362cf  main
    @     0x7f3097890ec5  (unknown)
    @           0x4360ed  (unknown)

build on Visual Studio 2015

I'm not sure how many people want to develop on Visual Studio 2013. However, if we can invite more developers, we should have such option.

cpu/test_lockit/ cannot be built with -Werror

cpu/test_lockit/ 以下のコードは Debug ビルド(コンパイルオプションに -Werror が入った状態) ではコンパイルできない感じになっているので warning を取り除かないといけない。

cpu/mayah fails

In Evaluator<ScoreCollector>::evalBook() in cpu/mayah/evaluator.cc,
AI failed with that ratio was NaN. I guess It means that totalPuyoCount can be 0.

$ cat cpu/mayah/run.err
F1011 15:22:37.143506  8531 evaluator.cc:81] Check failed: 0 <= ratio && ratio <= 1.0 -nan
*** Check failure stack trace: ***
    @     0x7ffa88c1a1bd  google::LogMessage::Fail()
    @     0x7ffa88c1c94f  google::LogMessage::SendToLog()
    @     0x7ffa88c19dbb  google::LogMessage::Flush()
    @     0x7ffa88c1d1dd  google::LogMessageFatal::~LogMessageFatal()
    @           0x457335  Evaluator<>::evalBook()
    @           0x455578  Evaluator<>::collectScore()
    @           0x43d76a  MayahAI::eval()
    @           0x43edd7  std::_Function_handler<>::_M_invoke()
    @           0x499b6b  iterateAvailablePlansInternal()
    @           0x499d19  iterateAvailablePlansInternal()
    @           0x499153  Plan::iterateAvailablePlans()
    @           0x43a0be  MayahAI::thinkPlan()
    @           0x4392b3  MayahAI::think()
    @           0x4a68e3  AI::runLoop()
    @           0x4375c3  main
    @     0x7ffa87c3eec5  (unknown)
    @           0x4373ad  (unknown)

BugReport: cpu/hamaji fails with stack buffer overflow

How to see

  1. Build with bin/build script.
  2. Edit build/cpu/hamaji/run.sh to record its stderr output
  3. $ ./duel/duel --realtime=false cpu/hamaji/run.sh cpu/sample/sample
  4. Duel stops with error outputs.
  5. $ /usr/bin/asan_symbolize / < run.err | c++filt

Log output

=================================================================
==27169==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5f06235b at pc 0x4541b7 bp 0x7fff5f0621f0 sp 0x7fff5f0621e8
WRITE of size 1 at 0x7fff5f06235b thread T0
    #0 0x4541b6 in LF::getBestChainCount(int*, int*, int*) const field.cc:649
    #1 0x4405e6 in Eval::fillEvalParamVector(LF const&, std::vector<double, std::allocator<double> >*, int*) eval.cc:246
    #2 0x440e16 in Eval::eval(LP*) eval.cc:288
    #3 0x43a31b in Core::decide(Game*) core.cc:232
    #4 0x434214 in tick(Game*) main.cc:75
    #5 0x4357fb in letsPuyoShobu() main.cc:163
    #6 0x436bc3 in main main.cc:196
    #7 0x7fe4b9184ec4 in __libc_start_main libc-start.c:287
    #8 0x43375c in _start ??:?
Address 0x7fff5f06235b is located in stack of thread T0 at offset 123 in frame
    #0 0x45245f in LF::getBestChainCount(int*, int*, int*) const field.cc:590
  This frame has 5 object(s):
    [32, 123) 'has_checked'
    [160, 296) 'nf'
    [352, 356) 'chain'
    [416, 420) 'score'
    [480, 484) 'frame'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
Shadow bytes around the buggy address:
  0x10006be04410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be04420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be04430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be04440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be04450: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
=>0x10006be04460: 00 00 00 00 00 00 00 00 00 00 00[03]f2 f2 f2 f2
  0x10006be04470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be04480: 00 f4 f4 f4 f2 f2 f2 f2 04 f4 f4 f4 f2 f2 f2 f2
  0x10006be04490: 04 f4 f4 f4 f2 f2 f2 f2 04 f4 f4 f4 f3 f3 f3 f3
  0x10006be044a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006be044b0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f4 f4 f4
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==27169==ABORTING

Build broken

I'm not sure what is the critical point, but it is sure that I cannot build programs after Munetoshi's commit 851fea9083f4042d62a3208f10aeb89697a8791e.
Could you check it, Munetoshi?

-- Configuring done
-- Generating done
-- Build files have been written to: /home/peria/github/puyo/ai/build
[6/155] Building CXX object core/CMakeFiles/puyoai_core.dir/field_pretty_printer.cc.o
FAILED: /usr/bin/clang++    -DDATA_DIR=\"/home/peria/github/puyo/ai/src/../data\" -DTESTDATA_DIR=\"/home/peria/github/puyo/ai/src/../testdata\" -DSRC_DIR=\"/home/peria/github/puyo/ai/src\" -Wno-error=sign-compare -Wno-error=missing-field-initializers -Wno-error=deprecated-declarations -Wall -Wextra -std=c++11 -std=c++11 -Werror -Wall -Wextra -Wno-error=unused-variable -Wno-error=unused-parameter -Wno-error=missing-field-initializers -fsanitize=address -O2 -g -I/home/peria/github/puyo/ai/src/. -I/home/peria/github/puyo/ai/src/third_party/gtest-1.7.0/include -I/home/peria/github/puyo/ai/src/third_party/gtest-1.7.0 -I/home/peria/github/puyo/ai/src/third_party/jsoncpp -I/home/peria/github/puyo/ai/src/third_party/tinytoml/include -I/usr/local/include -MMD -MT core/CMakeFiles/puyoai_core.dir/field_pretty_printer.cc.o -MF "core/CMakeFiles/puyoai_core.dir/field_pretty_printer.cc.o.d" -o core/CMakeFiles/puyoai_core.dir/field_pretty_printer.cc.o -c /home/peria/github/puyo/ai/src/core/field_pretty_printer.cc
In file included from /home/peria/github/puyo/ai/src/core/field_pretty_printer.cc:1:
In file included from /home/peria/github/puyo/ai/src/./core/field_pretty_printer.h:5:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/string:41:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/allocator.h:46:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h:33:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:93:7: error: multiple overloads of 'address' instantiate to the same signature 'const_pointer (const_reference) const noexcept'
      address(const_reference __x) const _GLIBCXX_NOEXCEPT
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/allocator.h:92:29: note: in instantiation of template class '__gnu_cxx::new_allocator<const Position>' requested here
    class allocator: public __allocator_base<_Tp>
                            ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/alloc_traits.h:90:24: note: in instantiation of template class 'std::allocator<const Position>' requested here
      typedef typename _Alloc::value_type value_type;
                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/alloc_traits.h:123:5: note: in instantiation of template class 'std::allocator_traits<std::allocator<const Position> >' requested here
  : std::allocator_traits<_Alloc>
    ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:74:35: note: in instantiation of template class '__gnu_cxx::__alloc_traits<std::allocator<const Position> >' requested here
      typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
                                  ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:210:30: note: in instantiation of template class 'std::_Vector_base<const Position, std::allocator<const Position> >' requested here
    class vector : protected _Vector_base<_Tp, _Alloc>
                             ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:161:9: note: in instantiation of template class 'std::vector<const Position, std::allocator<const Position> >' requested here
                      - this->_M_impl._M_start); }
                      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:248:7: note: in instantiation of member function 'std::_Vector_base<std::vector<const Position, std::allocator<const Position> >, std::allocator<std::vector<const Position, std::allocator<const Position> > > >::~_Vector_base' requested here
      vector()
      ^
/home/peria/github/puyo/ai/src/./core/rensa_result.h:78:2: note: in instantiation of member function 'std::vector<std::vector<const Position, std::allocator<const Position> >, std::allocator<std::vector<const Position, std::allocator<const Position> > > >::vector' requested here
        RensaVanishingPositionResult() {
        ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:89:7: note: previous declaration is here
      address(reference __x) const _GLIBCXX_NOEXCEPT
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:110:9: error: no matching function for call to 'operator delete'
      { ::operator delete(__p); }
        ^~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:174:12: note: in instantiation of member function '__gnu_cxx::new_allocator<const Position>::deallocate' requested here
          _M_impl.deallocate(__p, __n);
                  ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:160:9: note: in instantiation of member function 'std::_Vector_base<const Position, std::allocator<const Position> >::_M_deallocate' requested here
      { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
        ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:414:7: note: in instantiation of member function 'std::_Vector_base<const Position, std::allocator<const Position> >::~_Vector_base' requested here
      ~vector() _GLIBCXX_NOEXCEPT
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_construct.h:93:19: note: in instantiation of member function 'std::vector<const Position, std::allocator<const Position> >::~vector' requested here
    { __pointer->~_Tp(); }
                  ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_construct.h:103:11: note: in instantiation of function template specialization 'std::_Destroy<std::vector<const Position, std::allocator<const Position> > >' requested here
            std::_Destroy(std::__addressof(*__first));
                 ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_construct.h:127:2: note: in instantiation of function template specialization 'std::_Destroy_aux<false>::__destroy<std::vector<const Position, std::allocator<const Position> > *>' requested here
        __destroy(__first, __last);
        ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_construct.h:151:7: note: in instantiation of function template specialization 'std::_Destroy<std::vector<const Position, std::allocator<const Position> > *>' requested here
      _Destroy(__first, __last);
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:415:14: note: in instantiation of function template specialization 'std::_Destroy<std::vector<const Position, std::allocator<const Position> > *, std::vector<const Position, std::allocator<const Position> > >' requested here
      { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
             ^
/home/peria/github/puyo/ai/src/./core/rensa_result.h:78:2: note: in instantiation of member function 'std::vector<std::vector<const Position, std::allocator<const Position> >, std::allocator<std::vector<const Position, std::allocator<const Position> > > >::~vector' requested here
        RensaVanishingPositionResult() {
        ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/new:95:6: note: candidate function not viable: no known conversion from 'pointer' (aka 'const Position *') to 'void *' for 1st argument; take the address of the argument with &
void operator delete(void*) _GLIBCXX_USE_NOEXCEPT
     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/new:103:6: note: candidate function not viable: requires 2 arguments, but 1 was provided
void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/new:115:13: note: candidate function not viable: requires 2 arguments, but 1 was provided
inline void operator delete  (void*, void*) _GLIBCXX_USE_NOEXCEPT { }
            ^

Consider removing deprecated/

I believe cpu/hamaji has some useful toolchains. Can't we move them to src/ ?
After that, we can remove deprecated/.

FieldRealTimeTest does not pass 2 tests

  • Repro Step
$ cmake .
$ make
$ ./duel/field_realtime_test
  • Expected
    Pass all tests
  • Actual
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 1
Expected: states[i]
Which is: 5
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 5
Expected: states[i]
Which is: 1
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 2
Expected: states[i]
Which is: 5
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 5
Expected: states[i]
Which is: 2
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 0
Expected: states[i]
Which is: 5
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 0
Expected: states[i]
Which is: 5
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 0
Expected: states[i]
Which is: 5
/puyoai/duel/field_realtime_test.cc:60: Failure
Value of: f_->GetSimulationState()
  Actual: 0
Expected: states[i]
Which is: 5
[  FAILED  ] FieldRealtimeTest.TimingFreeFall (2 ms)
[ RUN      ] FieldRealtimeTest.TimingChigiri
/puyoai/duel/field_realtime_test.cc:77: Failure
Value of: f_->GetSimulationState()
  Actual: 1
Expected: FieldRealtime::STATE_SLEEP
Which is: 5
/puyoai/duel/field_realtime_test.cc:82: Failure
Value of: f_->GetSimulationState()
  Actual: 5
Expected: FieldRealtime::STATE_CHIGIRI
Which is: 1
/puyoai/duel/field_realtime_test.cc:86: Failure
Value of: f_->GetSimulationState()
  Actual: 5
Expected: FieldRealtime::STATE_VANISH
Which is: 2
/puyoai/duel/field_realtime_test.cc:89: Failure
Value of: f_->GetSimulationState()
  Actual: 2
Expected: FieldRealtime::STATE_SLEEP
Which is: 5
/puyoai/duel/field_realtime_test.cc:92: Failure
Value of: f_->GetSimulationState()
  Actual: 5
Expected: FieldRealtime::STATE_USER
Which is: 0
[  FAILED  ] FieldRealtimeTest.TimingChigiri (0 ms)
[----------] 3 tests from FieldRealtimeTest (2 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (2 ms total)
[  PASSED  ] 1 test.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] FieldRealtimeTest.TimingFreeFall
[  FAILED  ] FieldRealtimeTest.TimingChigiri

Consider 60fps

Currently, duel server and wii server are working in 30 fps. However, puyopuyo is definitely 60 fps. We have chosen 30 fps due to video capture limitation. It is not the limitation now.

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.