Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Queen 8 ChessBoard Example Help

 
Russell Ray
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to post here in hopes someone could provide me some direction of now to fix my problem.:

I have a simple chessboard made up of JPanels for each location on the chessboard. Each JPanel on the board has a JLable inside of it. This label has a color (black or white). As the user clicks on the location from the board, the program swaps out the JPanel with a new one with a Queen image. This seems to be working correctly, however, the application is place a "blank" JPanel to the left of the location where the queen is placed. I opine this is causing a reschuffle of the chessboard.

Could any please give me some pointers on how I can correct this.

Here is the code:


Any assisitance would be greatly appreciated as I have been working with this issue well over three days.

Russ
 
Russell Ray
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out.........

The problem was in the mouseReleaseed method. What was happening was exactly as I thought...... I was removing a JPanel and replacing it with a JLabel...... I didn't think Swing Components was doing this.

Here is the code:




Russ
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, how is your chess program going?
Are you using Alpha-beta pruning. You probably are, it is essential
for any chess program.
Have you managed to implement checkmate and stalemate?
Thats the only problem with mine, you can set it up a position, such as mate in 3, and it will solve it correctly, but however if there are a few
pieces on board, it seems to walk right into stalemate.
I just wondered if you knew how to implement checkmate and stalemate with alpha-beta.
The problem I've found is that the algorithm is too complex to test, even with 3 pieces on the board.
Basically I'm looking for some psuedocode of alpha-beta pruning that incorporates checkmate and stalemate.

Thanks, let me know how your doing if you can.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic