0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

オストル のゲームAIを作る第一回

Posted at

オストルのゲームAIを作りはじめました。
コンソールに初期配置を表示するところまで出来ました。

ostle.py
# -*- coding: utf-8 -*-
from __future__ import print_function

SPACE = 0
WHITE = 1
BLACK = 2
HOLE = 3

class OstleBoard(object):
    def __init__(self):
        # 初期配置
        # 2次元リストを生成する
        self.cells = [[WHITE, WHITE, WHITE, WHITE, WHITE],
        [SPACE, SPACE, SPACE, SPACE, SPACE],
        [SPACE, SPACE, HOLE, SPACE, SPACE],
        [SPACE, SPACE, SPACE, SPACE, SPACE],
        [BLACK, BLACK, BLACK, BLACK, BLACK]]

    def show_board(self):
        """ボードを表示する"""
        print("--" * 20)
        for i in self.cells:
            for cell in i:
                if cell == WHITE:
                    print('W',end='')
                elif cell == BLACK:
                    print('B',end='')
                elif cell == HOLE:
                    print('H',end='')
                else:
                    print('*',end='')
            print("\n")

def main():
    board = OstleBoard()
    board.show_board()

if __name__ == '__main__':
    main()
output.txt
----------------------------------------
WWWWW

*****

**H**

*****

BBBBB
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?