Example #1
0
        public SticksGame MachineMakesMove()
        {
            int sticksTaken = _generator.Next(MinToTake, MaxToTake);
            int remains     = NumberOfSticks - sticksTaken;

            MachineMoved?.Invoke(this, new Move(sticksTaken, remains));

            return(new SticksGame(Revert(Turn), remains, _generator, MachineMoved));
        }
Example #2
0
        private void MachineMakesMove()
        {
            int maxNumber      = NumberOfSticks >= 3 ? 3 : NumberOfSticks;
            int numberOfSticks = randomiser.Next(1, maxNumber);

            NumberOfSticks -= numberOfSticks;
            MachineMoved?.Invoke(numberOfSticks);
            WhoseTurn = WhoseTurn == Player.Human ? Player.Machine : Player.Human;
        }
Example #3
0
        public Game MachineMakesMove()
        {
            if (Turn == Player.Human)
            {
                throw new InvalidOperationException($"It's turn of Human to make a move.");
            }
            var sticksTaken = MachineTakes();

            MachineMoved?.Invoke(this, new Move(sticksTaken, Remains(sticksTaken)));

            return(MakeMove(sticksTaken));
        }