public DepthLimitedGOAPDecisionMaking(CurrentStateWorldModel currentStateWorldModel, List <Action> actions, List <Goal> goals) { this.ActionCombinationsProcessedPerFrame = 200; this.Actions = actions; this.Goals = goals; this.InitialWorldModel = currentStateWorldModel; }
public DepthLimitedGOAPDecisionMaking(CurrentStateWorldModel currentStateWorldModel, List<Action> actions, List<Goal> goals) { this.ActionCombinationsProcessedPerFrame = 200; this.Actions = actions; this.Goals = goals; this.InitialWorldModel = currentStateWorldModel; }
public void Start() { this.draw = true; this.influenceMapDebugMode = 0; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialization of the Influence Maps this.RedInfluenceMap = new InfluenceMap(this.navMesh, new SimpleUnorderedList(), new ClosedLocationRecordDictionary(), new LinearInfluenceFunction(), 0.1f); this.GreenInfluenceMap = new InfluenceMap(this.navMesh, new SimpleUnorderedList(), new ClosedLocationRecordDictionary(), new LinearInfluenceFunction(), 0.1f); this.ResourceInfluenceMap = new InfluenceMap(this.navMesh, new SimpleUnorderedList(), new ClosedLocationRecordDictionary(), new LinearInfluenceFunction(), 0.1f); this.CombinedInfluence = new Dictionary<LocationRecord, float>(); //initialization of the movement algorithms this.aStarPathFinding = new InfluenceMapAStarPathfinding(this.navMesh, new EuclideanDistanceHeuristic(), this.RedInfluenceMap, this.GreenInfluenceMap); this.aStarPathFinding.NodesPerSearch = 500; var steeringPipeline = new SteeringPipeline { MaxAcceleration = 40.0f, MaxConstraintSteps = 2, Character = this.Character.KinematicData, }; this.decomposer = new PathFindingDecomposer(steeringPipeline, this.aStarPathFinding); this.Targeter = new FixedTargeter(steeringPipeline); steeringPipeline.Targeters.Add(this.Targeter); steeringPipeline.Decomposers.Add(this.decomposer); this.CharActuator = new ActuatorSwitch(steeringPipeline); var followPath = new FollowPathActuator(steeringPipeline); var standStill = new StandStillActuator(steeringPipeline); this.CharActuator.Actuators.Add(followPath.Name, followPath); this.CharActuator.Actuators.Add(standStill.Name, standStill); this.CharActuator.SwitchActuator(followPath.Name); steeringPipeline.Actuator = this.CharActuator; this.Character.Movement = steeringPipeline; //initialization of the GOB decision making //let's start by creating 5 main goals //the eat goal is the only goal that increases at a fixed rate per second, it increases at a rate of 0.1 per second this.SurviveGoal = new Goal(SURVIVE_GOAL, 1.5f); this.EatGoal = new Goal(EAT_GOAL, 2.5f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.25f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.RestGoal = new Goal(REST_GOAL, 0.25f); this.ConquerGoal = new Goal(CONQUER_GOAL, 1.5f) { InsistenceValue = 5.0f }; this.Goals = new List<Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.EatGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.RestGoal); this.Goals.Add(this.ConquerGoal); //initialize the available actions var restAction = new Rest(this); this.Actions = new List<Action>(); this.Actions.Add(restAction); this.PlaceFlagAction = new PlaceFlag(this); this.Actions.Add(this.PlaceFlagAction); this.ActiveResources = new Dictionary<NavigationGraphNode, IInfluenceUnit>(); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); this.AddResource(new Resource(this.navMesh.QuantizeToNode(chest.transform.position, 1.0f))); } foreach (var tree in GameObject.FindGameObjectsWithTag("Tree")) { this.Actions.Add(new GetArrows(this, tree)); this.AddResource(new Resource(this.navMesh.QuantizeToNode(tree.transform.position, 1.0f))); } foreach (var bed in GameObject.FindGameObjectsWithTag("Bed")) { this.Actions.Add(new Sleep(this, bed)); this.AddResource(new Resource(this.navMesh.QuantizeToNode(bed.transform.position, 1.0f))); } foreach (var boar in GameObject.FindGameObjectsWithTag("Boar")) { this.AddResource(new Resource(this.navMesh.QuantizeToNode(boar.transform.position, 1.0f))); this.Actions.Add(new MeleeAttack(this, boar)); this.Actions.Add(new Shoot(this, boar)); } this.ResourceInfluenceMap.Initialize(this.ActiveResources.Values.ToList()); //flags used for the influence map this.RedFlags = new List<IInfluenceUnit>(); foreach (var redFlag in GameObject.FindGameObjectsWithTag("RedFlag")) { this.RedFlags.Add(new Flag(this.navMesh.QuantizeToNode(redFlag.transform.position, 1.0f), FlagColor.Red)); } this.GreenFlags = new List<IInfluenceUnit>(); foreach (var greenFlag in GameObject.FindGameObjectsWithTag("GreenFlag")) { this.GreenFlags.Add(new Flag(this.navMesh.QuantizeToNode(greenFlag.transform.position, 1.0f), FlagColor.Green)); } this.RedInfluenceMap.Initialize(this.RedFlags); this.GreenInfluenceMap.Initialize(this.GreenFlags); var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel,this.Actions,this.Goals); }