本文整理汇总了Python中board.Board._board方法的典型用法代码示例。如果您正苦于以下问题:Python Board._board方法的具体用法?Python Board._board怎么用?Python Board._board使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board._board方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_legal_move_for_pawn
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_pawn(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board2
#White pawn, forward one space from default position
self.assertTrue(b._isLegalMoveForPawn([7, 1, 7, 2], constants.WHITE_PLAYER))
#White pawn, forward two spaces from default position
self.assertTrue(b._isLegalMoveForPawn([7, 1, 7, 3], constants.WHITE_PLAYER))
#Black pawn, forward one space from default position
self.assertTrue(b._isLegalMoveForPawn([6, 6, 6, 5], constants.BLACK_PLAYER))
#Black pawn, forward two spaces from default position
self.assertTrue(b._isLegalMoveForPawn([6, 6, 6, 4], constants.BLACK_PLAYER))
#Black pawn, forward one space from non-default position
self.assertTrue(b._isLegalMoveForPawn([5, 5, 5, 4], constants.BLACK_PLAYER))
b._board = ChessTest.board1
#Legal move to kill
self.assertTrue(b._isLegalMoveForPawn([3, 4, 4, 5], constants.WHITE_PLAYER))
#Legal move to kill 2
self.assertTrue(b._isLegalMoveForPawn([3, 4, 2, 5], constants.WHITE_PLAYER))
示例2: test_is_check_mate
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_check_mate(self):
import board_analyzer
import constants
from board import Board
board1 = Board()
board1._board = ChessTest.checkmate1
board2 = Board()
board2._board = ChessTest.checkmate2
self.assertTrue(board_analyzer.isCheckMate(board1, constants.WHITE_PLAYER))
self.assertTrue(board_analyzer.isCheckMate(board2, constants.BLACK_PLAYER))
示例3: test_is_legal_move_for_bishop
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_bishop(self):
from board import Board
b = Board()
b._board = ChessTest.board2
#Move up and to the left
self.assertTrue(b._isLegalMoveForBishop([2, 0, 0, 2]))
#Move down and to the right
self.assertTrue(b._isLegalMoveForBishop([2, 5, 4, 7]))
b._board = ChessTest.board1
#Legal kill
self.assertTrue(b._isLegalMoveForBishop([5, 7, 1, 3]))
示例4: test_is_legal_move_for_queen
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_queen(self):
from board import Board
b = Board()
b._board = ChessTest.board1
#Move left
self.assertTrue(b._isLegalMoveForQueen([5, 3, 4, 3]))
#Move right
self.assertTrue(b._isLegalMoveForQueen([3, 3, 4, 3]))
#Move up and left
self.assertTrue(b._isLegalMoveForQueen([3, 3, 0, 6]))
#Move down and right
self.assertTrue(b._isLegalMoveForQueen([5, 3, 6, 2]))
#Legal kill
self.assertTrue(b._isLegalMoveForQueen([5, 3, 7, 1]))
#Legal kill2
self.assertTrue(b._isLegalMoveForQueen([3, 3, 5, 3]))
#Legal kill3
self.assertTrue(b._isLegalMoveForQueen([5, 3, 2, 0]))
示例5: test_is_legal_move_for_king_negative_test
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_king_negative_test(self):
from board import Board
b = Board()
b._board = ChessTest.board1
#Move diagnoally two spaces
self.assertFalse(b._isLegalMoveForKing([4, 0, 2, 2]))
示例6: test_is_legal_move_piece_not_moved
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_piece_not_moved(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board2
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [2, 0, 2, 0]))
示例7: test_is_legal_move_improper_movement
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_improper_movement(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board2
#Pawn - move forward three
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [7, 1, 7, 4]))
#Pawn - move left
self.assertFalse(b.isLegalMove(constants.BLACK_PLAYER, [6, 6, 7, 6]))
#Pawn - move backwards
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [3, 1, 3, 0]))
#Rook - move diagonally
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [1, 2, 2, 3]))
#Knight - move forward two
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [4, 2, 4, 4]))
#Bishop - move forward one
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [2, 0, 2, 1]))
#Queen - move like knight
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [3, 3, 1, 4]))
#King - move forward two
self.assertFalse(b.isLegalMove(constants.BLACK_PLAYER, [4, 6, 4, 4]))
示例8: test_is_legal_move_for_knight_negative_test
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_knight_negative_test(self):
from board import Board
b = Board()
b._board = ChessTest.board1
#Move left two
self.assertFalse(b._isLegalMoveForKnight([5, 2, 3, 2]))
示例9: test_is_legal_move_for_king
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_king(self):
from board import Board
b = Board()
b._board = ChessTest.board1
#Move left
self.assertTrue(b._isLegalMoveForKing([4, 7, 3, 7]))
#Move up and left
self.assertTrue(b._isLegalMoveForKing([4, 0, 3, 1]))
#Move down
self.assertTrue(b._isLegalMoveForKing([4, 7, 4, 6]))
b._board = ChessTest.board3
#Legal kill
self.assertTrue(b._isLegalMoveForKing([4, 3, 3, 3]))
示例10: test_is_legal_move_illegal_kills
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_illegal_kills(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board1
#Black pawn moves forward to kill white pawn
self.assertFalse(b.isLegalMove(constants.BLACK_PLAYER, [6, 4, 6, 3]))
#Knight moves forward three spaces to kill black pawn
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [0, 2, 0, 5]))
示例11: test_is_legal_move_moving_into_occupied_space
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_moving_into_occupied_space(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board1
#White rook moves into white pawn
self.assertFalse(b.isLegalMove(constants.WHITE_PLAYER, [0, 0, 0, 1]))
#Black king moves into black bishop
self.assertFalse(b.isLegalMove(constants.BLACK_PLAYER, [4, 7, 5, 7]))
示例12: test_move_piece_queen_overtakes_queen
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_move_piece_queen_overtakes_queen(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board1
self.assertEqual(b._board[3][3], "q")
self.assertEqual(b._board[5][3], "*q")
b.movePiece(constants.WHITE_PLAYER, [3, 3, 5, 3])
self.assertEqual(b._board[3][3], "")
self.assertEqual(b._board[5][3], "q")
示例13: test_is_legal_move_for_knight
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_knight(self):
from board import Board
b = Board()
b._board = ChessTest.board2
#Forward and right
self.assertTrue(b._isLegalMoveForKnight([4, 2, 5, 4]))
#Forward and left
self.assertTrue(b._isLegalMoveForKnight([4, 2, 3, 4]))
#Right and up
self.assertTrue(b._isLegalMoveForKnight([4, 2, 6, 3]))
#Left and down
self.assertTrue(b._isLegalMoveForKnight([4, 2, 2, 1]))
b._board = ChessTest.board1
#Legal kill
self.assertTrue(b._isLegalMoveForKnight([5, 2, 6, 4]))
示例14: test_is_legal_move_for_rook_negative_test
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_rook_negative_test(self):
from board import Board
b = Board()
b._board = ChessTest.board2
#Diagnoal
self.assertFalse(b._isLegalMoveForRook([1, 2, 0, 3]))
#Path blocked by friendly piece
self.assertFalse(b._isLegalMoveForRook([7, 7, 0, 7]))
#Path blocked by enemy piece
self.assertFalse(b._isLegalMoveForRook([7, 7, 7, 0]))
示例15: test_is_legal_move_for_pawn_negative_test
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import _board [as 别名]
def test_is_legal_move_for_pawn_negative_test(self):
from board import Board
import constants
b = Board()
b._board = ChessTest.board2
#White pawn, forward three spaces from default position
self.assertFalse(b._isLegalMoveForPawn([7, 1, 7, 4], constants.WHITE_PLAYER))
#White pawn, backward one space
self.assertFalse(b._isLegalMoveForPawn([7, 1, 7, 0], constants.WHITE_PLAYER))
#Black pawn, move to left
self.assertFalse(b._isLegalMoveForPawn([6, 5, 6, 5], constants.WHITE_PLAYER))
#Black pawn, move to right
self.assertFalse(b._isLegalMoveForPawn([6, 5, 6, 5], constants.WHITE_PLAYER))
#Black pawn, forward diagonally
self.assertFalse(b._isLegalMoveForPawn([5, 5, 4, 4], constants.WHITE_PLAYER))
#Black pawn, forward diagonally
self.assertFalse(b._isLegalMoveForPawn([5, 5, 5, 4], constants.WHITE_PLAYER))
#White pawn, backward diagonally
self.assertFalse(b._isLegalMoveForPawn([5, 1, 6, 0], constants.WHITE_PLAYER))
#White pawn, backward diagonally
self.assertFalse(b._isLegalMoveForPawn([3, 1, 4, 0], constants.WHITE_PLAYER))
#White pawn, far across board
self.assertFalse(b._isLegalMoveForPawn([3, 1, 5, 7], constants.WHITE_PLAYER))
b._board = ChessTest.board1
#Cannot kill piece by moving forward (must move diagnoally)
self.assertFalse(b._isLegalMoveForPawn([6, 3, 6, 4], constants.WHITE_PLAYER))