The Chainreaction domain is the examplary domain for jABC4 which will be used to introduce the first modeling steps.

Chainreaction is also available as standalone game. To download, visit: http://cr.freewarepoint.de/

# Rules of the Game

The Chainreaction game is a strategy board game for two players.

The board has 6×5 tiles (“*cells*“). Initially, they are empty. Each player alternately places one token (“*atom*“) on a cell that is either empty or belongs to that player. A cell belongs to a player if it contains at least one atom of that player.

### Cell Capacity

Every cell can hold a fixed amount (“*capacity*“) of atoms. It is equal to the horizontal and vertical neighbors of the cell. Therefore,

- the four corner cells each have a capacity of
*2*, while - the other edge cells have a capacity of
*3*, and - center cells have a capacity of
*4*.

Once a cell contains enough atoms so that it would reach its capacity by adding one more atom, it is considered “*critical*“. Adding an atom to a critical cell — ergo making it reach its capacity — makes this cell react (see below).

### Cell Reaction

A cell that has reached its capacity *reacts*, which means that all atoms on the cell are distributed to the (horizontal and vertical) neighbor cells. Since the amount of neighbors equals the capacity, every neighbor cell receives one atom. If a cell that receives an atom is owned by the opponent it is taken over by the player that started the cell reaction, assimilating all opponent atoms in that cell.

If a neighbor cell reaches its capacity during that process, it will react as well, which leads to chain reactions. This is where its name comes from.

### End of Game

The player that conquers all opponent cells wins as soon as the opponent has no cells left.

### Glossary

**Cell**— one of the tiles on the board**Atom**— a token that belongs to one of the players**Neighbor**— a cell that is horizontally or vertically adjacent to another cell**Capacity**— the amount of neighbors for a cell, represents the number of atoms that a cell needs in order to trigger a reaction**Reaction**— the process of distributing all atoms of a cell to its neighbors, this is triggered when a cell reaches its capacity**Critical**— a cell that needs only one additional atom until it reaches its capacity is considered critical**Endangered**— a cell is endangered if it has at least one critical neighbor cell that is owned by the opponent**Active**— a cell is active, if the current player is allowed to place an atom on it (i.e. it is empty or the current player owns it)

# The Chainreaction Domain in jABC4

The Chainreaction scenario is delivered with jABC4 by default. The scenario covers the basic tasks of modeling graphs and comes with a clear goal as well as many preconfigured features that allow for an easy entry and a flat learning curve.

The basic workflow that this domain offers is the creation of a game strategy, which resembles the process that an AI would take in order to evaluate the cell onto which it will place an atom in the next turn.

### Game Strategy

In short, the purpose of a game strategy is simply to evaluate a **single cell** based on the situation of that cell. It will lateron be automatically embedded into a framework, that takes over all other tasks such as considering all cells on the board, switching between players, evaluating winning conditions, reaction of critical cells, etc.

The game strategy will be automatically used for those cells **only**, that the AI is allowed to place upon.

When the game strategy is executed, it will be able to access information about the cell that it is currently evaluating, such as the cells’ position on the board (corner, edge, center) or the amount of critical neighbor cells. Additionally, it can acquire information about the whole board, for example the amount of critical cells on the board or the sum of all atoms owned by a player. Finally, a game strategy may virtually place an atom on the cell that it evaluates currently, in order to take the outcome of this action into account (i.e. the strategy may do a one-step glimpse into the future).

Based on these information, the value of the cell is determined.

### Cell Value

A game strategy evaluates exactly one cell and rates it with an integer. The framework will use the game strategy to assign an integer to every active cell. This number represents the value of the cell. The higher a cell value, the more beneficial the game strategy considers placing an atom onto that cell. The smallest value a game strategy may assigns is a *0,* so that negative cell value will internally be interpreted as a *0*, too.

After the framework has iterated all possible cells and has passed every allowed cell to the game strategy, each cell has been given a cell value *≥ 0*. The cell with the highest cell value will automatically be picked and an atom is placed onto it. After that, the AIs’ turn ends.

If there are multiple cells that have the “same highest” cell value, one of those will be chosen randomly.

The Chainreaction domain is the examplary domain for jABC4 which will be used to introduce the first modeling steps.