Ejemplo n.º 1
0
        public string GetCellString(GridPoint point)
        {
            if (!Maze.MazeCells.ContainsKey(point))
            {
                return(" ");
            }

            var cell = Maze.MazeCells[point];

            if (MazeCellType.Wall.Equals(cell.Type))
            {
                return("#");
            }
            if (Maze.CellsWithDoors.ContainsKey(point) &&
                !KeysCollected.ContainsKey(Maze.CellsWithDoors[point].ToLower()))
            {
                return(Maze.CellsWithDoors[point]);
            }
            if (Maze.CellsWithKeys.ContainsKey(point) &&
                !KeysCollected.ContainsKey(Maze.CellsWithKeys[point]))
            {
                return(Maze.CellsWithKeys[point]);
            }
            if (CurrentPositions.Contains(point))
            {
                return("@");
            }
            return(".");
        }
Ejemplo n.º 2
0
        public ConsoleColor GetCellColor(GridPoint point)
        {
            if (!Maze.MazeCells.ContainsKey(point))
            {
                return(Console.ForegroundColor);
            }

            var cell = Maze.MazeCells[point];

            if (MazeCellType.Wall.Equals(cell.Type))
            {
                return(ConsoleColor.DarkGray);
            }
            if (Maze.CellsWithDoors.ContainsKey(point) &&
                !KeysCollected.ContainsKey(Maze.CellsWithDoors[point].ToLower()))
            {
                return(ConsoleColor.Red);
            }
            if (Maze.CellsWithKeys.ContainsKey(point) &&
                !KeysCollected.ContainsKey(Maze.CellsWithKeys[point]))
            {
                return(ConsoleColor.Cyan);
            }
            if (CurrentPositions.Contains(point))
            {
                return(ConsoleColor.Green);
            }
            return(Console.ForegroundColor);
        }
Ejemplo n.º 3
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        supportedRecipes.Add(MasterRecipe.Instance.Log);

        CurrentPositions.Add(Jobs.FORESTER, 1);
        TotalPositions.Add(Jobs.FORESTER, 1);
        Register();
    }
Ejemplo n.º 4
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        supportedRecipes.Add(MasterRecipe.Instance.Ore);
        supportedRecipes.Add(MasterRecipe.Instance.Stone);

        CurrentPositions.Add(Jobs.MINER, 2);
        TotalPositions.Add(Jobs.MINER, 2);
        Register();
    }
Ejemplo n.º 5
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.ARMOR, ItemType.WEAPON
        };
        CurrentPositions.Add(Jobs.QUATERMASTER, 1);
        TotalPositions.Add(Jobs.QUATERMASTER, 1);
        Register();
    }
Ejemplo n.º 6
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        supportedRecipes.Add(MasterRecipe.Instance.Fish);
        logger.Log(debug, "woodCut constructor");

        CurrentPositions.Add(Jobs.FISHERMAN, 1);
        TotalPositions.Add(Jobs.FISHERMAN, 1);
        Register();
    }
Ejemplo n.º 7
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        supportedRecipes.Add(MasterRecipe.Instance.Wheat);
        supportedRecipes.Add(MasterRecipe.Instance.Barley);

        CurrentPositions.Add(Jobs.FARMER, 2);
        TotalPositions.Add(Jobs.FARMER, 2);
        Register();
    }
Ejemplo n.º 8
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.CHARCOAL
        };

        supportedRecipes.Add(MasterRecipe.Instance.Charcoal);
        CurrentPositions.Add(Jobs.COLLIER, 1);
        TotalPositions.Add(Jobs.COLLIER, 1);
        Register();
    }
Ejemplo n.º 9
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.BEER
        };

        supportedRecipes.Add(MasterRecipe.Instance.Beer);
        CurrentPositions.Add(Jobs.BREWMASTER, 1);
        TotalPositions.Add(Jobs.BREWMASTER, 1);
        Register();
    }
Ejemplo n.º 10
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.LUMBERPLANK
        };

        supportedRecipes.Add(MasterRecipe.Instance.LumberPlank);

        CurrentPositions.Add(Jobs.SAWWORKER, 1);
        TotalPositions.Add(Jobs.SAWWORKER, 1);
        Register();
    }
Ejemplo n.º 11
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType>(Enum.GetValues(typeof(ItemType)).Cast <ItemType>().ToList());

        CurrentPositions.Add(Jobs.TRADERUNNER, 1);
        TotalPositions.Add(Jobs.TRADERUNNER, 1);

        CurrentPositions.Add(Jobs.MULTICITYTRADER, 1);
        TotalPositions.Add(Jobs.MULTICITYTRADER, 1);

        Register();
    }
Ejemplo n.º 12
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.FIREWOOD
        };

        supportedRecipes.Add(MasterRecipe.Instance.FireWood);

        CurrentPositions.Add(Jobs.WOODCUTER, 1);
        TotalPositions.Add(Jobs.WOODCUTER, 1);
        Register();
    }
Ejemplo n.º 13
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.MEAT, ItemType.LEATHER
        };

        supportedRecipes.Add(MasterRecipe.Instance.Meat);
        supportedRecipes.Add(MasterRecipe.Instance.Leather);

        CurrentPositions.Add(Jobs.HUNTER, 1);
        TotalPositions.Add(Jobs.HUNTER, 1);
        Register();
    }
