private static int[][] SelectEfficiencyTable(GameManager.Player controllingPlayer, Ball.BallPosition ballPosition) { if ((controllingPlayer == GameManager.Player.B) && (ballPosition != Ball.BallPosition.PlayerAField)) { return(case1); } else if ((controllingPlayer == GameManager.Player.B) && (ballPosition == Ball.BallPosition.PlayerAField)) { return(case2); } else if ((controllingPlayer == GameManager.Player.A) && (ballPosition != Ball.BallPosition.PlayerBField)) { return(case3); } else if ((controllingPlayer == GameManager.Player.A) && (ballPosition == Ball.BallPosition.PlayerBField)) { return(case4); } else { Debug.LogWarning("No efficiency table was selected for he AI. Returning default table"); return(case1); } }
public static Card SelectCardToPlay(string AILevel, List <Card> AIhand, List <Card> deckPlayer, GameManager.Player controllingPlayer, Ball.BallPosition ballPosition) { if (AILevel == "Hard") { Card selectedCard = null; int cardEfficiency; int bestEfficiency = -1000; int[][] efficiencyTable = SelectEfficiencyTable(controllingPlayer, ballPosition); foreach (Card cardHand in AIhand) { // Rank one is a special case if (cardHand.GetRank() == 1) { cardEfficiency = SelectRankOneEfficiency(); } else { cardEfficiency = CalculateEfficiency(cardHand, deckPlayer, efficiencyTable); } if (cardEfficiency > bestEfficiency) { bestEfficiency = cardEfficiency; selectedCard = cardHand; } } return(selectedCard); } // On easy mode return a random card from the hand return(AIhand [Random.Range(0, AIhand.Count)]); }