# Bot Problem Judge

### How a bot game works?

Every bot game is played between Player 1 and Player 2. There is an initial state of the game which is usually fixed for a particular game. The state is represented by some numbers e.g. the state can be represented by a matrix of numbers for grid based games. The game is a series of moves played by Player 1 and Player 2 alternatively which are made until a player wins, loses or game is drawn. It's always Player 1 who makes the first move after game starts. A participant's bot can play as either Player 1 or Player 2. The program submitted by a participant will run for each move played by his/her assigned player in the game.

A player's program is fed the last state of the game and it's player id as input and the program has to output the move which it wants to play. The format of the move is specified in problem statement itself. Then our bot host generates the next state of the game using the move of the player and last state and checks if the game is finished; If the game is not finished then alternate player's program is fed the the generated state and it's player id as input. This goes on until the game is finished.

### How tournament is performed?

Suppose bot event has duration of 5 days, then tournament runs everyday after day 1 and after the challenge ends. The tournament runs everyday so that bot codes submitted one day before can be rated. The tournament starts at pre-defined time each day.

Lets say on 1st day, 3 players (A, B, C) submitted their code. Then in tournament on 2nd day, these submissions will be taken for evaluation. The tournament evaluation system will automatically start creating games on those submissions and the results of these games will be used for rating of the bots. For this example case (where only 3 players submitted their code), 6 games will be played. (3C2 * 2)

G1:  B - A,   G2:  A - B
G3:  C - A,   G4:  A - C
G5:  C - B,   G6:  B - C


After all the games are played, the results of these games (G1 to G6) is sent to rating system. We use Glicko-2 rating system for this. In this rating system initially all bots are given rating of 1500. Then results of games are taken one by one and rating of corresponding bots get changed. When results of all games are taken, every bot gets the final rating for this 2nd day tournament. The score is assigned as the normalization of rating into max score of 100 (score = rating*100/max_rating). After rating of each participant, leaderboard gets updated.

While the tournament runs, participants can change their bot code and new submissions won't affect the tournament running at that time. Suppose a new player D submits a bot and player B changes her code on day 2. Then in tournament on day 3, following games will be played to complete all combination of games (4C2 * 2 = 12).

G7:  B - A,   G8:  A - B
G9:  B - C,   G10: C - B
G11: D - A,   G12: A - D
G13: D - B,   G14: B - D
G15: D - C,   G16: C - D


The results of games (G3, G4, G7 to G16) which are 12 in count, will be taken for rating. The results of games G1, G2, G5, G6 were not taken because these games were played with the old bot submission of player B. Again rating and scores will be assigned to bots on 3rd day.

So here, it's only last bot submission of each participant which affects their position in leaderboard. So after the challenge ends, only last bot submission of each participant affects their position in final leaderboard.

Ques) How can I see my tournament games?
Ans) Go to Tournament tab and click (View my tournament stats) link. There you will see the games which affect your rating.

Ques) Can I see game of anybody?
Ans) Yes, you can see game of anybody (tournament or non-tournament) by clicking the datetime in each row in Games and Tournament page.

Ques) Can I submit bot code while tournament is running?
Ans) Yes, you can submit your bot code while tournament is running. But your this submission won't affect the rating in end of that tournament. It will be taken for rating in next tournament only.

Ques) How often can I submit bot code in a day?
Ans) The participant can change his/her bot code any number of times in a day. On next day, only his/her latest submission will be taken in tournament for rating. Every tournament is independent and the ratings in one doesn't affect the rating in other tournaments.

Ques) What is the significance of player id provided along with the state of game?
Ans) In a game, the player id assigned to two bots are fixed. So while your program is run multiple times in a game to generate new state. The player id which is fed to your program will be constant. It also tells whether you started the game first or second because Player 1 takes the first turn when the game starts.

Ques) How intelligent is Default bot?
Ans) The default bot is a bot code written by us which plays random still valid moves.

Ques) Is it possible to test my bot as 2nd player against other bots?
Ans) Not possible currently. But in the tournament, your bot is played against both as a first player and second player.

Ques) Is there a way for bot code to log things after each move which I can see?
Ans) Yes you can stdout numbers or anything which you want to log after printing the output for move. You will be able to see those logs while game is playing. Please separate log and move by enter character.