You are on page 1of 10

AI Battlefield

- Gamers invited
.AI Battlefield presents the game of Football. The game is a turnbased game like Chess, Go, etc. where each team (team A and team B) moves its players and kicks the ball during its turn, the object of the game being same as normal football, i.e. scoring maximum goals. Each participant code is supposed to develop a strategy and play the game for his team

Football Ground
The ground is a 21 x 11 matrix type area. Player Position: The players can be positioned at the corner of the squares, i.e. from corner 1 to 264. Ball Position: The ball is placed inside a square, whose position is identified by top-left corner number of the square, i.e. ball can be positioned in the squares 1 to 11, 13 to 23, 25 to 35, , 241 to 251. Note that the ball cannot be positioned in 12, 24, 36, 48, 60, ..., 240 and 252 to 264. Goal Post: When the ball enters the position 4 to 8 a goal is scored. Similarly, when the ball enters 244 to 248 a goal is scored. Goal Post
11 23 12 24 36 48 60 72 84 96
108 120 132 144 156 168 180 192 204 216 228 240 250 254 255 262 251 263 252 264

2 14 26

3 15 27 16 17 19 20 21

10 22

Number Identifying Positions

13 25 37 49 61 73 85 97
109 121 133 145 157 169 181 193 205 217 229 241 253

Football Ground

Initial Position
The following figure has players for the two teams, and the ball placed for reference. The position also forms the initial position of the game.

1 13 25 37 49 61 73 85 97
109 121 133 145 157 169 181 193 205 217 229 241 253

2 14 26

3 15 27 16 17 19 20 21

10 22

11 23

12

36 48 60 72 84 96
108 120 132 144 156 168 180 192 204 216 228 240 250 251 263 252 264

254

255

262

Initial Position

Ball Position : 126 Player Position : Team A (Yellow circles): Players: {77, 80, 99, 106, 126, 127} Goalkeeper: {18} Team B (Blue circles) : Players: {138, 139, 159, 166, 185, 188} Goalkeeper: {246}

Game Rules
The game proceeds as follows 1. There are total of 150 turns per team. 2. During one turn the team can: a. Move 0 or 1 or 2 players (how to move players is explained in pt 3). b. After moving the players, the ball can be kicked (how to kick the ball is explained in pt 4). 3. Player Move: A player can move horizontally / vertically / diagonally up to maximum of 7 steps. The player can move forward or backward. However, neither player nor goalkeeper can jump over other players, i.e. he can move till he encounters other player. However, goalkeeper can move horizontally only, i.e. in his original row only. Another restriction is that in a single turn, the sum of the two players moving should not exceed total of 10 steps. Goalkeepers move is taken into consideration while calculating the sum. For example: As shown in the figure below, the player at 126 can move in positions indicated by cross marks.

1 13 25 37 49 61 73 85 97
109 121 133 145 157 169 181 193 205 217 229 241 253

2 14 26

3 15 27 16 17 19 20 21

10 22

11 23

12
24

36 48 60 72 84 96
108 120 132 144 156 168 180 192 204 216 228 240 250 251 263 252 264

254

255

262

Player Movement

4. Kicking The Ball: After moving the players, the team can kick the ball. The
ball moves in horizontal / vertical / diagonal fashion in both forward and backward directions. The ball can be kicked only if there is at least one player of your team surrounding it. The ball can be kicked over squares less than or equal to kick strength, which is given by, Kick Strength = Modulo ((2 * m) - n) where m = number of players of your team n = number of players of opponent team At any moment, 0 <= Kick Strength <= 8. Note that the players move in the same turn is taken into consideration for calculating the kick strength for kicking the ball. Also, ball can jump over the players to move to next squares. In the figure below, the yellow team can kick the ball in the cross mark shown. Thus, the ball can be kicked to one of the following squares {100, 102, 104, 113, 114, 115, 124, 125, 127, 128, 137, 138, 139, 148, 150, 152}

1 13 25 37 49 61 73 85 97
109 121 133 145 157 169 181 193 205 217 229 241 253

2 14 26

3 15 27 16 17 19 20 21

10 22

11 23

12
24

36 48 60 72 84 96
108 120 132 144 156 168 180 192 204 216 228 240 250 251 263 252 264

254

255

262

5. Special Rules:
** After the end of a turn the ball cannot be into the square surrounded by four players of same team. ** If any illegal move is made (like ball is kicked outside the ground, or player is moved to illegal square) then the entire turn is taken as illegal and no change is made to the state of the game, and the team loses the chance to play for that turn. ** If any team tries to move players of the opponent team, then that team will be disqualified directly. ** Each participant code is given maximum of 4 seconds per turn to play, failing to play the turn in 4 seconds the team will lose that turn.
.

