fowode / pychess

Automatically exported from code.google.com/p/pychess
GNU General Public License v3.0
0 stars 0 forks source link

Game ending priority #692

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It looks like getResults (the check for game endings) has an issue with ending 
priorities.  It looks like it checks for repetition and 50 move rule draws 
before checkmate.  It doesn't happen very often but I was trying to use pyChess 
to generate some test cases and this caused some problems.

Utils/logic.py  around line 40.

I made the following modifications so I could get going on my project but I 
removed the LOSERSCHESS variant (Not familiar with it, sorry)

def getStatus (board):
    lboard = board.board
    board_clone = lboard.clone()
    hasMove = False
    for move in lmovegen.genAllMoves (board_clone):
        board_clone.applyMove(move)
        if board_clone.opIsChecked():
            board_clone.popMove()
            continue
        board_clone.popMove()
        hasMove = True
        break

    if not hasMove:
        if lboard.isChecked():
            if board.color == WHITE:
                status = BLACKWON
            else:
                status = WHITEWON
            return status, WON_MATE
        else:
            return DRAW, DRAW_STALEMATE

    if ldraw.repetitionCount (lboard) >= 3:
        return DRAW, DRAW_REPITITION

    if ldraw.testFifty (lboard):
        return DRAW, DRAW_50MOVES

    return RUNNING, UNKNOWN_REASON

Original issue reported on code.google.com by stevemul...@gmail.com on 10 Oct 2011 at 5:57

GoogleCodeExporter commented 9 years ago
Good catch, thx!

Original comment by gbtami on 14 Oct 2011 at 9:08

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 2f03c3d00c58.

Original comment by gbtami on 14 Oct 2011 at 9:10