CNI Hackathon '22 Data Science Challenge AI Challenge Register FAQs
AI Challenge: Fence and Conquer

##### Background
• Fence and conquer is a two player game, where both the players are bots. A color is assigned to each bot.
• There is a grid of square cells of size $$N \times N$$. At the start of the game all the cells are empty.
• When the game starts, the bots are assigned random distinct locations within the grid. These locations get the color of the bot.
• Objective: The objective of a bot is to conquer more cells than its competitor bot.
• Moving within the grid:
• One of the bots gets to make the first move.
• The bots take turns to move a step to the left, right, up, or down within the grid. A bot may also choose not to move.
• At a grid edge, if a bot makes another move towards the edge, it will wrap around and emerge from the opposite edge.
• Conquering cells:
• If a bot moves into an empty cell, the empty cell gets conquered and gets the color of the bot.
• If a bot makes a rectangle such that all the cells within the rectangle are empty, all those empty cells also get 'conquered' and get the color of the bot. Constraint: A bot can only conquer rectangles of size up to $$6 \times 6$$ cells in this manner.
• A bot can move to any cell in the grid, but cannot conquer an already conquered one. That is, if a cell gets colored, it's color cannot be changed even if a bot of different color moves through it.
• Timing constraints:
• There is a 10 second stop clock for each bot. That is, a bot gets 10 seconds of aggregate time to make its moves within a game.
• The clock for a bot stops whenever it waits for the other bot to make a move.
• The bot that runs out of time first, loses the game.
• In case both bots end up conquering the same number of cells in a game, the bot that consumes the least time to make all its moves is the winner.
The videos placed below illustrate the working of fence and conquer. The videos on the left side contain explanations. The ones on the right side provide an uninterrupted view.
Scenario 1: with pauses and voiceover Uninterrupted version (without voiceover)
Scenario 2: with pauses and voiceover Uninterrupted version (without voiceover)

Create a bot that competes with another bot for conquering more cells (area) in a grid.

##### Codebase

• Player1.py and Player2.py: These are some example bots that the participants can use to test against their own bots.
• game.py:
• This code runs games between bots.
• It assumes that the bots Player1.py and Player2.py are competing, and the former makes the first move.
• The participants should rename their bot files as Player1.py or Player2.py, to make their bot compete with Player2.py or Player1.py, respectively.
• For ready reference, the game.py code is listed below (see the comments between lines 1-70):
• The function main() in game.py sets up a competition between the bots Player1.py and Player2.py and prints the number of cells conquered by them once none of the cells within the grid remain unoccupied.
• The output of the function main() prints in the form of a tuple:

(#cells conquered by Player1.py, #cells conquered by Player1.py)

• Additional details related to the above mentioned Python codes:
• The variables board and B represent the grid. Each one of them is a list of $$N=30$$ lists, each containing $$N=30$$ elements, thereby making a $$30\times 30$$ grid.
• Considering the example of the variable board, the following figure illustrates how it represents the grid
(same logic applies for variable B as well):
• Important: Hence, board[x][y] represents the $$y$$-th element (row) in the $$x$$-th list (column) of the variable board.
Same logic applies for the variable B as well.

##### Importance of Strategy

All fence and conquer strategies may not be effective. For example, the following gif shows that the blue bot, which is taking every step in a random direction, is performing worse than the green bot, whose strategy itself is not really great in implementing fence-and-conquer.

##### Submission
• Team size: At most two individuals.
• Programming language: Python (3.5 and beyond)
• Packages: The participants may use Python packages like numpy, math, random, etc. In case the submissions use different packages, we reserve the right to not consider and evaluate them for the Hackathon.
• Step 1: A participant creates a GitHub repository as per the folder structure illustrated in the example below (see image):

where srika_FC_456AB is the GitHub repository and contains the python file Bot.py.
• (We will provide the repository name to each participating individual or team.)

We require the participants to keep their respective repositories private for the duration of the hackathon.

• Step 2 - Build the function move():
The following code snippet (Bot.py) illustrates the structure of the class player and the function move(): In Step 2, the participants build (define) the function move() within the class player present in Bot.py.
The move() function decides the direction in which a bot will move in the next turn.
The decision is based on the strategies to enable the bot to capture more cells as compared to the competitor bots.
• Step 3 (Before the hackathon deadline gets over): A participant adds cnihackathon22 as a collaborator to its GitHub repository, and grants the Read access.

##### Evaluation criteria
• We will fetch the last GitHub commit done before the submision deadline and evaluate it.
• The submissions will be evaluated through a tournament through which the best three performing bots will be chosen as the winners.
• Tournament format: The tournament will be carried out in two stages:
• Group Stage:
• The participant bots will be divided into groups.
• Each bot will play all of the other bots in its group in a round robin format.
• One match between two bots comprises a best-of-five games series.
• An ELO rating will be the used to rank the players at the end of the group stage.
• Initially, all the bots will be assigned an ELO of 1000, which will be updated after every match.
• From every group, the bots with the best two ELO will advance to the finals.
• Finals:
• The format of finals will be same as that in the group stage.
• Each bot will play all of the other bots in a round robin format, a match comprising a best-of-five games series.
• The ELO will get reset to 1000 for each bot at the beginning of the Finals, and will be updated after every match.
• The Jury: We will shortlist 5-6 best performing teams and ask them to present and explain their submissions before a jury.