private void StoreOriginalRules(GameRules rulesToModify) { this.OriginalMaximumGames = rulesToModify.MaximumGames; this.OriginalPointsToWin = rulesToModify.PointsToWin; this.OriginalStartingDynamite = rulesToModify.StartingDynamite; this.OriginalRules = rulesToModify; }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { if (you.NumberOfDecisions == 0) { int pointsToWin = rules.PointsToWin; you.Log.AppendLine("v10"); _endGamePoints = pointsToWin - _endGameOffset; double calc; foreach (var odd in _tieStreakOddsOrig) { calc = odd.Value > 2 ? (odd.Value * .001 * pointsToWin) / (0.01 * rules.StartingDynamite) : odd.Value; _tieStreakOdds.Add(odd.Key, (int)Math.Round(calc, MidpointRounding.AwayFromZero)); you.Log.AppendLine(string.Format("{0}:{1}",odd.Key, _tieStreakOdds[odd.Key])); } } _hasDynamite = you.DynamiteRemaining > _dynamiteRemainingOffset; _opponentLastMove = opponent.LastMove; Move tieStreakMove = ProcessTieStreakLogic(you, opponent); Move moveStreakMove = ProcessMoveStreakLogic(you); Move endGameMove = ProcessEndGameLogic(opponent, rules); return endGameMove ?? tieStreakMove ?? moveStreakMove ?? GetMyMove(); }
private GameRules ModifyGameRules(GameRules gameRules) { var newRules = gameRules; foreach (var property in gameRules.GetType().GetProperties()) { switch (property.Name) { case "MaximumGames": if (MaximumGames.HasValue) property.SetValue(newRules, MaximumGames.Value, null); break; case "PointsToWin": if (PointsToWin.HasValue) property.SetValue(newRules, PointsToWin.Value, null); break; case "StartingDynamite": if (StartingDynamite.HasValue) property.SetValue(newRules, StartingDynamite.Value, null); break; default: break; } } return newRules; }
// BigBang sample implementation private Move MakeBigBangMove(IPlayer you, IPlayer opponent, GameRules rules) { if (you.NumberOfDecisions < 5) return Moves.Dynamite; else return Moves.GetRandomMove(); }
// Random sample implementation public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { var numberOfDecisions = you.NumberOfDecisions; if (numberOfDecisions <=1) return Moves.GetRandomMove(); return Moves.GetRandomMove(); }
// Cycle sample implementation private Move MakeCycleMove(IPlayer you, IPlayer opponent, GameRules rules) { if (you.LastMove == Moves.Rock) return Moves.Paper; if (you.LastMove == Moves.Paper) return Moves.Scissors; if (you.LastMove == Moves.Scissors) if (you.HasDynamite) return Moves.Dynamite; else return Moves.WaterBalloon; if (you.LastMove == Moves.Dynamite) return Moves.WaterBalloon; return Moves.Rock; }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { Move resultingMove = null; switch (Mode) { case MoveMode.Random: resultingMove = MakeRandomMove(you, opponent, rules); break; case MoveMode.Cycle: resultingMove = MakeCycleMove(you, opponent, rules); break; case MoveMode.BigBang: resultingMove = MakeBigBangMove(you, opponent, rules); break; default: resultingMove = MakeYourMove(you, opponent, rules); break; } return resultingMove; }
// Random sample implementation public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { return Moves.GetRandomMove(); }
public GameRules GetGameRules(GameRules rulesToModify) { StoreOriginalRules(rulesToModify); GameRules rules = ModifyGameRules(rulesToModify); return rules; }
private Move MakeYourMove(IPlayer you, IPlayer opponent, GameRules rules) { Move yourMove = null; try { History.StoreMoves(you, opponent); Analyzer.Analyze(you); if (Analyzer.CurrentConfidence.Equals(Confidence.VeryConfident)) yourMove = Analyzer.BestGuess; else yourMove = you.GetRandomDynamiteMove(); } catch (Exception e) { you.LogError(e); yourMove = you.GetRandomDynamiteMove(); } if (yourMove.Equals(Moves.Dynamite)) yourMove = you.GetDynamiteMove(); else if (yourMove.Equals(Moves.WaterBalloon)) yourMove = opponent.GetWaterBalloonMove(); you.LogLine(" BG: {0} and CC: {1} with {2} dynamite remaining.", Analyzer.BestGuess.ToInitialString(), Analyzer.CurrentConfidence, you.DynamiteRemaining); return yourMove; }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { _ThrowValues.Add(ThisThrowValue); if (you.NumberOfDecisions == 0) { //start of game, let's set it up yo! return Strats.RandomWeighted(new Random(), new Weights() { DynamiteWeight = 0, WaterWeight = 0, PaperWeight = 1, RockWeight = 1, ScissorsWeight = 1 }); } Weights WeightsForThisThrow = new Weights(); _MyMoves.Add(you.LastMove); _TheirMoves.Add(opponent.LastMove); if (you.LastMove == Moves.Dynamite) MyDynamiteUsed += 1; if (opponent.LastMove == Moves.Dynamite) TheirDynamiteUsed += 1; MyActualWeights = Helpers.GetActualWeights(_MyMoves); TheirActualWeights = Helpers.GetActualWeights(_TheirMoves); HarvestPerceivedWeightsByThrowValue(); //not sure I care about this. /*for (int i = 5; i <= 100; i++) HarvestSets(you, opponent, i); */ return Strats.RandomWeighted(new Random(), SetWeights()); }
private Move ProcessEndGameLogic(IPlayer opponent, GameRules rules) { if (opponent.Points > _endGamePoints && _hasDynamite) { if(Moves.GetRandomNumber(2) == 0 && _lastEndGameThrow != Moves.Dynamite) { _lastEndGameThrow = Moves.Dynamite; return ThrowDynamite(); } else { _lastEndGameThrow = null; } } return null; }
public Game(GameRules rules) { _rules = rules; }
Move IRockPaperScissorsBot.MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { return Moves.GetRandomMove(); }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules) { if (!firstTime) { int myMove, opponentMove; myMove = 3; opponentMove = 3; if (you.LastMove == Moves.WaterBalloon) myMove = 0; if (you.LastMove == Moves.Dynamite) myMove = 1; if (you.LastMove == Moves.Rock) myMove = 3; if (you.LastMove == Moves.Scissors) myMove = 4; if (you.LastMove == Moves.Paper) myMove = 5; if (opponent.LastMove == Moves.WaterBalloon) opponentMove = 0; if (opponent.LastMove == Moves.Dynamite) opponentMove = 1; if (opponent.LastMove == Moves.Rock) opponentMove = 3; if (opponent.LastMove == Moves.Scissors) opponentMove = 4; if (opponent.LastMove == Moves.Paper) opponentMove = 5; MyBotLog.addLog(myMove, opponentMove); } else { firstTime = false; remainingThrowTransition = (rules.PointsToWin / 2) + Moves.GetRandomNumber(rules.PointsToWin / 20); startDynamite = (rules.PointsToWin / 30) + Moves.GetRandomNumber(rules.PointsToWin / 20); startDynamite = 0; startWaterBalloon = ((rules.PointsToWin * 2) / 3) + Moves.GetRandomNumber(rules.PointsToWin / 3); return Moves.GetRandomMove(); } // you.Log.AppendLine(myString); // you.Log.AppendLine(String.Format("{0}", MyBotLog.oneTieStats())); you.Log.AppendLine(MyBotLog.getTieStats()); you.Log.AppendLine(MyBotLog.getMyStats()); you.Log.AppendLine(MyBotLog.getOpponentStats()); int history; int dynamite = 0; int water = 0; int singleTiesRemaining, doubleTiesRemaining, tripleTiesRemaining, throwsRemaining; if (remainingThrowTransition > opponent.Points) throwsRemaining = (rules.PointsToWin * 2) - (opponent.Points + you.Points); else throwsRemaining = (rules.PointsToWin - opponent.Points) * 2; singleTiesRemaining = ((2 * throwsRemaining) / 9); doubleTiesRemaining = ((2 * singleTiesRemaining) / 9); tripleTiesRemaining = ((2 * doubleTiesRemaining) / 9); if ((opponent.LastMove == Moves.Dynamite) && (you.LastMove != Moves.Dynamite)) dynaCounter++; else dynaCounter = 0; if (dynaCounter == 3) return Moves.WaterBalloon; dynamiteCheck = 3; waterCounterCheck = 2; history = 5; if (you.LastMove.Equals(Moves.WaterBalloon)) { waterThrown++; if (opponent.LastMove.Equals(Moves.Dynamite)) { waterThrownWins++; } if ((((waterThrownWins * 100) / waterThrown) <= 60) && (waterThrown > 7)) { dynamiteCheck = 5; waterCounterCheck = 5; history = 6; waterCounter = waterCounterCheck; } } if ((MyBotLog.getTies() > 1) || (opponent.LastMove.Equals(Moves.Dynamite) || opponent.LastMove.Equals(Moves.WaterBalloon))) { if (you.NumberOfDecisions >= history) { MyBotLog.analyzeThrow(history, ref dynamite, ref water); if ((dynamite >= dynamiteCheck) && opponent.HasDynamite) { //if ((MyBotLog.getTies() >= 3) || ((rules.PointsToWin / 2) > opponent.Points)) //{ //you.Log.AppendLine(String.Format("{0}: Water Balloon : {1}/{2}", you.NumberOfDecisions, dynamite, history)); if (waterCounter > 0) { //you.Log.AppendLine(String.Format("{0}: oops decrement water counter : {1}/{2}", you.NumberOfDecisions, waterCounter, history)); waterCounter--; } else { waterCounter = waterCounterCheck; return Moves.WaterBalloon; } //} } if (water >= 3) { //you.Log.AppendLine(String.Format("{0}: Random : {1}/{2}", you.NumberOfDecisions, water, history)); return Moves.GetRandomMove(); } } } //if ((you.LastMove != Moves.Dynamite) && ((you.LastMove.Equals(opponent.LastMove)) && you.HasDynamite)) if ((startDynamite < you.NumberOfDecisions) && you.HasDynamite) { //randomNum = Moves.GetRandomNumber(100); if (MyBotLog.getTies() == 2) { //if (((you.DynamiteRemaining * 100) / doubleTiesRemaining) > 40) //{ if (Moves.GetRandomNumber(100) < 40) return Moves.Dynamite; //} //else if (Moves.GetRandomNumber(doubleTiesRemaining + 1) < you.DynamiteRemaining) //{ // return Moves.Dynamite; //} } else if (MyBotLog.getTies() > 2) { //if (((you.DynamiteRemaining * 100) / tripleTiesRemaining) > 40) //{ if (Moves.GetRandomNumber(100) < 40) return Moves.Dynamite; //} //else if (Moves.GetRandomNumber(tripleTiesRemaining + 1) < you.DynamiteRemaining) //{ // return Moves.Dynamite; //} } // randomNum = Moves.GetRandomNumber(singleTiesRemaining + 1); if ((Moves.GetRandomNumber(singleTiesRemaining + 1) < ((you.DynamiteRemaining / 3) +1)) && (MyBotLog.getTies() == 1)) { return Moves.Dynamite; } } return Moves.GetRandomMove(); }