code warrior - copy

6
  CODE WARRIORS Game Of Thrones Hazraat! Hazraat! Hazraat!  Gangs of CyberQuest are back: this time to take control over the entire kingdom. The fight is between Ramadhir Singh and Sardar khan. But there is a twist in the story. Sardar khan has no intention of shooting Ramadhir Singh, his motto is  Goli nahi ma renge use , Gh er k lenge u ski” . So he has decided to surround the maximum open area in the city as well as the area acquired by the followers of Ramadhir Singh. Since these followers only follow the most powerf ul , they change their liability to one with the maximum power(are a). Ramadhir singh is also doing the same. Now there can only be one king so whoever gets the maximum area ultimately will win the war. So it  s time for all the “CYBER PIAs”  to get ready with their player and prove the saying  DFS ka, BFS ka, GREEDY ka sab ka use karega tera yeh PLAYER” . Introduction: Game of Thrones is a board game involving abstract strategy and played by two players on a board with 19 rows and 19 columns and a set of distinct pieces for each side. Pieces typically are disks with a red and a blue coloured face, each colour belonging to one player. The player's goal is to have a majority of their coloured pieces showing at the end of the game either by converting the opponent pieces into their own colour or by covering uncovered area by forming a closed loop. Game Rules:

Upload: rajatpratapsingh

Post on 01-Mar-2016

223 views

Category:

Documents


0 download

DESCRIPTION

code warrior

TRANSCRIPT

Page 1: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 1/6

CODE WARRIORS

Game Of Thrones

Hazraat! Hazraat! Hazraat!  Gangs of CyberQuest are back: this time to take controlover the entire kingdom. The fight is between Ramadhir Singh and Sardar khan. Butthere is a twist in the story. Sardar khan has no intention of shooting Ramadhir Singh,his motto is

“ Goli nahi ma renge use , Gher k lenge uski” .

So he has decided to surround the maximum open area in the city as well as the areaacquired by the followers of Ramadhir Singh. Since these followers only follow the mostpowerful , they change their liability to one with the maximum power(area). Ramadhirsingh is also doing the same. Now there can only be one king so whoever gets themaximum area ultimately will win the war. So it ’ s time for all the “CYBER PIAs”  to getready with their player and prove the saying

“ DFS ka, BFS ka, GREEDY ka sab ka use karega tera yeh PLAYER” .

Introduction:

Game of Thrones is a board game involving abstract strategy and played by twoplayers on a board with 19 rows and 19 columns and a set of distinct pieces for eachside. Pieces typically are disks with a red and a blue coloured face, each colour

belonging to one player. The player's goal is to have a majority of their coloured piecesshowing at the end of the game either by converting the opponent pieces into their owncolour or by covering uncovered area by forming a closed loop.

Game Rules:

Page 2: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 2/6

1) The board has 19 rows and 19 columns . The rows are named from 'A' to 'S' fromtop to bottom. The columns are named 'A' to 'S' from left to right.

2) Each time the player is given its colour followed by 19 X 19 board -

Example

BlueXXRBBXXXBXXXXXBXRXXXXXXXXXBXXXXXXXXXXXXXXXBXXXRXXXXXXXXXXXXXXBXXXXXXXXRXBXXXRXBXXXXRXXXXXXXXXXXXXXRXXXXXRXBXXXXXXXXXXXRXXXXBXXXXXXXXXXBXXXXXXXXRXXXXXXBXXXXXXXXRXXXXXXXXXXX

XBBXXXXXXXXXXXXXXXXXXXXXXXXXXXXRXBXXXBXXRXRBXXXXXXXXXXXRBXXXXXXXXXXXXXXBRXRXXXXBBXXXXXXRXXXXXBXXXRXXXXBXXXXXXXXRXXRXXRXRBXXXXXXXXBRXBXXXXXBXRXBXXXXXXXXBXXXRXXXXXXXXRXXRXRBXXXBXRXBXXXXXRRXRXX

