The name of your C program file must be called firetop2.c, files with any other name will not be marked.
The difference on this week's lab is in the rolling of the dice. In last week's lab, both the human and creature have an attack of 2d6; that means we throw two six-sided dice. For this week, the human and creature can have different attacks. The human can have an attack of 2d6, and the creature can have an attack of 1d12 (throwing one twelve-sided dice). In general, an attack consists of mdn, where we throw an n-sided die m times. Your task is to add in this flexibility for the simulation.
6094 100 1 5 1 5 2 6 1 12The explanation for each number as well as their valid ranges are given as follows:
6094 | Random number seed (1-32767) |
100 | Number of simulations (1-100000) |
1 | Human's skill (1-12) |
5 | Human's stamina (1-24) |
1 | Creature's skill (1-12) |
5 | Creature's stamina (1-24) |
2 6 | Human's attack is 2d6 (1-24 for each integer) |
1 12 | Creature's attack is 1d12 (1-24 for each integer) |
Everything else remains the same as last week's lab.
Here is the contents of a sample text file:
6094 100 1 5 1 5 2 6 1 12 6095 1000 1 5 1 5 2 6 1 12 6096 10000 1 5 1 5 2 6 1 12 6097 100000 1 5 1 5 2 6 1 12 7094 100 12 24 12 24 2 6 1 12 7095 1000 12 24 12 24 2 6 1 12 7096 10000 12 24 12 24 2 6 1 12 7097 100000 12 24 12 24 2 6 1 12 8094 100 12 24 12 24 2 6 1 13 8095 1000 12 24 12 24 2 6 1 13 8096 10000 12 24 12 24 2 6 1 13 8097 100000 12 24 12 24 2 6 1 13 9094 100 12 24 12 24 2 6 1 14 9095 1000 12 24 12 24 2 6 1 14 9096 10000 12 24 12 24 2 6 1 14 9097 100000 12 24 12 24 2 6 1 14We will of course test your programs with different test data.
$ gcc -Wall firetop2.c -o firetop2 $ ./firetop2 Seed: 6094, human skill: 1, human stamina: 5 creature skill: 1, creature stamina: 5 human attack: 2d6, creature attack: 1d12 Number of simulations: 100, human victories: 59 creature victories: 40, draws: 1 Percentage of human victories: 59.000% Percentage of creature victories: 40.000% Percentage of draws: 1.000% Seed: 6095, human skill: 1, human stamina: 5 creature skill: 1, creature stamina: 5 human attack: 2d6, creature attack: 1d12 Number of simulations: 1000, human victories: 561 creature victories: 415, draws: 24 Percentage of human victories: 56.100% Percentage of creature victories: 41.500% Percentage of draws: 2.400% Seed: 6096, human skill: 1, human stamina: 5 creature skill: 1, creature stamina: 5 human attack: 2d6, creature attack: 1d12 Number of simulations: 10000, human victories: 5565 creature victories: 4181, draws: 254 Percentage of human victories: 55.650% Percentage of creature victories: 41.810% Percentage of draws: 2.540% Seed: 6097, human skill: 1, human stamina: 5 creature skill: 1, creature stamina: 5 human attack: 2d6, creature attack: 1d12 Number of simulations: 100000, human victories: 56640 creature victories: 41138, draws: 2222 Percentage of human victories: 56.640% Percentage of creature victories: 41.138% Percentage of draws: 2.222% Seed: 7094, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d12 Number of simulations: 100, human victories: 70 creature victories: 30, draws: 0 Percentage of human victories: 70.000% Percentage of creature victories: 30.000% Percentage of draws: 0.000% Seed: 7095, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d12 Number of simulations: 1000, human victories: 657 creature victories: 337, draws: 6 Percentage of human victories: 65.700% Percentage of creature victories: 33.700% Percentage of draws: 0.600% Seed: 7096, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d12 Number of simulations: 10000, human victories: 6738 creature victories: 3207, draws: 55 Percentage of human victories: 67.380% Percentage of creature victories: 32.070% Percentage of draws: 0.550% Seed: 7097, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d12 Number of simulations: 100000, human victories: 65976 creature victories: 33366, draws: 658 Percentage of human victories: 65.976% Percentage of creature victories: 33.366% Percentage of draws: 0.658% Seed: 8094, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d13 Number of simulations: 100, human victories: 56 creature victories: 44, draws: 0 Percentage of human victories: 56.000% Percentage of creature victories: 44.000% Percentage of draws: 0.000% Seed: 8095, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d13 Number of simulations: 1000, human victories: 493 creature victories: 500, draws: 7 Percentage of human victories: 49.300% Percentage of creature victories: 50.000% Percentage of draws: 0.700% Seed: 8096, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d13 Number of simulations: 10000, human victories: 4956 creature victories: 4970, draws: 74 Percentage of human victories: 49.560% Percentage of creature victories: 49.700% Percentage of draws: 0.740% Seed: 8097, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d13 Number of simulations: 100000, human victories: 49627 creature victories: 49749, draws: 624 Percentage of human victories: 49.627% Percentage of creature victories: 49.749% Percentage of draws: 0.624% Seed: 9094, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d14 Number of simulations: 100, human victories: 38 creature victories: 62, draws: 0 Percentage of human victories: 38.000% Percentage of creature victories: 62.000% Percentage of draws: 0.000% Seed: 9095, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d14 Number of simulations: 1000, human victories: 352 creature victories: 640, draws: 8 Percentage of human victories: 35.200% Percentage of creature victories: 64.000% Percentage of draws: 0.800% Seed: 9096, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d14 Number of simulations: 10000, human victories: 3479 creature victories: 6462, draws: 59 Percentage of human victories: 34.790% Percentage of creature victories: 64.620% Percentage of draws: 0.590% Seed: 9097, human skill: 12, human stamina: 24 creature skill: 12, creature stamina: 24 human attack: 2d6, creature attack: 1d14 Number of simulations: 100000, human victories: 35511 creature victories: 63976, draws: 513 Percentage of human victories: 35.511% Percentage of creature victories: 63.976% Percentage of draws: 0.513% $
A total of 6 different hosts have accessed this document in the last 393 days; your host, nsrp-source.comp.nus.edu.sg, has accessed it 3 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.