Skip to content

Azkellas/a-code-of-ice-and-fire

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Code of Ice and Fire

A Code of Ice and Fire game preview

This repository contains the referee for the A Code of Ice and Fire challenge, a turn-based strategy game opposing two AIs. Players have to create their own AI on CodinGame's platform and submit it to the contest, during a 10-day period. AI are then ranked according to their performance against other players' AI using the trueskill algorithm.

CodinGame is a platform for developers to learn and improve their coding skills by solving puzzles and participating in contests. The platform provides a large variety of programming languages and frameworks to solve the puzzles and participate in the contests.

Want to participate ? You can still submit an AI here. If you don't know how to start, feel free to use one of the starter AIs in the starter kit.

The game was created by Azkellas and Tehelka.

Acknowledgements

We would like to thank the testers aCat, csj, nanosplitter and Zenoscave. Many thanks to CodinGame for the support which made this contest possible. We also want to thank the community for their feedback and their participation in the contest.

Rules

The Goal

Build armies to defeat your opponent by destroying their headquarters.

The Map

The map is a grid of size 12x12, where the top-left corner is the cell (0,0). The map is randomly generated at the start of each game.

Both players start with headquarters (HQ) from opposite edges of the map ((0,0) and (11,11)).

A map cell can be either:

  • void (#): not a playable cell.
  • neutral (.): doesn't belong to any player.
  • captured (O or X): belongs to a player.
  • inactive (o or x): belongs to a player but inactive.

Territory ownership

Throughout the game, each player will capture cells to enlarge their territory. A player territory is composed of all the cells owned by the player that are active.

A cell is said to be active if and only if the cell is connected to the headquarters. That is, there exists a path of owned cells from the headquarters to this cell.

The red territory is composed of 6 cells. The 3 red-dark cells are now inactive because the blue player interrupted part of this territory. By capturing, for example, the cell marked by an X, the red player can make these cells active again.

Income

At the beginning of each turn, a player gains or loses gold based on their income. A player has +1 income for each active cell owned.

Every turn, army units cost some income (upkeep).

  • Level 1 units reduce income by 1 per unit.
  • Level 2 units reduce income by 4 per unit.
  • Level 3 units reduce income by 20 per unit.

Players has +4 income for each mine they control.

If a player has negative income and cannot pay their upkeep using their gold, all of the player's units die and the player's gold is reset to 0.

Buildings

Players can BUILD buildings to improve their economy or military power. A player can only build on owned active cells that are unoccupied.

Players can build two different buildings: the MINE and the TOWER.

  • MINE: mines produce gold each turn and can only be built on mine spots. Mines cost 15. A mine's income is always +4.
  • TOWER: towers protect owned cells that are adjacent (up, down, left and right, but not diagonally). Cells protected by a tower can only be reached by enemy units of level 3. Likewise, the tower can only be destroyed by a level 3 unit. A tower costs 15 gold to build and cannot be built on a mine spot. Here is a figure of a tower protection range:

The tower owned by the red player protects the adjacent cells marked by a black cross. Cells are not protected diagonally. Moreover, the blue cell on the right of the tower is not protected as it is not a red cell.

If a building is on an inactive cell, it is not destroyed; it is just inactive.

Armies

Army units can move to capture cells and to destroy opponent's buildings and units.

Army units of different levels (1, 2 or 3) can be trained using the command TRAIN level x y. The target cell (x,y) must be in the player's territory or its direct neighbourhood (adjacent cells).

Army units can only destroy units of inferior level, except level 3 units which can destroy any unit.

Towers can only be destroyed by level 3 units.

Only level 3 units can be trained or moved on a cell protected by an opponent tower.

Each unit can only move one cell per turn by using the command MOVE id x y.

It's not possible to train or move on a cell with a friendly building or unit on it.

An army unit cannot move on the same turn it's trained.

When using MOVE id x y, if the distance between the unit and the target coordinates (x,y) is greater than 1, the unit moves towards the target.

To train a unit or move it on an enemy unit or building, the attacking unit must be able to destroy the defending unit or building. If so, the attacking unit always survives. Else, the action is invalid; nothing happens.

If a unit is on an inactive cell at the beginning of a turn, the unit is instantly destroyed.

Level 1 2 3
Recruitment cost 10 20 30
Upkeep 1 4 20
Can kill units level - 1 1, 2, 3
Can destroy Mines
HQ
Mines
HQ
Mines
Towers
HQ

Order of actions

All actions are processed sequentially. Invalid actions are ignored.

Full rules (explaining input/output format) are on the game's page when you participate.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published