public static void Main(string[] args) { if (args.Length == 3) { string redAI = args [0]; string blueAI = args [1]; int count = int.Parse(args [2]); Random stream = new Random(); Engine engine = new Engine(); LetItRideAI letItRideAI = new LetItRideAI(stream.Next()); RandomAI randomAI = new RandomAI(stream.Next()); RPSAI red = (redAI == "LetItRide" ? letItRideAI : randomAI); RPSAI blue = (blueAI == "LetItRide" ? letItRideAI : randomAI); int redWins = 0; int blueWins = 0; int draws = 0; for (int index = 0; index < count; ++index) { Engine.Actions redAction = red.GetNextThrow(Engine.Players.RED); Engine.Actions blueAction = blue.GetNextThrow(Engine.Players.BLUE); Engine.Players winner = engine.Throw(redAction, blueAction); switch (winner) { case Engine.Players.NONE: ++draws; break; case Engine.Players.RED: ++redWins; break; case Engine.Players.BLUE: ++blueWins; break; } red.AddOutcome(redAction, blueAction, winner); blue.AddOutcome(redAction, blueAction, winner); string outcome = (winner == Engine.Players.NONE ? "Draw" : (winner == Engine.Players.RED ? "Red" : "Blue")); Console.WriteLine(redAI + " " + blueAI + " " + count + " " + outcome); } } else { Console.WriteLine("Usage: Engine.exe {LetItRide|Random} {LetItRide|Random} {count}"); } }
public static void Main(string[] args) { if (args.Length == 3) { string redAI = args [0]; string blueAI = args [1]; int count = int.Parse (args [2]); Random stream = new Random (); Engine engine = new Engine (); LetItRideAI letItRideAI = new LetItRideAI (stream.Next()); RandomAI randomAI = new RandomAI (stream.Next()); RPSAI red = (redAI == "LetItRide" ? letItRideAI : randomAI); RPSAI blue = (blueAI == "LetItRide" ? letItRideAI : randomAI); int redWins = 0; int blueWins = 0; int draws = 0; for (int index = 0; index < count; ++index) { Engine.Actions redAction = red.GetNextThrow (Engine.Players.RED); Engine.Actions blueAction = blue.GetNextThrow (Engine.Players.BLUE); Engine.Players winner = engine.Throw (redAction, blueAction); switch (winner) { case Engine.Players.NONE: ++draws; break; case Engine.Players.RED: ++redWins; break; case Engine.Players.BLUE: ++blueWins; break; } red.AddOutcome (redAction, blueAction, winner); blue.AddOutcome (redAction, blueAction, winner); string outcome = (winner == Engine.Players.NONE ? "Draw" : (winner == Engine.Players.RED ? "Red" : "Blue")); Console.WriteLine (redAI + " " + blueAI + " " + count + " " + outcome); } } else { Console.WriteLine ("Usage: Engine.exe {LetItRide|Random} {LetItRide|Random} {count}"); } }