# The Goal

The aim of this game is conquer more cells than your opponents by placing villages on a 2D grid.

# Rules

Important Notice: If you don't know Conway's Game of Life, i recommend you to solve this first

The game takes place on a two dimensional grid with width * height cells and periodic boundaries (so that the first row comes after the last and vice versa; same for columns).

Each cell is either neutral or belongs to a player

Each cell is either occupied by a village or empty.

Each village, like cells, is either neutral or belongs to a player.

Every odd round all players simultaneously place up to maxVillages on the grid. A player can only place villages on their own or neutral cell. The villages belong to the respective player, with one exception: If two or more players try to place villages on the same neutral field, they merge into one neutral village

Every even round the following rules are applied (the players do nothing):

- A village dies because of underpopulation if only one or zero villages are found on all eight adjacent cells (the owner does not matter)
- A village dies because of overpopulation if four or more villages are found on all eight adjacent cells (the owner does not matter)
- A new village is born on an empty cell if exactly three villages are found on all eight adjacent cells. The owner(s) of these villages DO matter:
  - The new born cell belongs to the player that owns most of the three adjacent villages. Neutral villages have no impact, but still count for the base rule.
  - If two or more players are have the same number of adjacent villages, the new born village is neutral.
  - If all three adjacent villages are neutral the new born village is as neutral as well.
  - Example 1: 2 Adjacent villages belong to player 1, the 3rd to player 2: The new born village belongs to player 1
  - Example 2: 1 Adjacent village belong to player 1, 1 is neutral, one to player 2: The new born village is neutral
  - Example 3: 1 Adjacent village belong to player 1, 2 are neutral: The new born village belongs to player 1

At the end of every round, each village, that belongs to a player, will conquer the cell

## You win if:

- You are the player with the most owned cells at the end of the game
- Or the player with the most villages, as fallback criteria on a tie

## You lose if:

- You try to place a village on top of another
- You try to place a village on a foreign cell
- You try to place more than maxVillages in a round
- All neutral cells are taken and you don't own a single cell
- Your program prints an odd number of numbers
- Your program prints not only numbers (and spaces and newlines as separators between coordinates and rounds of course)

# Game Input

Init

Line 1: one integer playerCount, you are always player 0

Line 2: two integers width and height

Loop

Line 1: one integer maxVillages telling you how many villages you can place this round

height lines: width character pairs:

1. First (Village): 'E' if the cell is empty, 'N' if the corresponding village on cell is neutral or a digit (player number) when it belongs to a player (0 if yours)
2. Second (Cell): 'N' if the corresponding cell is neutral or a digit (player number) when it belongs to a player (0 if yours)

Output
A single line containing up to maxVillages pairs of integers, separated by space
Constraints
2 <= playerCount <= 4
8 <= width <= 16
height 5 <= height <= 9
3 <= maxVillages <= 5

# Conway's Game of Life

The inventor of Game of Life, the british mathematician John Horton Conway died on 11 April 2020 due to COVID-19. May he rest in peace.

## The story behind Conway's Game of Life, taken from Wikipedia

In late 1940, John von Neumann defined life as a creation (as a being or organism) which can reproduce itself and simulate a Turing machine. Von Neumann was thinking about an engineering solution which would use electromagnetic components floating randomly in liquid or gas. This turned out not to be realistic with the technology available at the time. Stanislaw Ulam invented cellular automata, which were intended to simulate von Neumann's theoretical electromagnetic constructions. Ulam discussed using computers to simulate his cellular automata in a two-dimensional lattice in several papers. In parallel, Von Neumann attempted to construct Ulam's cellular automaton. Although successful, he was busy with other projects and left some details unfinished. His construction was complicated because it tried to simulate his own engineering design. Over time, simpler life constructions were provided by other researchers, and published in papers and books.

Motivated by questions in mathematical logic and in part by work on simulation games by Ulam, among others, John Conway began doing experiments in 1968 with a variety of different 2D cellular automaton rules. Conway's initial goal was to define an interesting and unpredictable cell automaton. Thus, he wanted some configurations to last for a long time before dying, other configurations to go on forever without allowing cycles, etc. It was a significant challenge and an open problem for years before experts on cell automatons managed to prove that, indeed, Conway's Game of Life admitted of a configuration which was alive in the sense of satisfying Von Neumann's two general requirements. While the definitions before Conway's Life were proof-oriented, Conway's construction aimed at simplicity without a priori providing proof the automaton was alive.

Conway chose his rules carefully, after considerable experimentation, to meet these criteria:

1. There should be no explosive growth.
2. There should exist small initial patterns with chaotic, unpredictable outcomes.
3. There should be potential for von Neumann universal constructors.
4. The rules should be as simple as possible, whilst adhering to the above constraints.

The game made its first public appearance in the October 1970 issue of Scientific American, in Martin Gardner's "Mathematical Games" column. Theoretically, Conway's Life has the power of a universal Turing machine: anything that can be computed algorithmically can be computed within Life. Gardner wrote, "Because of Life's analogies with the rise, fall and alterations of a society of living organisms, it belongs to a growing class of what are called 'simulation games' (games that resemble real life processes)."

Since its publication, Conway's Game of Life has attracted much interest, because of the surprising ways in which the patterns can evolve. Life provides an example of emergence and self-organization. Scholars in various fields, such as computer science, physics, biology, biochemistry, economics, mathematics, philosophy, and generative sciences have made use of the way that complex patterns can emerge from the implementation of the game's simple rules. The game can also serve as a didactic analogy, used to convey the somewhat counter-intuitive notion that design and organization can spontaneously emerge in the absence of a designer. For example, cognitive scientist Daniel Dennett has used the analogy of Conway's Life "universe" extensively to illustrate the possible evolution of complex philosophical constructs, such as consciousness and free will, from the relatively simple set of deterministic physical laws, which might govern our universe.

The popularity of Conway's Game of Life was helped by its coming into being just in time for a new generation of inexpensive computer access which was being released into the market. The game could be run for hours on these machines, which would otherwise have remained unused at night. In this respect, it foreshadowed the later popularity of computer-generated fractals. For many, Life was simply a programming challenge: a fun way to use otherwise wasted CPU cycles. For some, however, Life had more philosophical connotations. It developed a cult following through the 1970s and beyond; current developments have gone so far as to create theoretic emulations of computer systems within the confines of a Life board.

# Image Sources

Background made by Comfreak taken from Pixabay
Dog Tag taken from HiClipart

# Ideas (Subject to change, need feedback))

LEAGUES!

1. - Neutral Schemata (some neutral villages exist from the start, maybe in certain patterns)
2. - Claimed Schemata (some non-neutral villages exist or cells belong to players from the start)
3. - maxVillages changes per round
   - "Saving" (not placing) villages will be rewarded (higher maxVillages in the next/following rounds (maybe not 1:1)
4. - Cell properties (permanent, input would have to change)
   - "Plain": No special rules
   - "Ocean": You can't place villages on those. Also no village can spawn there. But some Schemata could place villages on water (Can't despawn, but may affect adjecent cells?)
   - "Island": Unaffected by adjacent villages - and doesn't affect them. A village on an island never dies. They also can't spawn there. But players can place villages on them.
   - "Mountain": You can't place villages on those. But they may spawn there, and the normal rules apply
   - "Forest": Villages are invisible, except for the players who own the cell (or a village on an adjacent cell?) ("fog of war"). Cell owners are visible(?)
   - Introduced one by one in different leagues?
   - ...