Developed by Ben Greenfield and Ben Placzek
Video presentation on this project can be found here:
https://www.youtube.com/watch?v=hrMI7ppUGyU&ab_channel=LazyTech
Base code for snake game inspired by FreeCodeCamp.org's example at:
https://www.youtube.com/watch?v=CD4qAhfFuLo&t=1734s&ab_channel=freeCodeCamp.org
Our objective was to create a game of snake that would be able to play itself intelligently by using
different search algorithms. We can create a scoring system so that we may analyze the performance of each algorithm.
The algorithms we tested were:
- Depth First Search
- Breadth First Search
- A Star Search
- Uniform Cost Search
After testing and compiling data, we found that BFS performed the best overall. This was determined by using our scoring system which can represented by:
finalScore = (score / actions) * 100
where score is the number of food eaten and actions is the sum of all actions taken until failure. We wanted to prioritize score over actions, as an algorithm that gets a higher score shows more success over basing it just on actions (i.e. DFS generates many actions, but a low score. DFS should be ranked lower even though it has a lot of actions).
After downloading from the git repository, you can:
- Run main() -Can play game of snake
- Run showExample() -Runs all searches at a slow speed
- Run runMultiple(times) -Calls runSearch for x times -Generates analytics based on every runSearch run
- runSearch(times) -Runs every type of search for 400 iterations or until agent dies -Calculates weighted scores -Writes to results.txt file -Generates a single bar graph with scores -Generates 4 line plots with actions vs scores