This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Game Development and the fly likes chess problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Game Development
Bookmark "chess problem" Watch "chess problem" New topic
Author

chess problem

omar bili
Ranch Hand

Joined: Aug 13, 2004
Posts: 177
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

Joined: Oct 17, 2001
Posts: 4313

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.


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
 
Have you checked out Aspose?
 
subject: chess problem
 
It's not a secret anymore!