aglab

自動テストプレイ

ゲーム定義ファイルで定義されたゲームの自動テストプレイを行います。

  • このまま実行した場合、使用されるゲーム定義ファイルは"definition/mygame.py"です。
    新たに作成したゲーム定義ファイルをテストしたい場合は下記セル中の"mygame"をすべて書きかえてください。

In [1]:
from definition import janken #mygame #テストしたいゲーム定義ファイルのファイル名
from src import aglab, controller

In [2]:
game = aglab.Game(janken, controller=controller.Randomizer) #Game(mygame, controller=controller.Randomizer)
game.setup() #プレイ前の準備


PROCESS:module.common.set_turn_order 
PROCESS:definition.janken.init_hand 

In [3]:
print game.get_info() #今回のプレイに関する情報を出力する


[じゃんけんカードゲーム]
- Player:1 in 2 players

In [4]:
for i in range(game.max_steps):
    game.step() #ゲームを1ステップ進行する
    if game.act is not None:        
        print game.reward, ', path:', game.get_contextpath()
        print game.output_state() #ゲームの状況を出力する
        observation = game.get_observation(observer=game.player)
        action = game.act.action(observation)
        game.perform_action(action)
    print
    if game.done:
        print game.get_result()
        print game.output_state()
        break #ゲーム終了


STEP: 1 --------------------------------
PROCESS:module.common.turn_start 

STEP: 2 --------------------------------
Reward:[0.0, 0.0] , path: //turn:1/phase:1?turn=1&next=2
P1.h: ['p', 'p', 't', 't', 'g', 'g']
P1.p: [' ', ' ', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', 'g', 'g']
P2.p: [' ', ' ', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:0, player-2:0, player-3:0, player-4:0,

TODO:Observation.to_array()
PROCESS:definition.janken.set_card [{'ckey': 'G'}, 'P{turn_player}.p']

STEP: 3 --------------------------------
Reward:[0.0, 0.0] , path: //turn:1/phase:2?turn=1&next=2
P1.h: ['p', 'p', 't', 't', ' ', 'g']
P1.p: ['g', ' ', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', 'g', 'g']
P2.p: [' ', ' ', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:0, player-2:0, player-3:0, player-4:0,

TODO:Observation.to_array()
PROCESS:definition.janken.set_card [{'ckey': 'G'}, 'P{next_player}.p']

STEP: 4 --------------------------------
PROCESS:definition.janken.judge 
turn-player: G  vs next-player: G
 -> draw

STEP: 5 --------------------------------
PROCESS:module.common.turn_end ['$turn-player']

STEP: 6 --------------------------------
PROCESS:module.common.turn_start 

STEP: 7 --------------------------------
Reward:[0.0, 0.02] , path: //turn:2/phase:1?turn=2&prev=1&next=1
P1.h: ['p', 'p', 't', 't', ' ', 'g']
P1.p: ['G', ' ', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', ' ', 'g']
P2.p: ['G', ' ', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:1, player-2:1, player-3:0, player-4:0,

TODO:Observation.to_array()
PROCESS:definition.janken.set_card [{'ckey': 'G'}, 'P{turn_player}.p']

STEP: 8 --------------------------------
Reward:[0.0, 0.02] , path: //turn:2/phase:2?turn=2&prev=1&next=1
P1.h: ['p', 'p', 't', 't', ' ', 'g']
P1.p: ['G', ' ', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', ' ', ' ']
P2.p: ['G', 'g', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:1, player-2:1, player-3:0, player-4:0,

TODO:Observation.to_array()
PROCESS:definition.janken.set_card [{'ckey': 'G'}, 'P{next_player}.p']

STEP: 9 --------------------------------
PROCESS:definition.janken.judge 
turn-player: G  vs next-player: G
 -> draw

STEP: 10 --------------------------------
PROCESS:module.common.turn_end ['$turn-player']

STEP: 11 --------------------------------
PROCESS:module.common.turn_start 

STEP: 12 --------------------------------
Reward:[0.0, 0.04] , path: //turn:3/phase:1?turn=1&prev=2&next=2
P1.h: ['p', 'p', 't', 't', ' ', ' ']
P1.p: ['G', 'G', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', ' ', ' ']
P2.p: ['G', 'G', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:2, player-2:2, player-3:0, player-4:0,

TODO:Observation.to_array()
PROCESS:definition.janken.set_card [{'ckey': 'G'}, 'P{turn_player}.p']
無効なアクションを実行しようとしました。; "G"のカードは手札にないため出せません。

========================================
[Result]
 step:12

P1.h: ['p', 'p', 't', 't', ' ', ' ']
P1.p: ['G', 'G', ' ', ' ', ' ', ' ']
P2.h: ['p', 'p', 't', 't', ' ', ' ']
P2.p: ['G', 'G', ' ', ' ', ' ', ' ']
P3.h: [' ', ' ', ' ', ' ', ' ', ' ']
P3.p: [' ', ' ', ' ', ' ', ' ', ' ']
P4.h: [' ', ' ', ' ', ' ', ' ', ' ']
P4.p: [' ', ' ', ' ', ' ', ' ', ' ']
[score] player-1:2, player-2:2, player-3:0, player-4:0,


In [5]:
# ゲーム終了時の状態
print game.reward
#print game.state


Reward:[0.0, -0.96]

In [ ]: