So the assignment is to make a Rock Paper Scissors Spock Lizard Player that plays against another student's player without using any Random generation for 100000 trials. We are supposed to be able to detect the patterns/sequences in the other player by storing their past moves and looking for any repeating sequences.

I'm doing a code in which I store the past moves in a two-dimensional array (but i don't really find a use for the second dimension?), and I keep checking if there is any repeating sequences within the past moves every time as the number of trials increase. But my code is piling up, **I want to put it in a loop in which I can just run it for the number of turns that has happened.**

Here's the part where I do the check, it's a lot of coding and I'm trying to figure out a way to compress it. **Also, is there any way to store the past opponent moves using perhaps multi-dimensional arrays?** Apparently, the teacher said that it would be good if we could do that, but I couldn't really think of a way in which it could be useful.

```
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-2][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-3][0]))
{
return 1;//one repeating move
}
if (turnNumber>=4)
{
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-3][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-4][0]))
{
return 2;//two moves switching back and forth
}
if (turnNumber>=6)
{
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-4][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-5][0])
&&(pastOppMoves[turnNumber-3][0]==pastOppMoves[turnNumber-6][0]))
{
return 3;//three moves switching back and forth
}
if (turnNumber>=8)
{
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-5][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-6][0])
&&(pastOppMoves[turnNumber-3][0]==pastOppMoves[turnNumber-7][0])
&&(pastOppMoves[turnNumber-4][0]==pastOppMoves[turnNumber-8][0]))
{
return 4;//four moves switching back and forth
}
if (turnNumber>=10)
{
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-6][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-7][0])
&&(pastOppMoves[turnNumber-3][0]==pastOppMoves[turnNumber-8][0])
&&(pastOppMoves[turnNumber-4][0]==pastOppMoves[turnNumber-9][0])
&&(pastOppMoves[turnNumber-5][0]==pastOppMoves[turnNumber-10][0]))
{
return 5;//five moves switching back and forth
}
if (turnNumber>=20)
{
if ((pastOppMoves[turnNumber-1][0]==pastOppMoves[turnNumber-11][0])
&&(pastOppMoves[turnNumber-2][0]==pastOppMoves[turnNumber-12][0])
&&(pastOppMoves[turnNumber-3][0]==pastOppMoves[turnNumber-13][0])
&&(pastOppMoves[turnNumber-4][0]==pastOppMoves[turnNumber-14][0])
&&(pastOppMoves[turnNumber-5][0]==pastOppMoves[turnNumber-15][0]))
{
return 6;
}
}
}
}
}
}
```

*Edited 5 Years Ago by flyingcurry*: n/a