Esempio n. 1
0
        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 override void AddOutcome(Engine.Actions redAction, Engine.Actions blueAction, Engine.Players winner)
        {
            lastRedAction = redAction;
            lastBlueAction = blueAction;
            lastWinner = winner;

            if (winner == Engine.Players.NONE)
                ++draws;
            else
                draws = 0;
        }
Esempio n. 3
0
        private Engine.Actions WhatBeats(Engine.Actions play)
        {
            switch (play)
            {
            case Engine.Actions.ROCK: return(Engine.Actions.PAPER);

            case Engine.Actions.PAPER: return(Engine.Actions.SCISSORS);

            case Engine.Actions.SCISSORS: return(Engine.Actions.ROCK);
            }

            return(Engine.Actions.ROCK);
        }
Esempio n. 4
0
        public override void AddOutcome(Engine.Actions redAction, Engine.Actions blueAction, Engine.Players winner)
        {
            lastRedAction  = redAction;
            lastBlueAction = blueAction;
            lastWinner     = winner;

            if (winner == Engine.Players.NONE)
            {
                ++draws;
            }
            else
            {
                draws = 0;
            }
        }
Esempio n. 5
0
 public virtual void AddOutcome(Engine.Actions redAction, Engine.Actions blueAction, Engine.Players winner)
 {
 }