def setUp(self): self.bc = BoardCleaner() self.cards = [Card(color, num) for num in range(1, 10) \ for color in range(3)] self.cards += [Card(color, None) for color in range(3, 6) \ for i in range(4)] self.cards += [Card(6, None)]
def setUp(self): self.sol = Solitaire() self.cards = [Card(color, num) for num in range(1, 10) \ for color in range(3)] self.cards += [Card(color, None) for color in range(3, 6) \ for i in range(4)] self.cards += [Card(6, None)]
def _testNextMove2(self): cards = [Card(color, num) for color in range(3) \ for num in range(9, 0, -1)] cards += [Card(color, None) for color in range(3, 6) \ for i in range(4)] cards += [Card(6, None)] game = Board(copy(cards)) print game for move in self.sol.nextMove(game): print move
def testTableauToTableau(self): cards = [Card(color, num) for color in range(3) \ for num in range(9, 0, -1)] cards += [Card(color, None) for color in range(3, 6) \ for i in range(4)] cards += [Card(6, None)] game = Board(cards) topTabToTab, lowTabToTab, toEmpty = self.sol.__getTableauToTableau__( game) self.assertEqual(len(topTabToTab), 5) self.assertEqual(len(lowTabToTab), 6) self.assertEqual(len(toEmpty), 0)
def recognize_card(self, im): """ recognize a card with its image """ src = np.array(list(im.getdata())) typ = self.__recognize_card_type__(src) if typ and typ < 10: color = self.__recognize_card_color__(src) return Card(color, typ) elif typ: return Card(typ - 7, None) else: return None
def setUp(self): cards = [Card(color, i) for color in range(3) for i in range(1, 10)] cards += [Card(color, None) for color in range(3, 6) for i in range(4)] cards.append(Card(6, None)) game = Board(cards) game.stock[0] = game.tableau[-1].pop() game.stock[1] = game.tableau[-2].pop() game.stock[2] = game.tableau[-3].pop() for i in range(3): game.foundation[i] += 1 print game.foundation.color_map self.board = game self.ctrl = GUIController()
def _testNextMoveFinishing(self): game = Board() game.stock = [[], None, []] game.tableau = [[Card(0, 9)], [Card(5, None), Card(2, 7), Card(2, 8)], [Card(5, None)], [Card(5, None)], [], [], [Card(2, 9)], [Card(5, None)]] game.foundation = {0: 8, 1: 9, 2: 6} print game for move in self.sol.nextMove(game): print move
def _testNextMoveFinishing4(self): game = Board() game.stock = [[], [], []] game.tableau = [[Card(1, 5), Card(1, 7)], [Card(0, 9), Card(1, 8), Card(2, 7), Card(1, 6)], [], [Card(1, 9), Card(2, 8), Card(0, 7), Card(1, 6)], [Card(2, 9), Card(0, 8)], [], [], []] game.foundation = {0: 6, 1: 4, 2: 5} print game for move in self.sol.nextMove(game): print move
def _testNextMoveFinishing3(self): game = Board() game.stock = [[], [], []] game.tableau = [[], [Card(0, 9), Card(0, 7)], [Card(2, 3), Card(1, 6)], [Card(2, 5), Card(0, 4)], [], [ Card(2, 9), Card(0, 8), Card(2, 7), Card(0, 6), Card(1, 5), Card(2, 4) ], [Card(1, 8)], [ Card(1, 9), Card(2, 8), Card(1, 7), Card(2, 6), Card(0, 5), Card(1, 4) ]] game.foundation = {0: 3, 1: 3, 2: 2} print game for move in self.sol.nextMove(game): print move
def _testNextMoveFinishing2(self): game = Board() game.stock = [None, [], []] game.tableau = [[ Card(1, 9), Card(3, None), Card(0, 9), Card(1, 8), Card(2, 7) ], [Card(3, None)], [Card(3, None)], [], [Card(2, 5), Card(2, 8)], [], [Card(3, None)], [Card(2, 9), Card(0, 8), Card(1, 7), Card(2, 6)]] game.foundation = {0: 7, 1: 6, 2: 4} print game for move in self.sol.nextMove(game): print move
from Board import Card testCases = [ [[Card(2, 8), Card(2, 6), Card(0, 9), Card(0, 4), Card(3, None)], [Card(1, 6), Card(1, 9), Card(1, 1), Card(2, 2), Card(2, 9)], [Card(0, 7), Card(5, None), Card(5, None), Card(1, 7), Card(1, 5)], [Card(3, None), Card(1, 8), Card(1, 3), Card(4, None), Card(0, 5)], [Card(5, None), Card(4, None), Card(4, None), Card(2, 5), Card(0, 3)], [Card(6, None), Card(5, None), Card(2, 3), Card(4, None), Card(1, 4)], [Card(0, 2),
def testToString(self): for color in range(3): for number in range(1, 10): print Card(color, number).toString(True) for color in range(3, 7): print Card(color, None).toString(True)
def setUp(self): cards = [Card(color, i) for color in range(3) for i in range(1, 10)] cards += [Card(color, None) for color in range(3, 6) for i in range(4)] cards.append( Card(6, None) ) shuffle( cards ) self.board = Board(cards)
def testInit(self): board = self.parser.parse_screenshot('tests/init.png') self.asw.tableau = [ [Card(3, None), Card(1, 3), Card(0, 4), Card(2, 3), Card(1, 6)], [Card(1, 9), Card(5, None), Card(0, 2), Card(2, 9), Card(5, None)], [Card(0, 6), Card(3, None), Card(1, 5), Card(1, 7), Card(4, None)], [Card(2, 6), Card(1, 4), Card(6, None), Card(2, 4), Card(2, 7)], [Card(4, None), Card(4, None), Card(0, 5), Card(2, 2), Card(0, 8)], [ Card(5, None), Card(4, None), Card(3, None), Card(2, 1), Card(0, 3) ], [Card(5, None), Card(1, 1), Card(0, 1), Card(0, 9), Card(0, 7)], [Card(3, None), Card(2, 8), Card(2, 5), Card(1, 8), Card(1, 2)] ] self.assertEqual(board, self.asw)