Students of Artificial Intelligence (CSC3206) at Sunway University were tasked with designing and implementing aritificial intelligent players for a snake game.
- Snake game is provided by the lecturer and students are only required to implement the players.
- The rules of the game is exactly like a regular snake game.
- At every iteration, information of the game state is passed to the player and algorithm must utilize the information and return the next move.
- Each AI player must be able to achieve a certain score to be considered successful.
The algorithms implemented in this assignment are path-finding algorithms. Three different varient of path-finding artificial intelligent players were implemented utilizing:
- A-star Search
- Breadth-first Search
- Uniform Cost Search
- Download this repository OR clone this repository to your machine.
-
Open a terminal at the root directory of this repository.
-
If you have an anaconda environment called
snake-gameand you do not wish to replace it, go toenvironment.ymland change the name of the environment on the first line:name: snake-game -
Create an anaconda environment with the
environment.ymlfile:conda env create -f environment.ymlℹ The environment.ymlwas created withconda env export --from-history > environment.yml⚠ If the command condacannot be found, you can either add the anaconda binaries folder to system path, or open the terminal from anaconda navigator by clicking the triangle icon next to thebaseenvironment -
Activate the environment (replace
snake-gamewith your environment name if you have changed it in step 2):conda activate snake-game
-
Open a terminal at the root directory of this repository.
-
[Optional] Create a virtual environment called
snake-gameto avoid messing with your python installation.python -m venv snake-gameActivate the virtual environment
POSIX (Linux/macOS):
source snake-game/bin/activateWindows (cmd.exe):
snake-game\Scripts\activate.batWindows (PowerShell):
snake-game\Scripts\Activate.ps1 -
Install the required libraries.
pip install -r environment.txtℹ The environment.txtwas created withpip list --format=freeze > environment.txt
-
Activate the environment if it is not activated yet.
-
Change into the
appdirectory.cd app -
Run the server with:
uvicorn server:app --reloadThe terminal output will display this if the server is started correctly. You may have a different URL.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [28720] INFO: Started server process [28722] INFO: Waiting for application startup. INFO: Application startup complete. -
Open your browser, go to the URL that has been provided in the terminal.
-
Append
/docsto the end of the local server URL. For instance, if the URL is http://127.0.0.1:8000, then go to http://127.0.0.1:8000/docs