All Projects → notshridhar → chain-reaction-ai

notshridhar / chain-reaction-ai

Licence: MIT License
ai opponent for the game chain reaction

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to chain-reaction-ai

PYTRIS
tetris made with pygame
Stars: ✭ 26 (-72.63%)
Mutual labels:  pygame
MyChess
中国象棋pygame
Stars: ✭ 30 (-68.42%)
Mutual labels:  pygame
Pygin
Simple game engine produced for making easier to build more complex games using Python.
Stars: ✭ 21 (-77.89%)
Mutual labels:  pygame
PygameDocs
关于Pygame库的中文文档
Stars: ✭ 33 (-65.26%)
Mutual labels:  pygame
LastSecondSlides
Use the Google speech-to-text API to generate presentation slides as you talk!
Stars: ✭ 32 (-66.32%)
Mutual labels:  pygame
Chrome-Dino-Runner
🐱‍🐉 A Replica of the hidden Dinosaur Game from Chrome Browser Offline mode build using Python and PyGame.
Stars: ✭ 22 (-76.84%)
Mutual labels:  pygame
agario
Python clone of agar.io game, made with pygame.
Stars: ✭ 32 (-66.32%)
Mutual labels:  pygame
Pygame3D
Set of modules that use Pygame to display 3D graphics
Stars: ✭ 55 (-42.11%)
Mutual labels:  pygame
connect-four-js
Minimax and Alpha-Beta Pruning implementations in JavaScript
Stars: ✭ 21 (-77.89%)
Mutual labels:  minimax
pygame-text-input
a small module that enables you to input text with your keyboard using pygame
Stars: ✭ 114 (+20%)
Mutual labels:  pygame
The-Third-Element
🎮 Small scale RPG game for the ICS3U final project
Stars: ✭ 19 (-80%)
Mutual labels:  pygame
orbital-sim
A simple physics engine build over a PyGame simulation to accurately model planetary orbits in space
Stars: ✭ 31 (-67.37%)
Mutual labels:  pygame
visgraph simulator
See how visibility graphs work in an interactive way using Pyvisgraph and Pygame
Stars: ✭ 28 (-70.53%)
Mutual labels:  pygame
Galaxy-Attack
An inspiration of the original Atari Space Invaders game built in pygame 👾 🎮
Stars: ✭ 32 (-66.32%)
Mutual labels:  pygame
Training-Snake-Game-With-Genetic-Algorithm
training snake game using neural network and genetic algorithm
Stars: ✭ 28 (-70.53%)
Mutual labels:  pygame
GameOfLife
Conway's Game of Life
Stars: ✭ 18 (-81.05%)
Mutual labels:  pygame
sappho
2D Game Library
Stars: ✭ 15 (-84.21%)
Mutual labels:  pygame
MagicTower-Python
Python魔塔样板,自带Demo游戏内容(Powered by Pygame)
Stars: ✭ 32 (-66.32%)
Mutual labels:  pygame
AirHockey
Air Hockey game created using pygame
Stars: ✭ 25 (-73.68%)
Mutual labels:  pygame
blackstone
Gomoku (Five in a Row) game manager with a powerful built-in AI, written in Java with a clean, minimal interface.
Stars: ✭ 33 (-65.26%)
Mutual labels:  minimax

Chain Reaction AI

AI opponent for the strategic board game Chain Reaction.

Installation

To install the package in your computer, run the following (preferably in virtual environment)

git clone https://github.com/shridharrhegde/chain-reaction-ai
cd chain-reaction-ai
pip install -r requirements.txt
pip install .

Usage

$ chain-reaction --help
usage: chain-reaction [-h] [--minimal] [--c-backend] enemy

Chain Reaction

positional arguments:
enemy        Opponent to play with - [human, random, mcts, minimax]

optional arguments:
-h, --help   show this help message and exit
--minimal    Play in a minimal non-animated window
--c-backend  Use c for processing

Configurations

To play a game with your own configurations, see sample.py

Enemy Agents

Here is a list of agents you can play against (in ascending levels of difficulty)

  1. Random : Just a random move maker that picks from valid moves.
  2. MCTS : Naive Monte Carlo Tree Search that simulates games randomly. Needs long time to be good enough.
  3. Minimax : Simple DFS to minimize loss. Very hard to beat because of the aggressive static board evaluation function.

Game Rules

  • Two players take turns to place orbs of their corresponding colors. A player can only place an orb in an empty cell or a cell which already contains colored orbs of his own. When two or more orbs are placed in the same cell, they stack up.
  • The critical mass of a cell is equal to the number of adjacent cells i.e., 4 for usual cells, 3 for edge cells and 2 for corner cells.
  • When a cell is loaded with a number of orbs equal to its critical mass, the stack explodes. As a result of the explosion, all the orbs from the initial cell fly to adjacent cells. The explosions might result in overloading of an adjacent cell and the chain reaction of explosion continues until every cell is stable.
  • When a red cell explodes and there are green cells around, the green cells are converted to red and the other rules of explosions still follow. The same rule is applicable for other colors.
  • The winner is the one who eliminates other player's orbs.

Gameplay

A game against minimax agent looks like this -

Uninstalling

To uninstall, run

pip uninstall chain-reaction

Dependencies

Runtime

  • python3
  • numpy
  • pygame

Building

  • wheel
  • setuptools
  • gcc

Tested on python 3.6 and pygame 1.9.6 on both Mac and Linux

Licence

The project is completely open-source under MIT Licence, so feel free to fork and modify this code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].