Food Eaten:
Moves:
Average Moves:
Average Nodes Processed:

Purpose

The goal of this assignment was to measure the usefulness of various search algorithms. In this example, we are using Breadth First Search, Depth First Search, and A* search with two heuristics (and combined) to allow the snake to find the food.

How it works

This application uses web workers to offload the processing, which allows the browser UI to remain responsive even though CPU intensive operations may be taking place. The results are drawn on the screen using a canvas element.

Findings

Breadth First Search - Results in low average moves, but must process many nodes (low number of moves at high CPU cost)
Depth First Search - Results in high average moves, but must process many nodes (high number of moves at high CPU cost, very bad)
A* Search - Results in low average moves, with low number of processed nodes (low number of moves at low CPU cost, very good)

What Makes A* So Great?

It's the heuristics! A* search allows us to know what direction the food is closest to, so we search in that direction instead of randmonly wandering around the board. Sort of like if the snake had a sense of smell.