def __init__(self): super(HiveShellClient, self).__init__() self.hive = Hive() self.view = HiveView(self.hive) self.input = sys.stdin self.player = {1: None, 2: None} self.logger = None
def setUp(self): # / \ / \ / \ / \ / \ # |wB1|wS2| |bB1| | # / \ / \ / \ / \ / \ / # |wG1| |wS1|bS1|bG1| # \ / \ / \ / \ / \ / \ # | |wQ1| |bQ1| | # / \ / \ / \ / \ / \ / # | | | |bA1| | # \ / \ / \ / \ / \ / # next is black player turn self.hive = Hive() self.hive.setup() self.hive.action('play', ('wS1')) self.hive.action('play', ('bS1', 'wS1', self.hive.E)) self.hive.action('play', ('wQ1', 'wS1', self.hive.SW)) self.hive.action('play', ('bQ1', 'bS1', self.hive.SE)) self.hive.action('play', ('wS2', 'wS1', self.hive.NW)) self.hive.action('play', ('bG1', 'bS1', self.hive.E)) self.hive.action('play', ('wB1', 'wS2', self.hive.W)) self.hive.action('play', ('bA1', 'bQ1', self.hive.SW)) self.hive.action('play', ('wG1', 'wB1', self.hive.SW)) self.hive.place_piece(self.piece['bB1'], 'bS1', self.hive.NE)
def test_first_move(self): """Test that we can move a piece on the 3rd turn wA1, bA1/*wA1, wG1*|wA1, bS1/*bA1, wQ1\*wA1, bA2*\\bA1, wG1|*wA1 """ hive = Hive() hive.setup() hive.action('play', ('wA1')) hive.action('play', ('bA1', 'wA1', hive.NW)) hive.action('play', ('wG1', 'wA1', hive.E)) hive.action('play', ('bS1', 'bA1', hive.NW)) hive.action('play', ('wQ1', 'wA1', hive.SW)) hive.action('play', ('bA2', 'bA1', hive.NE)) hive.action('play', ('wG1', 'wA1', hive.W))
def test_fail_placement(self): """Test that we can place a piece after an incorrect try. wA1, bA1/*wA1, wG1|*bA1, wG1*|wA1 """ hive = Hive() hive.setup() hive.action('play', ('wA1')) hive.action('play', ('bA1', 'wA1', hive.NW)) try: # This placement fails hive.action('play', ('wG1', 'bA1', hive.W)) except: pass # This placement is correct hive.action('play', ('wG1', 'wA1', hive.E))
def test_victory_conditions(self): """Test that we end the game when a victory/draw condition is meet.""" hive = Hive() hive.setup() hive.action('play', ('wS1')) hive.action('play', ('bS1', 'wS1', hive.E)) hive.action('play', ('wQ1', 'wS1', hive.NW)) hive.action('play', ('bQ1', 'bS1', hive.NE)) hive.action('play', ('wG1', 'wQ1', hive.W)) hive.action('play', ('bS2', 'bS1', hive.E)) hive.action('play', ('wA1', 'wQ1', hive.NE)) hive.action('play', ('bA1', 'bQ1', hive.E)) hive.action('play', ('wG1', 'wQ1', hive.E)) hive.action('play', ('bG2', 'bQ1', hive.NE)) hive.action('play', ('wA1', 'wG1', hive.NE)) self.assertTrue(hive.check_victory() == hive.WHITE_WIN)