You are on page 1of 8

Battle City Prelims

Deadline of Submission : 10 Dec 2011

For quick response contact : ANKIT MAHATO (+91) 9532094890 ankmahato@gmail.com

Rules : The Prelims comprises 2 questions. The maximum marks of each question are given in the brackets. You can use any language listed below to answer these questions : o C (gcc) o C++ (g++) o Java o Python (2.5/2.6/2.7) The input-output format for each question is given. Strictly stick to it. If you are using another method then do inform the coordinators. The code for each question should be enclosed in a zip file along with a readme which tells us about your solution approach. In each and every respect the decision of the coordinators shall be final. Mail the solutions to swcorner@techkriti.org with subject as <Team Name>_BattleCityPrelims

Q1. Design AI of a Tic-Tac-Toe Game. The board in plain text is : -|-|-|-|-|-|The first move is random. It can be started by a player. It can be started by computer. Your aim is to develop the best possible AI for the computer. Sample Input-Output : Player Begins -|-|-|-|-|-|23 -|-|-|-|x -|-|-|-|-|o|x -|-|33 -|-|-|o|x -|-|x

[20 marks]

#note : player has been picked to start

#note : player enters 2nd row 3rd column

#note : # computers # move

-|-|o -|o|x -|-|x 21 -|-|o x|o|x -|-|x -|-|o x|o|x o|-|Computer Wins! There can be two other cases: Player Wins! Draw!

Q2

[30 marks]

From a file named map.txt read a arena. The arena has the following format : # denotes walls of arena 0 denotes movable spots of the arena E denotes the entry point X denotes the exit point P denotes path taken by robot An arena can at maximum be a 500x500 characters grid. Sample arena:

#E################## #000000000000000000# #000000000000000#### #000000000000000000# #000000000000000000# #0000000###00000000# #000000000000000000# #000###000000000000# #000000000000000000# ##################X#

Your task is to write a code which can read the arena and perform necessary calculations to come up with a route from E to X. Obviously the routes cannot pass through the walls. Movements are allowed in all 8 directions (horizontally, vertically and diagonally) Many paths are possible as shown below:

#E################## #P00000000000000000# #P00000000000000#### #P00000000000000000# #P00000000000000000# #P0000000###0000000# #P00000000000000000# #P000###00000000000# #PPPPPPPPPPPPPPPPPP# ##################X#
Path where the robot travels hugging the wall on left.

#E################## #PPPPPPPPPPPPPPPPPP# #00000000000000P#### #00000000000000PPPP# #00000000000000000P# #00000000###000000P# #00000000000000000P# #0000###0000000000P# #00000000000000000P# ##################X#
Path where the robot travels hugging the wall on the right.

#E################## #0P0000000000000000# #00P000000000000#### #000P00000000000000# #0000P0000000000000# #00000P00###0000000# #000000PPPPPPPPP000# #0000###00000000P00# #0000000000000000P0# ##################X#
Path where the robot takes one of the shortest path possible.

Input: We will supply our own map.txt file which will have test arena different from the one given above. Output: You will get points to output the arena along with the path taken by your bot. Also output the number of P in your path (moves) You will get maximum points for printing the shortest possible path.

You might also like