Skip to content

aniruddhgoteti/CppND-Capstone-Snake-Game

 
 

Repository files navigation

CPPND: Dijkstra Algorithm adapting to Random Bot

Dijkstra's algorithm is also known as the shortest path algorithm. It is an algorithm used to find the shortest path between nodes of the graph. The algorithm creates the tree of the shortest paths from the starting source vertex from all other points in the graph. It differs from the minimum spanning tree as the shortest distance between two vertices may not be included in all the vertices of the graph. The algorithm works by building a set of nodes that have a minimum distance from the source. Here, Dijkstra's algorithm uses a greedy approach to solve the problem and find the best solution. (Source: https://favtutor.com/blogs/dijkstras-algorithm-cpp )

Note: The game is not perfect yet and the aglorithm doesnt yet adapt to the random bot perfectly, but this is a good example concerning good C++ programming practices.

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./SnakeGame.

Rubrics Completed

  • The project demonstrates an understanding of C++ functions and control structures

    rubric demonstrated in smartbot.cpp and controller.cpp

  • The project uses Object Oriented Programming techniques

    rubric demonstated in smartbot.h, controller.h, controller.cpp and smartbot.cpp where class methods are used

  • Classes use appropriate access specifiers for class members.

    rubric demonstated in smartbot.h and controller.h where access specifiers are used

  • The project uses destructors appropriately.

    Node in smartbot.cpp has its own class destructor which clears the vectors at destruction, thereby freeing the memory.

  • The project uses smart pointers instead of raw pointers.

    bot is a smart pointer declared and used in game.h and game.cpp

CC Attribution-ShareAlike 4.0 International

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

About

A 2D Snake game using C++ and SDL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 79.0%
  • CMake 21.0%