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.
I haven't really looked at the code, but it looks like you've done pretty well for only 3 days of Java.
I assume the goal is to land on every square exactly once, like a Knight's Tour? In that case it is provably impossible to solve this board. If you color in all the suqares in a checkerboard pattern, with the middle starting square black, then there are 24 black squares and 21 white squares. But a knight's move will always go from black to white or white to black. If it starts on black and makes 44 moves, it will reach 23 black squares and 22 white squares. There's no possible way to cover them all, for the given board.
If you enhance this to use other board shapes, may I suggest adding a reset key? And maybe an "undo" key. That would make it much easier to try different tactics without having to reload everything.
"I'm not back." - Bill Harding, Twister
Joined: Sep 05, 2007
Thanks for the comment .
Sorry for the bad explanation. The goal is to get an high as possible score, you can only touch each tile once and you're score will raise by 1 everytime you hit a tile. I've managed to get a score of 41 (only 3 open squares left). I allready thought it would be impossible to totally complete the board, but maybe it'll be possible to get just one open square left.
Anyways, I think it can still be a quite fun challenge to 'nearly' complete the board. I'll create an undo and reset function later today, and maybe add some more boards if I can think of any good ones.
Joined: Jan 30, 2000
Yes, I can fill all but 3 squares too. At that point, if we color them in as a black and white checkerboard with the center square black, there are 21 black squares and 21 white squares filled, and the remaining squares are all white. (I misspoke earlier - if the center square is black, then there are 24 white and 21 black, not 24 black and 21 white.) The last move was on a white square, and so the next must be on a black square - but there are no black squares remaining. Thus, having 3 squares remaining is the best possible score for this game.
If getting the highest score is the goal, perhaps you could add a box labeled Score: which displays the current score. That would make the goal a bit clearer, I think.
Joined: Sep 05, 2007
Thanks for the advice, I'm going to update the game when I got some time. I'm thinking about creating a few levels, for each level you'll need a certain score to complete, maybe I'll also add a time limit of some sort.