Exemple #1
0
        public static AntDirection Reverse(this AntDirection dir)
        {
            switch (dir)
            {
            case AntDirection.N: return(AntDirection.S);

            case AntDirection.S: return(AntDirection.N);

            case AntDirection.E: return(AntDirection.W);

            case AntDirection.W: return(AntDirection.E);
            }
            return(AntDirection.U);
        }
Exemple #2
0
    private void CalculateDirections()
    {
        for (int i = 0; i < directions.Length; i++)
        {
            directions[i] = new AntDirection();
        }

        int angle       = range / (directions.Length - 1);
        int middleIndex = directions.Length / 2;

        directions[middleIndex].Angle = 0;
        for (int i = 0; i < middleIndex; i++)
        {
            directions[middleIndex - i - 1].Angle = -(i + 1) * angle;
            directions[middleIndex + i + 1].Angle = (i + 1) * angle;
        }
    }
Exemple #3
0
        // Returns a new Coordinates corresponding to the current Coordinates offseted by 1 in a specific direction
        public Coordinates ApplyDirection(AntDirection dir)
        {
            Coordinates val = new Coordinates(Col, Row);

            switch (dir)
            {
            case AntDirection.N: val.Row--;
                break;

            case AntDirection.S: val.Row++;
                break;

            case AntDirection.E: val.Col++;
                break;

            case AntDirection.W: val.Col--;
                break;
            }
            return(val);
        }