Advanced Programming for Games

GitHub Repository

The Safe Problem
Part 1

Specification (what you need to do): You will build a computer program in C++ to demonstrate strategies for constructing a simulation of a multi-lock safe.

  • Create a program that will use randomisation to determine appropriate four digit inputs for each hash function and the ROOT value to generate a valid multi-lock configuration (the hash function inputs should be the same for all multi-lock safes but the number for the root should be different each time).
  • Produce a text file outlining solutions known as the key file. Identify the number of solutions in the file and then list each solution to include the ROOT value followed by the four hash function inputs. This is an example of how you need to structure the file (this is not a valid solution but is used to illustrate file format):

NS 2
ROOT 6789
UHF +1,-4,+2,+5
LHF -4,+5,+2,-1
PHF -2,+3,+2,-3
ROOT 6749
UHF +1,-2,+2,+9
LHF -6,+5,+7,-1
PHF -1,+3,+2,-8

  • Ensure your program can read in a key file and generate the equivalent CN, LN and HN values and output these in a text file (known as the multi-safe file) and identify if each entry is or is not a valid output given the requirements. Each solution should have 5 outputs for CN, LN and HN (one for each combination lock). This is an example of how you need to structure the file (this is not a valid solution but is used to illustrate the file format):

NS1 NOT VALID
CN0 7892, LN0 3446, HN0 1259,
CN1 7892, LN1 3456, HN1 3269
CN2 7292, LN2 3556, HN2 3759
CN3 9892, LN3 3056, HN3 7259
CN4 7892, LN4 3406, HN4 3959

Part 2

Specification (what you need to do): You will extend your computer program from coursework 1 to allow the determination of combinations to unlock multi-lock safes

  • Create a program that will use a method of your choice (without cheating – i.e., looking at the solution held in the associated multi-safe file or key file) to determine appropriate four digit inputs for each hash function (UHF, LHF, PHF) to generate the LN values as displayed in the locked safe file. Once this is achieved the CN values can be easily derived (they are actually derived as a step in this process)
  • Your output should be a multi-safe file (as in coursework 1) showing the solutions and the key file (as in coursework 1) showing how they were derived from the original locked safe file. These can then be checked again for validity using coursework 1
  • Finally, extend your solutions in coursework 1 and coursework 2 to allow a user to specify the number of locks that are present in a multi-lock safe
  • How quickly can your program run?