diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-07-25 17:27:57 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-07-25 17:27:57 (GMT) |
commit | 0e9ecb44ee254ca68df4bda1fb15444a312bbd5c (patch) | |
tree | 99713eb27150e979869b3d2ea0afc4b92d03cb11 /chess.py | |
parent | 74fe18db0e83b91915e2ebebc29a9dc95f166282 (diff) |
fix problem with pawn capture hints
Diffstat (limited to 'chess.py')
-rw-r--r-- | chess.py | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -545,7 +545,7 @@ class Gnuchess(): if capture: move = move[find(move, 'x') + 1:] if white: - if move[0] in 'kqbnrKQBNR': + if move[0] in 'KQBNR': capture_piece = move[0] if len(move) > 1: if move[1] in FILES: @@ -565,7 +565,7 @@ class Gnuchess(): elif move[0] in RANKS: capture_rank = move[0] else: - if move[0] in 'KQBNRkqbnr': + if move[0] in 'KQBNR': capture_piece = move[0] if len(move) > 1: if move[1] in FILES: @@ -621,66 +621,66 @@ class Gnuchess(): self, piece, source_file, source_rank, capture_file, capture_rank, capture=False): # Check for capture - if capture and piece == 'p': + if capture and len(self.move_list) % 2 == 0: if source_file == capture_file: f = FILES.index(capture_file) if f > 0: i = self._file_and_rank_to_index('%s%s' % ( - FILES[f - 1], RANKS[RANKS.index(capture_rank) + 1])) + FILES[f - 1], RANKS[RANKS.index(capture_rank) - 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.black[8 + p].get_xy() + pos = self.white[8 + p].get_xy() if x == pos[0] and y == pos[1]: return FILES[f - 1], \ - RANKS[RANKS.index(capture_rank) + 1] + RANKS[RANKS.index(capture_rank) - 1] if f < 7: i = self._file_and_rank_to_index('%s%s' % ( - FILES[f + 1], RANKS[RANKS.index(capture_rank) + 1])) + FILES[f + 1], RANKS[RANKS.index(capture_rank) - 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.black[8 + p].get_xy() + pos = self.white[8 + p].get_xy() if x == pos[0] and y == pos[1]: return FILES[f + 1], \ - RANKS[RANKS.index(capture_rank) + 1] + RANKS[RANKS.index(capture_rank) - 1] else: i = self._file_and_rank_to_index('%s%s' % ( - source_file, RANKS[RANKS.index(capture_rank) + 1])) + source_file, RANKS[RANKS.index(capture_rank) - 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.black[8 + p].get_xy() + pos = self.white[8 + p].get_xy() if x == pos[0] and y == pos[1]: return source_file, \ - RANKS[RANKS.index(capture_rank) + 1] - if capture and piece == 'P': + RANKS[RANKS.index(capture_rank) - 1] + elif capture: if source_file == capture_file: f = FILES.index(capture_file) if f > 0: i = self._file_and_rank_to_index('%s%s' % ( - FILES[f - 1], RANKS[RANKS.index(capture_rank) - 1])) + FILES[f - 1], RANKS[RANKS.index(capture_rank) + 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.white[8 + p].get_xy() + pos = self.black[8 + p].get_xy() if x == pos[0] and y == pos[1]: return FILES[f - 1], \ - RANKS[RANKS.index(capture_rank) - 1] + RANKS[RANKS.index(capture_rank) + 1] if f < 7: i = self._file_and_rank_to_index('%s%s' % ( - FILES[f + 1], RANKS[RANKS.index(capture_rank) - 1])) + FILES[f + 1], RANKS[RANKS.index(capture_rank) + 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.white[8 + p].get_xy() + pos = self.black[8 + p].get_xy() if x == pos[0] and y == pos[1]: return FILES[f + 1], \ - RANKS[RANKS.index(capture_rank) - 1] + RANKS[RANKS.index(capture_rank) + 1] else: i = self._file_and_rank_to_index('%s%s' % ( - source_file, RANKS[RANKS.index(capture_rank) - 1])) + source_file, RANKS[RANKS.index(capture_rank) + 1])) x, y = self._index_to_xy(i) for p in range(8): - pos = self.white[8 + p].get_xy() + pos = self.black[8 + p].get_xy() if x == pos[0] and y == pos[1]: return source_file, \ - RANKS[RANKS.index(capture_rank) - 1] + RANKS[RANKS.index(capture_rank) + 1] # Check for first move if piece == 'p' and capture_rank == '5': i = self._file_and_rank_to_index('%s7' % (capture_file)) |