public int StateMapping(Battle b) { //For our state, we consider: // The agent's health quartile // The enemy's health quartile // The enemy's first type // The enemy's second type (note: if enemy has no second type, // The type of move 1 // The type of move 2 // The type of move 3 // The type of move 4 //With 15 different possibilities for each of these types, our state space's size is: // 15^8 = 2 562 890 625 ~= 10^9 //However, our sample battle will be much simpler // there are only 4 unique enemies (4 possible enemy type combinations) // moves are set in stone, so there is only 1 possible type for each move // thus, our practical state space is much lower than 15^8 //We will use this information to construct a number that represents the state int stateNum = 0; int digitMult = 7; //15; //should keep this the same //Get the opponent's types int agentHealthQuartile = b.GetAgentHealthQuadrant(); int opponentHealthQuartile = b.GetDefenderHealthQuadrant(); List <PokémonAPI.Type> opponentTypes = b.GetDefenderTypes(); int opponentTypeIndex1 = (int)opponentTypes[0]; int opponentTypeIndex2 = opponentTypeIndex1; if (opponentTypes.Count > 1) { opponentTypeIndex2 = (int)opponentTypes[1]; } int move1TypeIndex = (int)b.GetAgentMoves()[0].AttackType; int move2TypeIndex = (int)b.GetAgentMoves()[1].AttackType; int move3TypeIndex = (int)b.GetAgentMoves()[2].AttackType; int move4TypeIndex = (int)b.GetAgentMoves()[3].AttackType; //this structure will help us build the number int currentNum = 0; for (int i = 0; i < 8; ++i) { switch (i) { case (0): currentNum = 0; //opponentHealthQuartile; break; case (1): currentNum = 0; //agentHealthQuartile; break; case (2): currentNum = opponentTypeIndex1; break; case (3): currentNum = opponentTypeIndex2; break; case (4): currentNum = move1TypeIndex; break; case (5): currentNum = move2TypeIndex; break; case (6): currentNum = move3TypeIndex; break; case (7): currentNum = move4TypeIndex; break; default: break; } //Add to the stateNum, multiplied by a certain order of magnitude //Console.Write("state aspect " + i + ": " + currentNum + "; "); stateNum += (int)(currentNum * Math.Pow(digitMult, (double)i)); } Console.WriteLine(); return(stateNum); }
public List <Move> ViableMoves(Battle b) { return(b.GetAgentMoves()); }