public MaryBottins() { Dynamite = new Dynamite(); GameplayScores = new GameplayScores(); PredictOpponentMoves = new Dictionary <Move, MovePredictionData>(); PredictMyMoves = new Dictionary <Move, MovePredictionData>(); MoveArray = new[] { Move.R, Move.P, Move.S, Move.W, Move.D }; SuggestMove = new SuggestMove(); foreach (var move in MoveArray) { MovePredictionData p1predictMoves = new MovePredictionData(move); MovePredictionData p2predictMoves = new MovePredictionData(move); PredictMyMoves.Add(move, p1predictMoves); PredictOpponentMoves.Add(move, p2predictMoves); } }
public Move ShouldDynamiteBePlayed(GameplayScores gameplayScores, Move moveToMake) { if (p1Dynamite == 0) { if (moveToMake == Move.D) { return(Move.P); } return(moveToMake); } decimal RoundsBetweenUsage = (1950 - gameplayScores.RoundNumber) / (p1Dynamite); // Calculate the number of rounds between each dynamite if thrown evenly throughout match decimal ProbOfThrowingInv; //decimal RoundsBetweenUsage = 19; //del if (gameplayScores.DrawCount > 0) { double NumberOfDrawsExponent = 1.5; if (p2Dynamite == 0) { NumberOfDrawsExponent = 1.7; } double NumberOfDrawsFactor = 4; if (DynamiteJustThrown) { NumberOfDrawsFactor = 2; } ProbOfThrowingInv = RoundsBetweenUsage / ((decimal)(Math.Pow(gameplayScores.DrawCount, NumberOfDrawsExponent) * NumberOfDrawsFactor)); // Inverse of the probability we are aiming for to throw dynamite. } else if (moveToMake == Move.D) { ProbOfThrowingInv = RoundsBetweenUsage / (decimal)1.2; } else { return(moveToMake); } int RoundedProbabilityInv = (int)Math.Round(ProbOfThrowingInv); int FinalProbability = Math.Max(RoundedProbabilityInv, 1); var rand = new Random(); int pick = rand.Next(FinalProbability); if (pick == 0) { if (ConsecutiveDynamiteCount > 3) { return(Move.W); } return(Move.D); } return(Move.P); }