Skip to content

Snake example issues #48

@jckr

Description

@jckr
  • "longest path" algorithm should check for "boring" hamiltonian circuits first ie see if the current path can fit on some dumb criss cross pattern that fills the screen ("framed z"). snakes in the initial position are guaranteed to match one of these.
  • natural movements. when possible, the snake should follow the shortest path from head to fruit. This means: if there is a complete path that goes from tail to head (ie - existing snake), then shortest path from head to fruit, then complete path from fruit to tail, snake should always choose that option. else, snake stays on its current complete path.
    each time a fruit spawns, we check if such a better path can be found. if we find that better path, we stick to it and won't reevaluate until there's a new fruit. If we can't find that path, we stick to the current path - possibly until we hit the fruit on that path.
    We've tried that approach but snake would somehow collide. with better testing and better function definition we can isolate the problems and make it work. besides, having first step done will make the "open space" more likely to be convex and so there should be more path possibilities.
  • we've tried rendering the frame with dom elements, and sure it's possible but it doesn't look great. let's scrap this and do canvas. Each segment of the snake can be done as a "pill" of length 2 x 1 with rounded ends. we could even alternate colors to stripe the snake. the head can be a circle with eyes added to the first "pill".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions