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

Mirrored piece moves when move is pushed to the board #41

Closed
cupOfJava2014 opened this issue Jul 25, 2015 · 5 comments
Closed

Mirrored piece moves when move is pushed to the board #41

cupOfJava2014 opened this issue Jul 25, 2015 · 5 comments

Comments

@cupOfJava2014
Copy link

When a Move is created for a piece, for example, the white pawn on a2, the data in the Move appears to be correct. However, when the Move is pushed to the board the mirrored piece is moved instead (black pawn on a7 is moved instead).

if not spaceClicked == None:
                sx, sy = spaceClicked
                index = getIndex(sx, sy)
                print index
                move = []
                moves_str = []
                moves_index = []
                hspaces_old = highlight_spaces
                highlight_spaces = []

                index = getIndex(sx,sy)
                pc = spaces[index]

                highlight = False
                for sqr in range(64):
                    if chess.Move(index, sqr) in boardData.legal_moves:
                        move.append(chess.Move(index, sqr))
                if index in hspaces_old:
                    new_move = chess.Move(space_in_focus, index) # Have found this to be correct. The data given matches the chosen move
                    boardData.push(new_move) # Focus of issue
                for m in move:
                    moves_str.append(m.uci()[2:])
                    for mstr in moves_str:
                        #moves_index.append(chess.SQUARE_NAMES.index(mstr))
                        highlight_spaces.append(chess.SQUARE_NAMES.index(mstr))
                    space_in_focus = index
@niklasf
Copy link
Owner

niklasf commented Jul 25, 2015

Hi. Can you please try

print(new_move)
print(boardData.fen())
boardData.push(new_move)
print(boardData.fen())

to get more info?

Aside: Note that if chess.Move(index, sqr) in boardData.legal_moves: will never exactly match promotions.

@cupOfJava2014
Copy link
Author

Here is the data output when moving the white pawn on a2 to a4:

Move to commit(new_move):  a2a4
Pre-push board data:  rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Post-push board data:  rnbqkbnr/pppppppp/8/8/P7/8/1PPPPPPP/RNBQKBNR b KQkq - 0 1

Please note that this program is unfinished and piece promotions have not been implemented yet.

@niklasf
Copy link
Owner

niklasf commented Jul 26, 2015

Sure, I just thought i should mention it.

The output looks as expected to me. A white pawn starts on a2. White pieces are uppercase in FENs. The first rank goes last.

@cupOfJava2014
Copy link
Author

So, what is the problem then?

Please excuse my slow reply to your comments. I am on vacation and am out of town a lot.

@niklasf
Copy link
Owner

niklasf commented Aug 7, 2015

Maybe you're drawing the board mirrored or with inverted colors? You could also try print(boardData) to see in the console how it should look like.

Happy holidays!

@niklasf niklasf closed this as completed Sep 15, 2015
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

2 participants