There's more...

Not only it is important to define and balance strategies, but also the results of keeping track of the opponent's actions. That's why we need to implement a member function for adding them into the mix we talked about in the previous section:

public void TellOpponentActionRM(RPSAction action){  lastOpponentAction = action;  int i;  for (i = 0; i < numActions; i++)  {    regret[i] += GetUtility((RPSAction)lastActionRM[i], (RPSAction)action);    regret[i] -= GetUtility((RPSAction)lastAction, (RPSAction) action);  }}

Finally, it's important to balance the strategies and the utility function. It's pretty straightforward for RPS, but it could get as complex as our game.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.