Coder Social home page Coder Social logo

radtek / soccer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koz4k/soccer

0.0 1.0 0.0 3.62 MB

Bot for paper soccer, the winning submission to the Artificial Intelligence in Games Contest organized in 2014 at the Faculty of Mathematics, Informatics and Mechanics at the University of Warsaw.

License: MIT License

CMake 0.83% C++ 80.69% C 14.84% Turing 1.72% TeX 0.01% Roff 1.77% Objective-C 0.14%

soccer's Introduction

Paper soccer bot

This repo contains code for the winning submission to the Artificial Intelligence in Games Contest (page in Polish) organized in 2014 at the Faculty of Mathematics, Informatics and Mechanics at the University of Warsaw. Since then it has laid lost and forgotten on my computer until I finished my studies in 2018. Then I decided that the code might still be useful to someone, so I cleaned it up and put it on GitHub.

Getting started

This project uses the CMake build system. To build, run:

mkdir build && cd build && cmake .. && make

The binary will appear in build/bin/soccer. By default, it will launch a GUI for playing with the best version of the bot. It's quite hard to beat, at least for me ๐Ÿ˜‰

The GUI uses the Ultimate++ framework. The relevant part of it is included in this repo.

Game

Screenshot of the board

Paper soccer is played by two people on a quadratic grid in shape of a rectangle. There are two goals, one for each player, placed on the opposite sides of the grid. At the beginning of the game, the ball is placed at the center of the grid, at an intersection of lines. Players make their turns moving the ball to an adjacent intersection in one of the 8 directions by drawing a line between the old and new position. Lines cannot be drawn over existing lines. If a player reaches a point already connected with a line (or an edge of the grid), the ball "bounces" and they get another turn. The player who places the ball in the other player's goal wins.

The game is described in more detail on the Wikipedia.

Algorithms

For the purpose of this contest I implemented various strategies, including alpha-beta pruning, Monte Carlo tree search with various improvements (including RAVE) and other, simpler heuristics.

Implementations of those algorithms can be found at soccer/ai. The strategies are composable, for example MCTS can use any other strategy for generating playouts.

Modes

Coming up with the solution required a lot of experimentation, tuning the parameters by setting bots against each other and playing with them manually to understand their flaws. Much of the code for those experiments is included in this repo as switchable "modes" - .hpp files containing actual code, that can be switched by changing the following line in soccer/main.cpp before building the binary:

#define MODE play

List of modes:

  • play - default mode, a GUI for playing with the best version of the bot (MCTS)
  • generator - a tool for generating openings, not used in the final submission
  • standalone_ab, standalone_mcts - standalone versions of the alpha-beta and MCTS bot respectively, communicating via stdin and stdout according to the contest protocol
  • ab_contest, mcts_contest, k_tuning, sanity_contest, time_contest, timing_test - various experiments with bots playing against each other, for comparing them and tuning their parameters

Acknowledgements

Many thanks to Jakub Pawlewicz, who organized the contest and prepared the materials that enabled implementing this bot.

soccer's People

Contributors

koz4k avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.