We will implement a Bandit class for building the logic behind the algorithm:
- Create a new class named Bandit:
using UnityEngine;public class Bandit : MonoBehaviour{ // next steps}
- Define the required member variables:
bool init;int totalActions;int[] count;float[] score;int numActions;RPSAction lastAction;int lastStrategy;
- Define the function for initializing the UCB1 algorithm:
public void InitUCB1(){ if (init) return; // next step}
- Define the local variables and initialize them:
totalActions = 0; numActions = System.Enum.GetNames(typeof(RPSAction)).Length; count = new int[numActions]; score = new float[numActions]; int i; for (i = 0; i < numActions; i++) { count[i] = 0; score[i] = 0f; } init = true;
- Define ...