Exemplo n.º 1
0
        private static Dictionary<long, Node> createNodes(string FileName, char separator)
        {
            var nodes = new Dictionary<long, Node>();
            var lines = readLines(FileName);

            foreach (var line in lines)
            {
                var coords = line.Split(separator);
                var val = Convert.ToDouble(coords[0]);
                var state = new MazeState(Convert.ToDouble(coords[0]), Convert.ToDouble(coords[1]));
                var node = new Node(state);
                nodes.Add(node.Id, node);
            }

            return nodes;
        }
Exemplo n.º 2
0
        private static ChangeActiveMazeCellAction determineAction(MazeState from, MazeState to)
        {
            if(from.ActiveCellXCoord == to.ActiveCellXCoord)
            {
                if (from.ActiveCellYCoord < to.ActiveCellYCoord)
                    return new ChangeActCellDownAction();
                else if (from.ActiveCellYCoord > to.ActiveCellYCoord)
                    return new ChangeActCellUpAction();
            } else if (from.ActiveCellYCoord == to.ActiveCellYCoord)
            {
                if (from.ActiveCellXCoord < to.ActiveCellXCoord)
                    return new ChangeActCellRightAction();
                else if (from.ActiveCellXCoord > to.ActiveCellXCoord)
                    return new ChangeActCellLeftAction();
            }

            throw new Exception("Unknown action");
        }