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

Can you beat this game?

 
J Eisses
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I started programming in java 3 days ago and after reading the tutorials on java.sun.com I tried to remake a small puzzle game I saw on a forum a few years back.
Clicky (Applet)

You have to click on the black tiles in the applet and can only make moves like the horse in chess.

Source:
http://www.chainswarriors.com/SmallGame.java
http://www.chainswarriors.com/Board.java

PS. Feel free to comment on the code, this is my first java creation ever, I could use it
[ September 07, 2007: Message edited by: Jesse Eisses ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J Eisses
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J Eisses
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic