예제 #1
0
from fenChecker import Fen, WarningMsg

# initial test
print('****************************************************************')
print('test all castling OK')
fen = 'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2'
board = 'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R'
test = Fen(fen)
a = test.boardToString(board=board)
print(a)
print(len(a))
boardString = test.boardToString(board)
b = test.interrogateBoard(boardString = boardString, targetSquare = 'e8')
print('The piece on e8 is a ' + b)
c = test.checkCastling(board =board, castling = 'KQkq')
print('castling passed "KQkq" : ' + c)
c = test.checkCastling(board =board, castling = '-')
print('castling passed "-" : ' + c)
c = test.checkCastling(board =board, castling = 'kq')
print('castling passed "kq" : ' + c)
c = test.checkCastling(board =board, castling = '')
print('castling nothing passed: ' + c)
c = test.checkCastling(board =board, castling = "?")
print('castling question mark element passed: ' + c)

print('****************************************************************')
print('test Black King moved')
fen = 'rnbkqbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2'
board = 'rnbkqbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R'
test = Fen(fen)
a = test.boardToString(board=board)
예제 #2
0
a) test display of board
b) test too many pawns
c) pawns on 1st or 8th rank
d) pawns + queens more than 9
z) to finish tests

""")
    selection = input('please select option\n')

    # -----------------------------------------------------------------------------
    if selection == 'a':
        print('pre-set test\n')
        test = Fen(
            'rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2')
        # arguments given
        w = test.boardToString(
            board='rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R')
        print('The simplest board representation looks like this ...\n')
        test.displayBoardString(w)
        print('\n')
        wait = input('press any key to continue\n')
        print('This adds colour...\n')
        x = test.boardToArray(
            board='rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R')
        test.displayBoard(x)
        wait = input('press any key to continue\n')
        print('This adds rank and file markers...\n')
        y = test.augmentBoard(x)
        test.displayBoard(y)
        wait = input('press any key to continue\n')
        print('\n')
        print("""