public void PopulateChildren(Map map, float searchStepTime, List <TreeSearchMoveInfo> possibleMoves) { // TODO: if we ever want to do searches more than 1 layer, we should re-implement opposite direction filtering foreach (TreeSearchMoveInfo moveInfo in possibleMoves) { Vector2 vec = moveInfo.BaseDir.Rotate(TankInfo.Rot); List <Vector2> passedPos = new List <Vector2>(); TankStateInfo newStateInfo; if (!moveInfo.IsJet) { newStateInfo = AIUtility.CalcPosInFutureWithRequestedDir(vec, searchStepTime, TankInfo, out passedPos); } else { newStateInfo = AIUtility.CalcPosInFutureWithRequestedDirJets(vec, searchStepTime, TankInfo, out passedPos); } HashSet <Node> passedNodes = new HashSet <Node>(); bool passedOutOfBounds = false; foreach (Vector2 pos in passedPos) { if (map.IsPositionWithinBounds(pos)) { passedNodes.Add(map.PositionToNode(pos)); } else { passedOutOfBounds = true; break; } } if (!passedOutOfBounds) { ChildNodes.Add(new LookaheadNode(this, vec, moveInfo.IsJet, newStateInfo, searchStepTime, passedNodes.ToList())); } } }