• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chess problem

 
omar bili
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all , i am writing a chess game
where can i perform if the test is legal or not ?
and should i take all the possibilities or is there might be
a better way to do that ?
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as was suggested in your previous post... one idea is to create an interface for the chess piece:

Then you can implement this class for each type of chess piece. You'll have to come up with a scheme to determine if a given move is allowed.

For example... for a knight they can move (ummm I forget) 1 forward and 3 to the side?? so given the current position, is (x,y) the position that is 1 space forward and 3 to the side? Also is (x,y) even on the board? Is another piece occupying that space?

Maybe your Board class will have methods like


Does that make sense? Try thinking along those lines and see what you come up with.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic