Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Castling maybe not working #9

Closed
mkondel opened this issue Jan 16, 2016 · 4 comments
Closed

Castling maybe not working #9

mkondel opened this issue Jan 16, 2016 · 4 comments

Comments

@mkondel
Copy link

mkondel commented Jan 16, 2016

Just as an example, here is the board, player is white. As you can see, castling is not in the list of possible moves. There is a Board.getShortNotationOfMove() that should return '0-0-0' and '0-0', but move.kingsideCastle and move.queensideCastle are not getting recognized at that point.

It's your move. Type '?' for options. ? 0-0
command: 0-0
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? o-o
command: o-o
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? O-O
command: o-o
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? 0-0-0
command: 0-0-0
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? o-o-o
command: o-o-o
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? O-O-O
command: o-o-o
move None
Couldn't parse input, enter a valid command or move.
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ? l
command: l
a3
a4
b3
b4
c3
d3
d4
e5
g3
g4
h3
h4
Nc3
Na3
Qe2
Ke2
Kf1
Bd5
Be6
Bxf7
Bd3
Be2
Bf1
Bb5
Bxa6
Bb3
Nh4
Nd4
Nxg5
Ng1
Ne5
Rg1
Rf1
   a b c d e f g h   

8  R N B Q K B N R  8
7  x p x p p p x p  7
6  p x x x x x x x  6
5  x x p x x x p x  5
4  x x B x p x x x  4
3  x x x x x N x x  3
2  p p p p x p p p  2
1  R N B Q K x x R  1

   a b c d e f g h

Currently, the point difference is : 0
It's your move. Type '?' for options. ?
@jonathanMelly
Copy link

Same issue for me, as I saw in the code, the parser is not ready, nor the available moves report castling :-(
Time for a fork ;-)

@ddugovic
Copy link
Contributor

ddugovic commented Dec 11, 2017

I can fix this. For a start, it appears all the + and - symbols are backwards, although then the game crashes (during my testing the AI played Ng4xh2 just before this!):

Making move : Nxh2
   a b c d e f g h

8  R N B Q K B x R  8
7  p p p p p p p p  7
6  x x x x x x x x  6
5  x x x x x x x x  5
4  x x x x x x x x  4
3  x x x x x x p x  3
2  p p p p p p B N  2
1  R N B Q K x x R  1

   a b c d e f g h

AI thinking...

Making move : a5
   a b c d e f g h

8  R N B Q K B x R  8
7  x p p p p p p p  7
6  x x x x x x x x  6
5  p x x x x x x x  5
4  x x x x x x x x  4
3  x x x x x x p x  3
2  p p p p p p B N  2
1  R N B Q K x x R  1

   a b c d e f g h

Traceback (most recent call last):
  File "src/main.py", line 130, in <module>
    startGame(board, playerSide, opponentAI)
  File "src/main.py", line 78, in startGame
    if board.isCheckmate():
  File "/home/lila/command-line-chess/src/Board.py", line 125, in isCheckmate
    if len(self.getAllMovesLegal(self.currentSide)) == 0:
  File "/home/lila/command-line-chess/src/Board.py", line 411, in getAllMovesLegal
    if self.moveIsLegal(move):
  File "/home/lila/command-line-chess/src/Board.py", line 401, in moveIsLegal
    self.makeMove(move)
  File "/home/lila/command-line-chess/src/Board.py", line 332, in makeMove
    self.movePieceToPosition(rookToMove, move.rookMovePos)
AttributeError: 'Move' object has no attribute 'rookMovePos'

Fixing makeMove then results in command l being able to list the move, although I can't play O-O.

It's your move. Type '?' for options. ? O-O
Couldn't parse input, enter a valid command or move.
   a b c d e f g h

8  R x B Q K B N R  8
7  p x p p p p x p  7
6  N p x x x x x x  6
5  x x x x x x p x  5
4  x x x x x x x x  4
3  x x x x x N p x  3
2  p p p p p p B p  2
1  R N B Q K x x R  1

   a b c d e f g h

@jonathanMelly
Copy link

Well done, thanks for that first patch ;-)

@ddugovic
Copy link
Contributor

Glad to submit a patch the entire community may benefit from!

marcusbuffett added a commit that referenced this issue Jan 7, 2018
Fix castling and spelling of en passant #9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants