def testWinsForVerticalTrue(self): b = hw.Board(7,6) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) self.assertTrue(b.winsFor('X'),'** INCORRECT ** b does win for X')
def testIsFullTrue(self): b = hw.Board(2,2) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) b.addMove( 1, 'X' ) b.addMove( 1, 'X' ) self.assertTrue(b.isFull(),'** INCORRECT ** b actually is full')
def testWinsForHorizontalTrue(self): b = hw.Board(7,6) b.addMove( 0, 'X' ) b.addMove( 1, 'X' ) b.addMove( 2, 'X' ) b.addMove( 3, 'X' ) self.assertTrue(b.winsFor('X'),'** INCORRECT ** b does win for X')
def testTieBreakMove2(self): b = hw.Board(7, 6) p = hw.Player('X', 'LEFT', 0) p2 = hw.Player('O', 'RIGHT', 1) scores = [0, 100, 0, 0, 0, 100, 0] self.assertEqual(p2.tiebreakMove(scores), 5, '** INCORRECT ** p2 should tiebreak in column 5')
def testIsFullFalse(self): b = hw.Board(2,2) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) b.addMove( 1, 'X' ) b.addMove( 1, 'X' ) b.delMove(1) self.assertFalse(b.isFull(),'** INCORRECT ** b actually is not full')
def testScoreBoard1(self): b = hw.Board(7,6) p = hw.Player( 'X', 'LEFT', 0 ) p2 = hw.Player( 'O', 'RIGHT', 1 ) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) b.addMove( 0, 'X' ) self.assertEqual(p.scoreBoard(b), 50.0,'** INCORRECT ** b should score a 50.0 for X')
def testWinsForDiagonalSEFalse(self): b = hw.Board(7,6) b.addMove( 6, 'X' ) b.addMove( 5, 'O' ) b.addMove( 5, 'X' ) b.addMove( 4, 'O' ) b.addMove( 4, 'X' ) b.addMove( 4, 'X' ) b.addMove( 3, 'X' ) b.addMove( 3, 'O' ) b.addMove( 3, 'X' ) self.assertFalse(b.winsFor('X'),'** INCORRECT ** b does not win for X')
def testWinsForDiagonalSETrue(self): print "\n\nTEST 8" b = hw.Board(7,6) b.addMove( 6, 'X' ) b.addMove( 5, 'O' ) b.addMove( 5, 'X' ) b.addMove( 4, 'O' ) b.addMove( 4, 'X' ) b.addMove( 4, 'X' ) b.addMove( 3, 'X' ) b.addMove( 3, 'O' ) b.addMove( 3, 'X' ) b.addMove( 3, 'X' ) self.assertTrue(b.winsFor('X'),'** INCORRECT ** b does win for X')
def testScoresFor5(self): b = hw.Board(7,6) b = setupBoard( b, '1211244445' ) answer = hw.Player('O', 'LEFT', 4).scoresFor(b) self.assertEqual(answer, [0.0, 0.0, 0.0, 100.0, 0.0, 0.0, 0.0],'** INCORRECT ** 4 ply scoring test')
def testScoresFor1(self): b = hw.Board(7,6) b = setupBoard( b, '1211244445' ) answer = hw.Player('X', 'LEFT', 0).scoresFor(b) self.assertEqual(answer, [50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0],'** INCORRECT ** 0 ply scoring test')
def testOppCh(self): b = hw.Board(7,6) p = hw.Player( 'X', 'LEFT', 0 ) p2 = hw.Player( 'O', 'RIGHT', 1 ) self.assertEqual(p.oppCh(),'O', '** INCORRECT ** p\'s opponent is not \'O\'')