Ejemplo n.º 14
0
    public override void Start()
    {
        base.Start();
        this.debug = false;


        canHold = new List <ItemType> {
            ItemType.STONEBLOCK
        };

        supportedRecipes.Add(MasterRecipe.Instance.StoneBlock);

        CurrentPositions.Add(Jobs.STONECUTTER, 1);
        TotalPositions.Add(Jobs.STONECUTTER, 1);
        Register();
    }
Ejemplo n.º 15
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.BOW, ItemType.ARROW
        };

        supportedRecipes.Add(MasterRecipe.Instance.Bow);
        supportedRecipes.Add(MasterRecipe.Instance.Arrow);

        CurrentPositions.Add(Jobs.FLETCHER, 1);
        TotalPositions.Add(Jobs.FLETCHER, 1);
        Register();
    }
Ejemplo n.º 16
0
    public override void Start()
    {
        base.Start();
        this.debug = false;

        canHold = new List <ItemType> {
            ItemType.ARMOR, ItemType.WEAPON, ItemType.TOOL
        };

        supportedRecipes.Add(MasterRecipe.Instance.Armor);
        supportedRecipes.Add(MasterRecipe.Instance.Weapon);
        supportedRecipes.Add(MasterRecipe.Instance.Tool);

        CurrentPositions.Add(Jobs.ARMORSMITH, 1);
        TotalPositions.Add(Jobs.ARMORSMITH, 1);
        CurrentPositions.Add(Jobs.WEAPONSMITH, 1);
        TotalPositions.Add(Jobs.WEAPONSMITH, 1);
        CurrentPositions.Add(Jobs.TOOLSMITH, 1);
        TotalPositions.Add(Jobs.TOOLSMITH, 1);
        Register();
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Retrieves all neighboring maze states that can be reached by moving
        /// the given position.
        /// </summary>
        /// <param name="positionIndex"></param>
        /// <returns></returns>
        private IList <Tuple <MazeState, int, int> > GetNeighboringMazeStatesWithCostsForPosition(int positionIndex)
        {
            var result          = new List <Tuple <MazeState, int, int> >();
            var currentPosition = CurrentPositions[positionIndex];

            foreach (var targetKey in Maze.Keys)
            {
                if (KeysCollected.ContainsKey(targetKey))
                {
                    continue;
                }

                var targetKeyCell = Maze.KeyCells[targetKey];

                // SIMPLIFYING ASSUMPTION:
                // The shortest paths between all pairs of keys when ignoring
                // doors always yields the ultimate shortest path
                var edgeKey = new Tuple <GridPoint, GridPoint>(currentPosition, targetKeyCell);
                if (!Maze.ShortestPathsBetweenKeysIgnoringDoors.ContainsKey(edgeKey))
                {
                    continue;
                }
                bool canReachTarget = true;
                foreach (var door in Maze.DoorsAlongShortestPathBetweenKeys[edgeKey])
                {
                    if (!KeysCollected.ContainsKey(door.ToLower()))
                    {
                        canReachTarget = false;
                    }
                }
                if (!canReachTarget)
                {
                    continue;
                }
                var shortestPath           = Maze.ShortestPathsBetweenKeysIgnoringDoors[edgeKey];
                var totalCost              = shortestPath.Count - 1;
                var keysCollectedAlongPath = Maze.GetKeysAlongPath(shortestPath);

                //// THIS CODE WORKS IN THE GENERAL CASE WHEN THE SIMPLIFYING ASSUMPTION IS NOT MET
                //int Heuristic(GridPoint currentCell)
                //{
                //    return GridPoint.GetManhattanDistance(currentCell, targetKeyCell);
                //}
                //bool GetCanEnterNode(GridPoint point)
                //{
                //    return Maze.GetCanEnterCell(point, KeysCollected);
                //}
                //var nodePathToTargetKeyCell = Maze.MazeGraph.GetShortestPathViaNodes(
                //    start: currentPosition,
                //    end: targetKeyCell,
                //    Heuristic: Heuristic,
                //    GetCanEnterNode: GetCanEnterNode);
                //if (nodePathToTargetKeyCell.Path.Count == 0)
                //    continue;
                //var keysCollectedAlongPath = Maze.GetKeysCollectedAlongNodePath(nodePathToTargetKeyCell.Path);
                //var shortestPath = Maze.GetRobotPathFromNodePath(nodePathToTargetKeyCell.Path);
                //var totalCost = shortestPath.Count - 1;

                var endKeysCollected = new SortedDictionary <string, string>(KeysCollected);
                foreach (var key in keysCollectedAlongPath)
                {
                    if (!endKeysCollected.ContainsKey(key))
                    {
                        endKeysCollected.Add(key, key);
                    }
                }
                var finalPositions = CurrentPositions.ToList();
                finalPositions[positionIndex] = targetKeyCell;
                var newMazeState = new MazeState(
                    maze: Maze,
                    currentPositions: finalPositions,
                    keysCollected: endKeysCollected);
                var resultEntry = new Tuple <MazeState, int, int>(
                    newMazeState,
                    totalCost,
                    positionIndex);
                result.Add(resultEntry);
            }
            return(result);
        }
Ejemplo n.º 18
0
 public override int GetHashCode()
 {
     return(HashCode.Combine(CurrentPositions.First().X, CurrentPositions.First().Y));
 }