Skip to content

Nonentity5565/Artificial-Intelligent-Snake-Game

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

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.

Players

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

Setup

  1. Download this repository OR clone this repository to your machine.

Python Environment Setup

With Anaconda

  1. Open a terminal at the root directory of this repository.

  2. If you have an anaconda environment called snake-game and you do not wish to replace it, go to environment.yml and change the name of the environment on the first line:

    name: snake-game
    
  3. Create an anaconda environment with the environment.yml file:

    conda env create -f environment.yml
    
    ℹ The environment.yml was created with conda 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 the base environment
  4. Activate the environment (replace snake-game with your environment name if you have changed it in step 2):

    conda activate snake-game

Without Anaconda

  1. Open a terminal at the root directory of this repository.

  2. [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

  3. Install the required libraries.

    pip install -r environment.txt
    
    ℹ The environment.txt was created with pip list --format=freeze > environment.txt

Activate the Python Server

  1. Activate the environment if it is not activated yet.

  2. Change into the app directory.

    cd app
    
  3. 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.
    
  4. Open your browser, go to the URL that has been provided in the terminal.

API testing

  1. Activate the python server

  2. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 55.1%
  • Python 22.7%
  • JavaScript 22.2%