The first line of input can contain one of two strings either “Blue” or “Red”• denotingthe colour of the move which the player has to make. After that 19 X 19 boardcontains only 'X' or 'R' or 'B' character where 'X' denotes empty position . 'R' denotesthat Red coloured disk is at that position and 'B' denotes that Blue coloured disk ispresent at that position .

3) Player is supposed to generate a move to any one of the empty position according tohis strategy. The output should contain 2 characters , the first one denotes the rownumber and the second one denotes the column number.

ExampleoutputAD

Above output denotes that player makes a move to row number 'A' and column number'D'.

Page 3: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 3/6

4) If a player makes a closed loop then all the disks lying inside the closed regionwhether it is of opponent's colour or empty location will get coloured with the colour ofthe player making loop.

Closed Loop :  A closed polygon formed by joining the vertices of same colour . Here

disk is considered as a vertex. A vertex could be joined to any of its adjacent left , right, above , below or diagonal vertex.

What I have to do ?

  You have to think of a strategy  to play the game and code it so as to beat theopponent player by maximizing the disks of your colour on the board.

  You can use either C/C++ language to implement your strategy.

 Judging rules:

1. A program is simply disqualified and opponent is declared winner if any of

following conditions holds:  An invalid move is generated by program which includes making a move to

position which is non-empty or generating a move containing characters orcharacter other than 'A' to 'S' .

  When program generates output containing either more than 2 characters orless than 2 characters.

  If a player takes more than a maximum of two seconds from last input togenerate the next move.

  Program terminated pre-maturely by any reason.

2. The game will be finished when

 

All board places are filled.In the above condition the player having maximum number of disks will be declaredwinner.

Test Cases:

Input :

BlueXXRBBXXXBXXXXXBXRXXXXXXXXXBXXXXXXXXXXXXXXXBXXXRXXXXXXXXXX

XXXXBXXXXXXXXRXBXXXRXBXXXXRXXXXXXXXXXXXXXRXXXXXRXBXXXXXXXXXXXRXXXXBXXXXXXXXXXBXXXXXXXXRXXXXXXBXXXXXXXXRXXXXXXXXXXXXBBXXXXXXXXXXXXXXXXXXXXXXXXXXXXRXBXXXB

Page 4: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 4/6

XXRXRBXXXXXXXXXXXRBXXXXXXXXXXXXXXBRXRXXXXBBXXXXXXRXXXXXBXXXRXXXXBXXXXXXXXRXXRXXRXRBXXXXXXXXBRXBXXXXXBXRXBXXXXXXXXB

XXXRXXXXXXXXRXXRXRBXXXBXRXBXXXXXRRXRXX

output:SA

Input :

RedXXRBBXXXBXXXXXBXRXXXXXXXXXBXXXXXXXXXXXXXXXBXXXRXXXXXXXXXXXXXXBXXXXXXXXRXBXXXRXBXXXXRXXXXXXXXXXXXXXRXXXXXRXBXXXXXXXXXXXRXXXXBXXXXXXXXXXBXXXXXXXXRXXXXXXBXXXXXXXXRXXXXXXXXXXXXBBXXXXXXXXXXXXXXXXXXXXXXXXXXXXRXBXXXBXXRXRBXXXXXXXXXXXRBXXXXXXXXXXXXXXBRXRXXXXBBXXXXXXRXXXXXBX

XXRXXXXBXXXXXXXXRXXRXXRXRBXXXXXXXXBRXBXXXXXBXRXBXXXXXXXXBXXXRXXXXXXXXRXXRXRBBXXBXRXBXXXXXRRXRXX

output:SB

Explaination of closed loop

Case1: Since white disks surrounds black , forms a cycle

or closed loop as a result all the inner disks get coloured

with white colour.

Page 5: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 5/6

  ----------------- 

Case 2: Here black disks form closed outer loop in first

fig. (consider diagonal case) . The second one is

resultant figure.

------------------ 

Case3:Similar to above cases , here white balls form

closed loop.

----------------- 

Page 6: Code Warrior - Copy

7/18/2019 Code Warrior - Copy

http://slidepdf.com/reader/full/code-warrior-copy 6/6

 

CyberQuest presents Code Warriors