https://github.com/d12/snakeai
A simple AI harness to test algorithms on a game of Snake.
https://github.com/d12/snakeai
Last synced: over 1 year ago
JSON representation
A simple AI harness to test algorithms on a game of Snake.
- Host: GitHub
- URL: https://github.com/d12/snakeai
- Owner: d12
- Created: 2018-02-19T02:40:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-24T02:54:38.000Z (over 8 years ago)
- Last Synced: 2025-02-12T15:18:07.858Z (over 1 year ago)
- Language: Ruby
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Snake AI
A simple command line snake game where the snake is controlled by an interchangable AI module.
To use, create a new player in `players/`. Player classes should implement `#next_move` which takes the game state as input and outputs the next move. To test your player, swap `ManualPlayer` for your new player in `main.rb` and run `ruby main.rb`.
An example of a simple player can be seen in [players/manual_player.rb](https://github.com/d12/SnakeAI/blob/master/players/manual_player.rb)
## SnakeGame
`SnakeGame` is the game state object passes into player objects. It exposes two pieces of information
### @apple
`@apple` represents the 2d coordinate of the apple.
```
@apple
=> [1, 2]
```
### @snake
`@snake` represents the position of all segments of the snake. The first segment is the head of the snake.
```
@snake
= > [[1, 3], [1, 4], [2, 4]]
```