Capture the Flag
“Capture the Flag” was a C, C++ Programming competition held as a part of “MindBend 06”, a National Level Technical Symposium held at SVNIT. The competition consisted of a computerized board game where codes from the participants competed against each other. My team won the first prized in this competition.
The board game was basically a 2 player game and consisted of m * n boxes. Some of these boxes possessed flags while some consisted of obstacles and others were empty boxes. The main aim of the game was to capture as many flags as possible. For each flag the player gets 10 points. At the same time if a player is able to capture the other player he gets 30 points. When all the flags have been captured, the player with maximum points wins the game.
Some of the main features that differentiated our code from others and that helped us to win are
A very different strategy as compared to other participants. Our code always tried to predict our competitor’s next move and decided our next move accordingly. For this we adopted the min max theorem of game theory as per our needs. This helped our code never to go for a flag which is being pursued by our competitor and is closer to his player than to us.
While most of the codes basically concentrated on capturing the flags, our code also tried to capture the opponent player. For this our code identified the flags on the board which are surrounded by more than 3 obstacles and marks them as danger flags. This is because when a player captures this flag, he has at most 4 possible moves on his next turn and hence our code has better chance of predicting the opponent next move thus increasing the probability to capture our competitor. Whenever our competitor tries to capture one of the danger flag, our player stops his current activity and moves towards that flag in such a manner that we capture our opponent and get 30 points in the process. This innovative strategy really impressed the judges and was pivotal in helping us to win the first prize.