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-game
and you do not wish to replace it, go toenvironment.yml
and change the name of the environment on the first line:name: snake-game
-
Create an anaconda environment with the
environment.yml
file:conda env create -f environment.yml
ℹ The environment.yml
was created withconda env export --from-history > environment.yml
⚠ If the command conda
cannot 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 thebase
environment -
Activate the environment (replace
snake-game
with 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-game
to avoid messing with your python installation.python -m venv snake-game
Activate the virtual environment
POSIX (Linux/macOS):
source snake-game/bin/activate
Windows (cmd.exe):
snake-game\Scripts\activate.bat
Windows (PowerShell):
snake-game\Scripts\Activate.ps1
-
Install the required libraries.
pip install -r environment.txt
ℹ The environment.txt
was created withpip list --format=freeze > environment.txt
-
Activate the environment if it is not activated yet.
-
Change into the
app
directory.cd app
-
Run the server with:
uvicorn server:app --reload
The 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
/docs
to 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