- 69
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
You have to simulate a duel where two simple AI can either cooperate or defect in each turn, and determine which AI has won a duel (earned a higher total reward).If they both cooperate (
If they both defect (
Else, the one that defects earns a reward of t and the one that cooperates earns a reward of f.
For the purpose of this puzzle, these four values will be fixed: c=2, d=1, t=3 and f=0.
Each AI has its own strategy. A strategy is a set of commands, each of which is a condition followed by an action (
This means if the previous action of the opponent is
Else, defect.
Below are the codes used to describe a strategy. They generally follow the global syntax of
(Assume it is the turn for Mya now. The opponent is called Opal.)
•
•
•
•
•
•
Previous action(s) refer to action(s) up to the last turn. For example, in the first turn, if Mya plays first, Opal does not treat Mya's first chosen action as a previous action.
X may be
The very first x = 12, which is not used for the first pseudo-random value.
If the current value in the LCG is x, the next one is 137*x+187 mod 256→x.
If the binary decomposition of the calculated x has an even number of 1, choose
Both AI use the same LCG throughout all the turns.
Input
Line 1: The number of turns
Line 2: The number n of commands for the first AI and its name
Next n lines: The first AI’s strategy
Next line: The number m of commands for the second AI and its name
Next m lines: The second AI’s strategy
Line 2: The number n of commands for the first AI and its name
Next n lines: The first AI’s strategy
Next line: The number m of commands for the second AI and its name
Next m lines: The second AI’s strategy
Output
The name of the winner AI, or DRAW in case of equality, after the specified number of turns have been played
Constraints
Example
Input
100 1 NiceGuy1 * C 1 NiceGuy2 * C
Output
DRAW
A higher resolution is required to access the IDE