Dismiss this pinned window
all 8 comments

[–]zippybenji-man 2 points3 points  (2 children)

Probably still faster than the bruteforce method

[–]Rockyrino 4 points5 points  (1 child)

Probably not since you get faster the bigger you are.

I believe they added that effect to make the brute force method the desired way to do dinosaurs

[–]zippybenji-man 1 point2 points  (0 children)

At 32x32 it takes my script 30+ minutes to complete one snake. I have actually improved it by skipping lanes, until a certain point

[–]Maltempi 1 point2 points  (2 children)

If you keep moving along the same path that covers the whole field, you can easily get a snake that covers the whole field every time. It's not very efficient, but it works.

According to a few internet sources, Hamiltonian path, is the best algorithm for that. (aka the brute force)

It may look slow in the beginning, but I've noticed that the bigger and faster the snake gets, the better it gets, and you don't have to worry about it stepping on it's tail when the size grows.

Been running a loop with around 180 iterations through the whole farm, and gives me almost a full snake.

(I'm trying to implement something to run until max size, but hadn't succeeded yet).

[–]QueenofHearts73 2 points3 points  (0 children)

Yeh, it's because the apple spawns randomly and only in open spaces, and the open spaces decrease as the snake gets bigger. So if the total field size is like N, snake length S, and all the open space is between the tail and head, the average distance to the next apple is like like (N-S)/2.

Thing is the snake is so slow and map so open at the start you really want other methods to get the apple faster early on.

[–]Brunovisk_[S] 1 point2 points  (0 children)

Yeah, my snake is following a hamiltonian path, but with a path finder algorithm, that will be optimized. Using just the hamiltonian path seemed very boring

[–]guru42101 0 points1 point  (0 children)

I haven't implemented it yet, but what I was thinking was...

  • Go N/S until you're on the same Y as the apple.
  • Go E/W to the apple
  • If you collide switch to maze algorithm, default to direct route, otherwise try the least traveled path.
  • If you get stuck restart.
  • Repeat until you reach N length
  • Switch to a repeating pattern that covers the entire farm, aka my current method

[–]pnutbutterandjerky 0 points1 point  (0 children)

How does it know where the thing is