Skip to content

WarwickAI/snake-comp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Warwick AI Snake Competition ๐Ÿ†

snakebr

๐ŸŽฎ Welcome to the first ever WAI AI Programming Competition! ๐ŸŽฎ

Competition Status Week Prize


Hello all and welcome to the first ever Warwick AI programming competition!

Don't worry if you're new to programming or AI, there's something here for everyone! For beginners, check out the WAI + Code Soc + UWCS Python course or ask us anything at our weekly code nights. See our website for details.

๐ŸŽฏ Competition Highlights

  • ๐Ÿ—บ๏ธ Format: Squad up in teams of any size!
  • ๐Ÿง  Duration: Running officially till week 9 of term 1
  • ๐Ÿ’ฐ Prize: The winning team will receive a ยฃ50 Tesco Voucher + eternal WAI glory
  • ๐Ÿ“Š Leaderboard: Live updates on our website throughout the competition
  • ๐Ÿ† Final Testing: We'll do thorough testing for final results

๐Ÿ“ Contributing

๐Ÿค– We want this repository to become place where future members can explore a variety of AI implementations and archetypes.

โค๏ธ Once the competition is over, we'd love to accept any and all creations as open source contributions! Your AI might even be used as a baseline for scoring future submissions!

โœ๏ธ Also, this is a also new project with room for improvement. If you have ideas or suggestions:

  • โœ‰๏ธ Message us directly
  • ๐Ÿšจ Send a pull request with your changes

Open source contributions are great practice and go an long way on a CV!

๐Ÿ› ๏ธ Environment Setup

Using the Template

1๏ธโƒฃ Step 1 - Login on our Website

First, login on our website https://warwick.ai with your GitHub account! Don't worry if you forget, logging in later won't break anything :)

2๏ธโƒฃ Step 2 - Copy the Template

Next, use this template repository to create you own by pressing Use this template: โฌ‡๏ธ

template

This button is in the top right of the page. You will be prompted to give it a name and choose for it to be public/private. These setting are completely up to you and won't affect anything :)

3๏ธโƒฃ Step 3 - Enable the WAI GitHub App

Then, go to https://github.com/apps/warwickai and press install/configure to authorise the app to view your repository.

This is what allows us to send your score to the leaderboard!

ghapp

4๏ธโƒฃ Step 4 - Installing Dependencies

Open your project's repository in a terminal and install the required dependencies:

# Create virtual environment
python -m venv .venv

# Activate it
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -e .

With this done, submitting is as easy as pushing a commit to your repository!

Alternatives

If you don't have a development environment set up, an alternative is making a github codespace:

codespaces

Please note, snake run will not work from a github codespace, instead the code must be run locally.


๐ŸŽฏ Running the Game

Available Commands

๐Ÿ“‹ List all difficulties

snake list

๐Ÿ‘€ Watch your AI play

snake run easy
snake run hard

โšก Run headless tests

snake test 100 medium
snake test 50 all  # cycles through every difficulty

๐ŸŽฒ Deterministic testing

snake run hard --seed 123
snake test 100 hard --seed 69

๐Ÿง  Writing Your AI

The Basics

Your submission is the myAI function in myAI.py:

def myAI(state: GameState) -> Turn:
    # Your brilliant strategy here!
    return Turn.LEFT  # or Turn.STRAIGHT or Turn.RIGHT

Your AI function should use the current state of the game state and ouput one of Turn.LEFT, Turn.RIGHT or Turn.STRAIGHT.

The turn you choose will make your snake turn left, right or stay straight before moving.

Some Inspiration

There's all sorts of ways to write an AI for this competition:

  • Rules/heuristics
  • Search algorithms
  • Reinforcement learning
  • and much more!

๐Ÿ† Submitting you AI

๐Ÿ To submit your AI, simply push a commit to your repository.

๐Ÿงช This will run some automated tests and your score will automatically appear on the website! https://warwick.ai


๐Ÿšจ Important

Don't change anything in the snake folder as the submission tests use this code!

Other than this, have fun and see you at code nights!


Need Help?

  • ๐Ÿ“… Weekly code nights
  • ๐ŸŒ Visit warwick.ai
  • ๐Ÿ’ฌ Message us with questions

๐Ÿ† Good luck and may the best snake win! ๐Ÿ†