Monday, July 9, 2012

Game Mechanics

Overview

Bulls and Cows -- also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots -- is an old code-breaking paper and pencil game for two players, similar to Mastermind.
It is a game with numbers that may date back a century or more. It is played by two opponents. The game can also be played with 3 digits instead of 4.  On a sheet of paper, the players each write a 4-digit secret number. The digits must be all different. Then, in turn, the players try to guess their opponent's number who gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Example:
  • Secret number: 4271
  • Opponent's try: 1234
  • Answer: 1 bull and 2 cows. (The bull is "2", the cows are "4" and "1".)
The first one to reveal the other's secret number wins the game. As the "first one to try" has a logical advantage, on every game the "first" player changes. In some places, the winner of the previous game will play "second". Sometimes, if the "first" player finds the number, the "second" has one more move to make and if he also succeeds, the result is even. The secret numbers for bulls and cows are usually 4-digit-numbers, but the game can be played with 3 to 6 digit numbers (in every case it is more difficult than with 4). Objectives
  1. Create a program that can guess a 4 digit secret code composed any of the numbers 0 - 9.
  2. The program must accept a bull feedback and a cow feedback.
  3. The program will continue to guess the 4 digit secret code which can be based on the given feedback on previous attempts until the code is guessed.
  4. The program must stop when the code has been revealed.
Rules of the Game Since we will be using computer programs to break the secret code, the rules will be slightly different and the difficulty level will be increased compared to the original paper and pencil game.
  1. There will only be 1 secret  code that will be randomly generated manually or by a computer program.
  2. The secret code shall be a 4 digit combination composed of any of the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.
  3. The secret code combination can be a repetition of the digit.
Example: secret code: 1111 or 1122 or 2225 or 1999  
  1. The computer program shall attempt to break or guess the secret code by generating 4 digit numbers.
  2. The computer program shall accept 2 inputs for feedback, 1 for "Bulls" and 1 for "Cows".  The feedback will be used to determine the next 4 digit numbers to generate for the next attempt.
  3. If a matching digit is on the right position it is considered a "Bull", if on a different position it's a "Cow".
  4. The computer program shall continue to break the code until the secret number is guessed.  There will be no limit on the number of attempts.
  5. The computer program shall indicate that it has guessed the secret code.
More Rules
  • All teams must be registered before joining the programing competition.
  • This will be a test of analytical skills and algorithm so the team can use any programming language of their choice.
  • The team must provide their own laptop, PC, tablet or iPad to run their program.
  • The teams should check-in their devices and should be in good running condition 1 hour before the start of the competition.
Game Mechanics


  1. The programming competition shall have 2 categories - Student and Professional. 
  2. Individuals or a team of maximum of 3 members can join the competition. 
  3. Participants can use any programming language of their choice. 
  4. Two teams will play in best of 3 match. 
  5. Each team will have a chance to compete with all other teams in a round robin tournament match belonging to the same category. 
  6. The team which has the most number of wins shall be declared champion for that category.