Changeset 336
- Timestamp:
- 11/12/11 19:54:07 (6 months ago)
- Files:
-
- Checkers/src/GameBoard.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Checkers/src/GameBoard.py
r334 r336 14 14 ABS_BOTTOM_RIGHT = 7 15 15 NOCAP_DRAW_TURNS = 40 16 17 DIRECTIONS = [FORWARD_LEFT, FORWARD_RIGHT, BACKWARD_LEFT, BACKWARD_RIGHT] 16 18 17 19 def __init__( self ): … … 92 94 # indicate player one victory 93 95 # and quit 94 print "Player 1 WON!"96 print("Player 1 WON!") 95 97 self.resign() 96 98 elif victor == GameBoard.PLAYER_TWO: 97 99 # indicate player two victory 98 100 # and quit 99 print "Player 2 WON!"101 print ("Player 2 WON!") 100 102 self.resign() 101 103 elif victor == -1: 102 104 # Indicate draw and quit. 103 print "Game is a draw!"105 print ("Game is a draw!") 104 106 self.resign() 105 107 else: … … 327 329 def get_pieces( self ): 328 330 ''' 329 Gets a 2D list of all the pieces on the gameboard 330 Unclear for now 331 @return list - a 2D list of all the pieces on the gameboard 331 Gets a 1D list of all the pieces on the gameboard 332 @return list - a 1D list of all the pieces on the gameboard 332 333 ''' 333 334 pieces = [] … … 336 337 if self.board[x][y] != None: 337 338 pieces.append(self.board[x][y]) 339 return pieces 340 341 342 def get_pieces_for_player(self, player): 343 ''' 344 Gets a 1D list of all the pieces for the given player 345 @return list - a 1D list of all the pieces on the gameboard for the given player 346 ''' 347 pieces = [] 348 for row in range(len(self.board)): 349 for col in range(len(self.board[row])): 350 if self.board[row][col] != None and (self.board[row][col]).player == player: 351 pieces.append(self.board[row][col]) 338 352 return pieces 339 353 … … 599 613 if print_rows%2 == 0: 600 614 if print_columns%2 == 0: 601 print ' +',615 print (' +'), 602 616 else: 603 print ' -',617 print (' -'), 604 618 else: 605 619 if print_columns%2 == 0: 606 620 if print_columns == 0: 607 print '',608 print '|',621 print (''), 622 print ('|'), 609 623 else: 610 624 y = (print_rows-1)/2 … … 612 626 piece = self.board[x][y] 613 627 if piece == None: 614 print ' ',628 print (' '), 615 629 continue 616 if piece.player == GameBoard.PLAYER_ONE: 617 print GREEN, 630 print (''), 631 if piece.is_king: 632 print ('K'), 618 633 else: 619 print BLUE,620 if piece.is_king:621 print 'K',622 else:623 print 'O',624 print ENDC,625 print ' '# new line634 if piece.player == GameBoard.PLAYER_ONE: 635 print ('G'), 636 else: 637 print ('B'), 638 # print ('O'), 639 print (ENDC), 640 print (' ') # new line 626 641 # end print_board
