Ejemplo n.º 1
0
 def test_play(self):
     """ test play """
     game = Pentago()
     game.play(3, 0, 0, 1)
     self.assertEqual(game.getpoint(3, 0), game.WHITE)
     game.play(4, 1, 1, 0)
     self.assertEqual(game.getpoint(3, 0), game.VOID)
     self.assertEqual(game.getpoint(5, 0), game.WHITE)
     self.assertEqual(game.getpoint(4, 1), game.BLACK)
Ejemplo n.º 2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Entry point
"""

from pentago import Pentago


def get_play_cmd():
    """ get user cmd """
    try:
        print("x[0, 5]\ny[0, 5]\nquad[0, 3]\nsens[0, 1]")
        dat = tuple([int(input()) for _ in range(4)])
        assert 0 <= dat[0] <= 5
        assert 0 <= dat[1] <= 5
        assert 0 <= dat[2] <= 3
        assert 0 <= dat[3] <= 1
        print("x={} y={} quad={} sens={}".format(*dat))
        return dat
    except:
        print("Error entry")


if __name__ == '__main__':
    game = Pentago()
    print(game)
    while game.run:
        game.play(*get_play_cmd())
        print(game)