Scoring Goals:
Team B can score goal if they can place ball in any of the squares {4, 5, 6, 7, 8} Likewise, team A can score goal if they can place ball in any of the squares {244, 245, 246, 247, 248}. After a goal is scored, the initial position is restored, and the game continues with the team with the next turn.

Goalkeeper:
The goalkeeper is allowed to move horizontally only, i.e. in its starting row only. When the ball is kicked towards the goal, the goalkeeper can save the goal, if it is passing through the two squares in front of him. For example: If B kicks the ball from the square 41, with kick strength 4, with the route, 41-29-17-5, the goalkeeper comes into play he grabs the ball when it passes through the square 17. Thus, B cannot score through that route. However, if route chosen is 41-30-19-8, B scores the goal as the goalkeeper cannot save the goal.

1 13 25 37 49 61 73 85 97
109 121 133 145 157 169 181 193 205 217 229 241 253

10

11

12
24

36 48 60 72 84 96
108 120 132 144 156 168 180 192 204 216 228 240 252 254 255 262 263 264

Winning / Losing Conditions:


1. At the end of 150 turns, the team scoring more goals wins the game. 2. If the scores are level, then both teams are given 25 turns more as extra time. The team, which scores first, wins the game. If still there is a tie, the team in whose half the ball remains for more number of moves, that team loses. 3. If the tie is still not resolved, the team making minimum number of illegal moves, wins the game.

Coding Conventions
Programming Language: C Environment: The program will run on Fedora Core 1.0 (gcc compiler). Interface with our system: Your code will have access to two global variables: 1. int battlefield[22][12]; /* represents state of game */ 2. int whoseTurn; /* represents team to play */ All you are required to do is write a function that plays its move by making corresponding changes in the array battlefield. Function Signature: void <function name>(void); The function name should be the login_id of the first person of the team. At the end of every turn your code is supposed to make changes to the array battlefield[][] to move the players and the ball. We will verify the changes and pass the state of the game to other participant code. Example: 1. whoseTurn = 1 indicates your code is supposed to play for Team A whoseTurn = 2 indicates your code is supposed to play for Team B 2. The state of the game is represented by a 22 x 12 integer array battlefield wherein each array element represents corner position(refer to earlier diagrams) that can be occupied by players. For simplicity, even ball is represented in the same elements of the array. Thus, ball can occupy any position in the array except the positions battlefield[020] [11] and battlefield[21][011] (since the ball cannot be identified by numbers 12, 24, 36, , 252 and 253, , 264). Thus, a particular element of the array could be: either empty or with player in it or both player and ball in it. In this array following representations are used: battlefield[22][12] Number Meaning 0 Empty spaces in the field 11 Goalkeeper of Team A 12 Player of Team A 13 Player of Team A 14 Player of Team A 15 Player of Team A 16 Player of Team A 17 Player of Team A 21 Goalkeeper of Team B 22 Player of Team B 23 Player of Team B 24 Player of Team B 25 Player of Team B 26 Player of Team B 27 Player of Team B 100 Ball
. . .

When an element contains 1. No Player and No Ball, it is represented by 0. 2. A Player, it is represented by player number. 3. The ball is represented by 100. 4. A Player and Ball, it is represented by sum of player number (11... 17, 21...27) and 100 (used to represent ball).

24 18

As an example of the array representation, the initial position of the game is represented as follows battlefield [22] [12] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 116, 26, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

Note: The entry 116 implies both player 16 and ball are present in that square. Depending on which team has to play (A or B found by whoseTurn integer), the participant code is just expected to alter the above array by making legal player moves and then kicking the ball.

Restrictions:
While coding, the participants should note the following points 1. Usage of malicious / system crashing code will disqualify the participant team directly. For example Routines like system, popen, fork, exec, execlp, execvp, gets etc. should not be used. 2. Usage of preprocessor directives will disqualify the participant team directly. 3. Usage of recursive functions is should be avoided. 4. Memory allocations should be done using a special function myAlloc ( do not use malloc, allocmem, calloc, coreleft, farcalloc, farmalloc, free, realloc etc ) Function Signature : void * myAlloc( unsigned int ) ; You will be provided this function. Environment includes an inbuilt garbage collector (so no need to use free routine in your function) 5. Teams having identical source code will be disqualified. 6. Each participant code is given maximum of 4 second per turn, failing to play the turn in 4 seconds that team will lose that turn. All the codes should be mailed to aibattlefield@technovanza.org by 1800 hrs on 18th August, 2006. The email should have: Subject: AI Battlefield. Inside the mail: Login ids of the participants in the team. Attachment : <login id.c>(login id of first team member). In case of any queries you can always contact us at aibattlefield@technovanza.org Or call us at : +91 9869000547 (Raj Parakh) +91 9819794514 (Nilesh Yadav)

You might also like