Snake charmer

Discuss about the puzzles, but without giving the solutions please !!!

Snake charmer

Postby admin » Sun Oct 30, 2011 12:48 am

The goal of this puzzle is to write the artificial intelligence for the popular snake game.


User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Snake charmer

Postby random.johnnyh » Mon Oct 31, 2011 8:34 am

I might be understanding the problem wrong, but how is a score of 1512186 even possible?
Assuming that the snake occupies every position of a 30*30 grid, it must have eaten at most 900 apples, and gotten at most 90,000 points, which doesn't add up for all of the test cases given.
User avatar
random.johnnyh
 
Posts: 15
Joined: Wed Apr 20, 2011 6:04 pm

Re: Snake charmer

Postby admin » Mon Oct 31, 2011 9:09 am

random.johnnyh wrote:I might be understanding the problem wrong, but how is a score of 1512186 even possible?
Assuming that the snake occupies every position of a 30*30 grid, it must have eaten at most 900 apples, and gotten at most 90,000 points, which doesn't add up for all of the test cases given.


Sorry about that, we inadvertently multiplied the score by 6 !
The score proportion and everything else is ok, so we removed the factor 6, and we're recomputing the scores (this time without multiplying them by 6).

Thanks for pointing this to us.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Snake charmer

Postby demo » Tue Nov 01, 2011 6:51 pm

for a map below
..
.+
if the snake moves in clockwise direction, in the following 5 steps, the corresponding situation will be
1st the length is 4
2nd nothing
3rd nothing
4th nothing
5th game ends
the problem is when the next grid the head is going to is the tail and there is a '+' in the origin map there. From the 2nd step, I conclude the sections of the snake move simultaneously, and I think in this map the '+' will always be occupied by the snake, so maybe it's inconsistent. would you give some clarifications?
User avatar
demo
 
Posts: 11
Joined: Mon Jan 17, 2011 7:18 pm

Re: Snake charmer

Postby admin » Tue Nov 01, 2011 9:46 pm

@demo
In that case, the snake eats the apple and immediately after bites its tail.
If you run it in the simulator (you can enter your own map and simulate the moves), you'll get a score of 192 with the moves dlurd

The scoring follows exactly the behavior of the javascript simulator given on the puzzle page.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Great Puzzle

Postby browni3141 » Tue Nov 01, 2011 10:06 pm

I just want to say that I am loving/hating this puzzle. I only wish I had more time to implement my ideas. Thanks for a great site!

Right now my snake is committing suicide for some reason. I think it needs therapy.
User avatar
browni3141
 
Posts: 19
Joined: Mon Jan 31, 2011 11:05 am

Re: Snake charmer

Postby random.johnnyh » Tue Nov 01, 2011 11:15 pm

Agreed, this puzzle is one of the best on the site, because there are so many different ways to approach the problem, and even simple algorithms or slow languages can perform very well.
User avatar
random.johnnyh
 
Posts: 15
Joined: Wed Apr 20, 2011 6:04 pm

Re: Snake charmer

Postby bobby » Wed Nov 02, 2011 12:00 am

I love this puzzle too ! What I really like about it is the javascript program that replays the moves. It helped me so much to write my solution, I would code something, run my program, and then copy one of my test boards in the simulator, then copy my moves and watch it play. It helps so much to analyze where the solution does not perform well.

Unfortunately I cannot figure out the Pawn Battle, so I am not going to win anything. But at least I am having a good score on the snake charmer puzzle. Actually, I still have many ideas to improve my solution but time is running short, anyway I do it for fun and I'll keep testing my program even after the contest ends.

Back to coding now, hehe !
User avatar
bobby
 
Posts: 6
Joined: Mon Feb 14, 2011 3:19 pm

Re: Snake charmer

Postby Moises Lopez » Wed Nov 02, 2011 11:55 pm

Hey , Congrats Random Johnny , bobby , protocolocon (and all the ones that made a good result in this problem or at least try a little).

I had the good idea to maximize this too late and had no time to implement it (I think that is the good one, maybe not)

See you in the next battle. This was tooo fun.
User avatar
Moises Lopez
 
Posts: 5
Joined: Fri Jul 01, 2011 11:50 pm

Re: Snake charmer

Postby protocolocon » Thu Nov 03, 2011 9:23 am

Just over the deadline I think I also got some kind of idea... let's see if it works :roll:

Congratulations for the top coders at the first attempt!
User avatar
protocolocon
 
Posts: 8
Joined: Sat Jan 22, 2011 4:36 am

Next

Return to Puzzles

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron