일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Splunk
- Python
- pip
- synology
- DFS
- E-P1
- Series
- index
- keras
- SciPy
- CNN
- pandas
- 알고리즘
- Numpy
- Lotto
- javascript
- 삼성소프트웨어멤버십
- GitHub
- pycharm
- Button
- mariadb
- dataframe
- LSTM
- mean
- imread
- ipad
- SPL
- RNN
- install
- GT-S80
Archives
- Today
- Total
잠토의 잠망경
[딥러닝과 바둑] 틱택토 본문
main source
from dlgo.ttt.ttttypes import Point
from dlgo.ttt.ttttypes import Player
from dlgo.ttt.tttboard import GameState
from dlgo.ttt.tttboard import Move
from dlgo.minmax.minmax import MinMaxAgent
from six.moves import input
COL_NAMES = 'ABC'
def print_board(board)->None:
print(' A B C')
for row in (1, 2, 3):
pieces = []
for col in (1, 2, 3):
piece = board.get(Point(row, col))
if piece == Player.x:
pieces.append('X')
elif piece == Player.o:
pieces.append('O')
else:
pieces.append(' ')
print('%d %s' % (row, ' | '.join(pieces)))
def point_from_coords(text):
col_name = text[0]
row = int(text[1])
return Point(row, COL_NAMES.index(col_name) + 1)
def main():
game:GameState = GameState.new_game()
human_player = Player.x
bot = MinMaxAgent()
while(not game.is_over()):
print_board(game.board)
if(game.next_player == human_player):
human_move = input('-- ')
point:Point = point_from_coords(human_move.strip())
move = Move(point)
else:
move:Move = bot.select_move(game)
game:GameState = game.apply_move(move)
print_board(game.board)
winner = game.winner()
if winner is None:
print("비김")
else:
print('winner: {0}'.format(winner))
pass
if __name__ == '__main__':
main()
실행 결과
Comments