示例#1
0
        static void  parseFile(string fileName, bool turning)
        {
            StreamReader sr = new StreamReader(fileName);

            string line;
            int    counter = 0;

            while ((line = sr.ReadLine()) != null)
            {
                string[] parts = line.Split(' ');
                cord[]   nodes = new cord[parts.Length];

                for (int i = 0; i < parts.Length; i++)
                {
                    int nodeV = int.Parse(parts[i]) - 1;

                    if (turning)
                    {
                        nodeV = nodeV / 4;
                    }

                    nodes[i] = new cord(nodeV % 8, nodeV / 8);
                }

                string outFileName = fileName + counter + ".txt";
                WriteOutput(outFileName, nodes);

                counter++;
            }
        }
示例#2
0
        public override DIRECTION translateMove(cord from, cord to, ref View v)
        {
            int first  = to.x - from.x;
            int second = to.y - from.y;

            if (first > 0) // dolu
            {
                return(DIRECTION.DIRECTION_FORWARD);
            }
            else if (first < 0) // nahoru
            {
                v = new TopView();
                return(DIRECTION.DIRECTION_BACKWARD);
            }
            else if (second > 0) // doprava
            {
                v = new RightView();
                return(DIRECTION.DIRECTION_LEFT);
            }
            else if (second < 0) // doleva
            {
                v = new LeftView();
                return(DIRECTION.DIRECTION_RIGHT);
            }
            else
            {
                return(DIRECTION.WAIT);
            }
        }
示例#3
0
        public static View detectView(cord from, cord to)
        {
            int first  = to.x - from.x;
            int second = to.y - from.y;

            if (first > 0)
            {
                return(new DownView());
            }
            else if (first < 0)
            {
                return(new TopView());
            }
            else if (second > 0)
            {
                return(new RightView());
            }
            else
            {
                return(new LeftView());
            }
        }
示例#4
0
 public virtual DIRECTION translateMove(cord from, cord to, ref View v)
 {
     return(0);
 }