public void Evalulate(Node node, IStragetgyItterator <Node> itterator) { var free = Static.FloorMap.Subtract(node.Maps.CrateMap); foreach (var move in node.Maps.MoveMap.TruePositions()) { var dir = node.CrateTarget - move; if (dir == VectorInt2.Up || dir == VectorInt2.Down || dir == VectorInt2.Left || dir == VectorInt2.Right) // Next to each other { var p = move; var pp = node.CrateTarget; var ppp = node.CrateTarget + dir; if (free.Contains(ppp) && free[ppp]) { var newCrate = new Bitmap(node.Maps.CrateMap); newCrate[pp] = false; newCrate[ppp] = true; var newMove = SolverHelper.FloodFillUsingWallAndCrates(Static.WallMap, newCrate, pp); var newNode = new Node { PlayerBefore = p, PlayerAfter = pp, CrateTarget = ppp, Maps = new StateMaps(newCrate, newMove) }; // Does this already exist if (!CrateMap[ppp]) { // New crate position node.Add(newNode); itterator.Add(newNode); CrateMap[ppp] = true; } else { // the crate may exist, but we have a new move map var match = node.Root().FirstOrDefault(x => x.Maps.Equals(newNode.Maps)); if (match == null) { node.Add(newNode); itterator.Add(newNode); } } } } } }
private void CheckAndAddChild(IStragetgyItterator <Node> itterator, Node node, VectorInt2 direction) { var possibleChild = node.Position + direction; if (!exists[possibleChild]) { itterator.Add((Node)node.Add(new Node { Position = possibleChild })); exists[possibleChild] = true; } }