Ah I found my mistake. This part of the instruction gave me the clue excluding the current turn
When checking the previous action I was also taking last action, also if it was generated this round. For example if player 2 needs to check the actions of the opponent should you also look at the action generated in current round or not?
After only taking previous (completed) rounds in account my code worked.
I agree, that although I had fun solving this puzzle, it’s one of the hardest in the easy category.
Hello, i’m trying to solve the puzzle and i have some questions about it.
I don’t understand well how to calculate the random number , i get the formula 137*x+187 mod 256→x. but i don’t know what is x.
Can you provide me an example ?
Secundo what is exacly the number of turn for a game? each player seems to have diffrerent length of action list…
No X is initialised with a value as described in the description of the RAND action.
Regarding the turns, you need to output The name of the winner AI, or DRAW in case of equality, after the specified number of turns have been played. So 100 in this example.
Hello, I need some help to make the random generator usable.
Actually for the “Two jokers” test i always obtain a draw.
My random generator is aways producing the same sequence of number. It leads to the same actions for both player for each turn, resulting in the exact same actions and obviously the same score .
Here is a little extract of my code in order to have a better understanding of my concern.
int[] randomNumbers = new int[nbturns];
randomNumbers[0]=12;
int i=1;
while(i <= currentTurn){
randomNumbers[i]= ((randomNumbers[i-1] * 137) + 187) % 256;
i++;}
in my opinion, i have to choose a different number for each of the players in the randomNumbers[] sequence array. The thing is that i don’t know which number to choose or how to choose one in order to apply the binary transformation that’s comming next to obtain different actions for joker1 and joker2.
It looks like you generate a random number for each turn in advance. You only need to calculate a random number if you need one. So the value is always different.
Hello leonar,
I totaly agree with you, i allready tried that with the same result.
Particularly for the joker test because i generate a number for both player at the same turn.
In fact as my very first x is always 12 randomNumbers[0]=12on each turn. Both random numbers are the same then.
As i want the random numbers to change each time i do the calculation. The only way i see is to change that very first x each time i want a new random number. Or to pick another number in the randomNumber array
The thing is that i can’t find out what value i should use for this very first valueof x neither the number i have to pick in the sequence ?
Thank you
Consider the random number generator x as a sequence.
x[0]=12 and is not used. Then compute x[1]=137*x+187 mod 256 and use x[1], then x[2]=… and so on.
Thank you, finaly i understood what you mean. it works now, the test are passing… I still have to work on the validation for not “so nice…”.
i think i have to implement all the actions possible for all the player.