Everyone can write their own AI. It is one of the main ideas of this website.
Code Game Challenge is a very interesting competition conducted worldwide in many different forms.
Most of them are held as side events at various programming competitions, like ACM ICPC.
They consist in writing the logic for a player-controlled unit that performs some actions in the game world.
Remember your favorite game.
What if you could program the behavior of your character,
and then see how it behaves under your code's control?
Interesting, isn't it?
On this website, you can do something similar, and from anywhere, anytime.
This Rails app allows you to participate in Code Game Challenge competitions.
You can play with other players or train with bots.
The app contains many interesting WEB techniques and features (check the list below).
Strategy
Player's class that defines the behavior of your unit (in our case, a wizard)
Simulator (the processing system)
A system that performs a simulation of a game world based on classes written by players (Strategies)
Game step (simulation step)
It is a world simulation resolution.
At every step, Simulator executes the code of all strategies and processes behavior of their units.
During this process, units can issue commands to walk and cast shells (each move costs some energy to perform).
Scallable implementation of game sessions.
- Recruit players from the lobby
- Game Sessions can be limited in time
- You can see the game visualization at any moment
The Simulator processes the game world state and players' strategies code, which control your unit.
Main features of the Simulator are:
- Expandable tiny game engine
- You can add many things, like new skills for units, new game objects, new constraints & so on
- Secure execution of players strategies classes
- Support for strategies written in Ruby
- Output is a JSON file
- You can visualize output with (app/assets/javascripts/visualizer)
- Number of static pages are written in Markdown
- Device gem
- Secure player's code evaluation
- Bootstrapped views
- Custom 404 pages
- Heroku workaround for Hobby price plan (DB errors)
- Online code editor for strategies
Ruby 2.2.4
Linux systems (due to secure
gem)
- Create database for required environment (prod or dev)
rake db:schema:load
- Precompile assets
rake assets:clean && rake assets:precompile
For production, you will also need to add the keys to config/secrets.yml
and initializers/devise.rb
Tests use Minitest
library.
Use rake test
to run all tests.
The app is deployed on Heroku with 'Hobby' plan:
https://ai-project-new.herokuapp.com/
Sometimes PostgresDB closes connections.
One workaround here is to rescue
these moments and reconnect.
This technique is implemented in simulation action in the GameSession controller.