Example #1
0
        public ColorCrazeDecision(ColorCrazeDirection dir)
        {
            switch (dir)
            {
            case ColorCrazeDirection.Up:
                Movement = new Point(0, -1);
                break;

            case ColorCrazeDirection.Down:
                Movement = new Point(0, 1);
                break;

            case ColorCrazeDirection.Left:
                Movement = new Point(-1, 0);
                break;

            case ColorCrazeDirection.Right:
                Movement = new Point(1, 0);
                break;

            default:
                Movement = new Point(0, 0);
                break;
            }
        }
        private static PossibleCase GetPossibleCase(Point pts, ColorCrazeBoard.ColorCrazeBoard board, ColorCrazeDirection direction)
        {
            PossibleCase possibleCase = new PossibleCase
            {
                Direction = direction,
                owner     = board[pts.X, pts.Y].Owner
            };

            return(possibleCase);
        }
Example #3
0
            public Point Simulate(List <Point> occupiedLocations, Point fromLocation, ColorCrazeDirection direction)
            {
                var movement = fromLocation;

                switch (direction)
                {
                case ColorCrazeDirection.Up:
                    movement = new Point(fromLocation.X, fromLocation.Y - 1);
                    break;

                case ColorCrazeDirection.Down:
                    movement = new Point(fromLocation.X, fromLocation.Y + 1);
                    break;

                case ColorCrazeDirection.Left:
                    movement = new Point(fromLocation.X - 1, fromLocation.Y);
                    break;

                case ColorCrazeDirection.Right:
                    movement = new Point(fromLocation.X + 1, fromLocation.Y);
                    break;
                }

                if (occupiedLocations.Contains(movement))
                {
                    return(fromLocation);
                }

                if (movement.X >= this.board.Width ||
                    movement.Y >= this.board.Height ||
                    movement.X < 0 ||
                    movement.Y < 0)
                {
                    return(fromLocation);
                }

                return(movement);
            }