public MCTSBiasedRAVE(CurrentStateWorldModel WorldModel) : base(WorldModel) { ActionHistory = new List <Pair <int, Action> >(); if (BestSelection) { lastestActions = new List <GOB.Action>(); } }
public MCTS(CurrentStateWorldModel currentStateWorldModel) { this.InProgress = false; this.CurrentStateWorldModel = currentStateWorldModel; this.MaxIterations = 15000; this.MaxIterationsProcessedPerFrame = 10; this.RandomGenerator = new System.Random(); }
public MCTS(CurrentStateWorldModel currentStateWorldModel) { this.InProgress = false; this.CurrentStateWorldModel = currentStateWorldModel; this.MaxIterations = 100; this.MaxIterationsProcessedPerFrame = 10; this.RandomGenerator = new System.Random(Guid.NewGuid().GetHashCode()); }
public MCTS(CurrentStateWorldModel currentStateWorldModel) { this.InProgress = false; this.CurrentStateWorldModel = currentStateWorldModel; this.MaxIterations = 100; this.MaxIterationsProcessedPerFrame = 10; this.RandomGenerator = new System.Random(); this.SumProcessingTime = 0.0f; this.MaxSelectionDepthReached = 0; this.MaxPlayoutDepthReached = 0; }
public MCTS(CurrentStateWorldModel currentStateWorldModel) { this.InProgress = false; this.CurrentStateWorldModel = currentStateWorldModel; this.MaxIterations = 2000; this.NumberOfRuns = 10; this.MaxIterationsProcessedPerFrame = 100; this.MaxPlayoutDepthAllowed = 5; this.MaxPlayoutSimulations = 5; //stochastic simulations this.RandomGenerator = new System.Random(); }
private MCTSNode Expand(MCTSNode parent, GOB.Action action) { WorldModel worldmodel = CurrentStateWorldModel.GenerateChildWorldModel(); action.ApplyActionEffects(worldmodel); MCTSNode n = new MCTSNode(worldmodel) { Action = action, Parent = parent, N = 0, Q = 0 }; parent.ChildNodes.Add(n); return(n); }
public void Start() { this.draw = true; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialization of the GOB decision making //let's start by creating 4 main goals this.SurviveGoal = new Goal(SURVIVE_GOAL, 5.0f) { InsistenceValue = 20.0f }; this.GainXPGoal = new Goal(GAIN_XP_GOAL, 5.0f) { ChangeRate = 0.1f, InsistenceValue = 15.0f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { ChangeRate = 0.1f }; this.BeQuickGoal = new Goal(BE_QUICK_GOAL, 1.0f) { ChangeRate = 0.1f }; this.Goals = new List <Goal>(); this.Goals.Add(this.GainXPGoal); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.BeQuickGoal); this.Goals.Add(this.GetRichGoal); //initialize the available actions this.Actions = new List <IAJ.Unity.DecisionMaking.GOB.Action>(); foreach (var potion in GameObject.FindGameObjectsWithTag("ManaPotion")) { this.Actions.Add(new GetManaPotion(this, potion)); } foreach (var potion in GameObject.FindGameObjectsWithTag("HealthPotion")) { this.Actions.Add(new GetHealthPotion(this, potion)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Skeleton")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Orc")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Dragon")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } this.Actions.Add(new LevelUp(this)); MathHelper.Shuffle(this.Actions); var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); if (!MCTSActive) { this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel, this.Actions, this.Goals); } else { this.MCTSAlgorithm = new MCTSBiased(worldModel); } }
public void Start() { this.draw = true; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialize your pathfinding algorithm here! //use the best heuristic from Project 2 this.AStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanHeuristic()); //initialization of the GOB decision making //let's start by creating 4 main goals this.SurviveGoal = new Goal(SURVIVE_GOAL, 1.0f); this.GainLevelGoal = new Goal(GAIN_LEVEL_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.BeQuickGoal = new Goal(BE_QUICK_GOAL, 1.0f) { ChangeRate = 0.1f }; this.Goals = new List <Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.BeQuickGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.GainLevelGoal); //initialize the available actions //Uncomment commented actions after you implement them this.Actions = new List <Action>(); //this.Actions.Add(new ShieldOfFaith(this)); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var potion in GameObject.FindGameObjectsWithTag("ManaPotion")) { //this.Actions.Add(new GetManaPotion(this, potion)); } foreach (var potion in GameObject.FindGameObjectsWithTag("HealthPotion")) { this.Actions.Add(new GetHealthPotion(this, potion)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Skeleton")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new DivineSmite(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Orc")) { this.Actions.Add(new SwordAttack(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Dragon")) { this.Actions.Add(new SwordAttack(this, enemy)); } var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel, this.Actions, this.Goals); this.DiaryText.text = "My Diary \n I awoke. What a wonderful day to kill Monsters!\n"; }
public MCTSBiasedPlayout(CurrentStateWorldModel currentStateWorldModel) : base(currentStateWorldModel) { }
public void Start() { this.draw = true; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); var clusterGraph = Resources.Load <ClusterGraph>("ClusterGraph"); this.Initialize(NavigationManager.Instance.NavMeshGraphs[0], new NodeArrayAStarPathFinding(NavigationManager.Instance.NavMeshGraphs[0], new GatewayHeuristic(clusterGraph))); //this.Initialize(NavigationManager.Instance.NavMeshGraphs[0], new NodeArrayAStarPathFinding(NavigationManager.Instance.NavMeshGraphs[0], new EuclideanHeuristic())); //initialization of the GOB decision making //let's start by creating 4 main goals this.SurviveGoal = new Goal(SURVIVE_GOAL, 2.0f); this.GainXPGoal = new Goal(GAIN_XP_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.BeQuickGoal = new Goal(BE_QUICK_GOAL, 1.0f) { ChangeRate = 0.1f }; this.Goals = new List <Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.BeQuickGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.GainXPGoal); //initialize the available actions this.Actions = new List <Action>(); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var potion in GameObject.FindGameObjectsWithTag("ManaPotion")) { this.Actions.Add(new GetManaPotion(this, potion)); } foreach (var potion in GameObject.FindGameObjectsWithTag("HealthPotion")) { this.Actions.Add(new GetHealthPotion(this, potion)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Skeleton")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Orc")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Dragon")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel, this.Actions, this.Goals); this.MCTSDecisionMaking = new MCTS(worldModel); this.MCTSDecisionMaking.MaxIterations = 1000; this.MCTSDecisionMaking.MaxIterationsProcessedPerFrame = 25; }
public MCTSBiasedLimited(CurrentStateWorldModel currentStateWorldModel) : base(currentStateWorldModel) { }
public MCTSRAVE(CurrentStateWorldModel worldModel) : base(worldModel) { }
public MCTSRAVE(CurrentStateWorldModel worldModel) : base(worldModel) { this.ActionHistory = new List <Pair <int, GOB.Action> >(); }
public MCTSRave(CurrentStateWorldModel currentStateWorldModel) : base(currentStateWorldModel) { }
public void Start() { this.draw = true; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); var clusterGraph = Resources.Load <ClusterGraph>("ClusterGraph"); this.Initialize(NavigationManager.Instance.NavMeshGraphs[0], new NodeArrayAStarPathFinding(NavigationManager.Instance.NavMeshGraphs[0], new GatewayHeuristic(clusterGraph))); //initialization of the GOB decision making //let's start by creating 4 main goals this.SurviveGoal = new Goal(SURVIVE_GOAL, 2.0f); this.GainXPGoal = new Goal(GAIN_XP_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.BeQuickGoal = new Goal(BE_QUICK_GOAL, 1.0f) { ChangeRate = 0.1f }; this.Goals = new List <Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.BeQuickGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.GainXPGoal); //initialize the available actions this.Actions = new List <Action>(); this.Actions.Add(new LevelUp(this)); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var potion in GameObject.FindGameObjectsWithTag("ManaPotion")) { this.Actions.Add(new GetManaPotion(this, potion)); } foreach (var potion in GameObject.FindGameObjectsWithTag("HealthPotion")) { this.Actions.Add(new GetHealthPotion(this, potion)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Skeleton")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Orc")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Dragon")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } if (MCTSBias) { //temporary model used to sort var WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); if (MCTSBiasActions) { this.Actions.Sort((item1, item2) => item1.getHValue(WorldModel as WorldModel) < item2.getHValue(WorldModel) ? 1 : 0); //model with sorted values WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); } this.MCTSDecisionMaking = new MCTSBiasedPlayout(WorldModel); } else if (MCTSearch) { var WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); if (MCTSBiasActions) { this.Actions.Sort((item1, item2) => item1.getHValue(WorldModel as WorldModel) < item2.getHValue(WorldModel) ? 1 : 0); //model with sorted values WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); } this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(WorldModel, this.Actions, this.Goals); this.MCTSDecisionMaking = new MCTS(WorldModel); } else if (MCTSRave) { var WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); if (MCTSBiasActions) { this.Actions.Sort((item1, item2) => item1.getHValue(WorldModel as WorldModel) < item2.getHValue(WorldModel) ? 1 : 0); //model with sorted values WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); } this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(WorldModel, this.Actions, this.Goals); this.MCTSDecisionMaking = new MCTSRAVE(WorldModel); } else if (MCTSBiasRave) { var WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); if (MCTSBiasActions) { this.Actions.Sort((item1, item2) => item1.getHValue(WorldModel as WorldModel) < item2.getHValue(WorldModel) ? 1 : 0); //model with sorted values WorldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); } this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(WorldModel, this.Actions, this.Goals); this.MCTSDecisionMaking = new MCTSBiasedRAVE(WorldModel); } this.MCTSDecisionMaking.MaxIterations = 5000; this.MCTSDecisionMaking.MaxIterationsProcessedPerFrame = 25; }
public void Start() { this.draw = true; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialize your pathfinding algorithm here! //use goalBoundingPathfinding for a more efficient algorithm this.Initialize(NavigationManager.Instance.NavMeshGraphs[0], new NodeArrayAStarPathFinding(NavigationManager.Instance.NavMeshGraphs[0], new EuclidianDistanceHeuristic())); //this.goalBoundsTable = Resources.Load<GoalBoundingTable>("GoalBoundingTable"); //this.Initialize(NavigationManager.Instance.NavMeshGraphs[0], new GoalBoundingPathfinding(NavigationManager.Instance.NavMeshGraphs[0], new EuclidianDistanceHeuristic(), this.goalBoundsTable)); //initialization of the GOB decision making //let's start by creating 4 main goals this.SurviveGoal = new Goal(SURVIVE_GOAL, 2.0f); this.GainXPGoal = new Goal(GAIN_XP_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.BeQuickGoal = new Goal(BE_QUICK_GOAL, 1.0f) { ChangeRate = 0.1f }; this.Goals = new List <Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.BeQuickGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.GainXPGoal); //initialize the available actions this.Actions = new List <Action>(); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var potion in GameObject.FindGameObjectsWithTag("ManaPotion")) { this.Actions.Add(new GetManaPotion(this, potion)); } foreach (var potion in GameObject.FindGameObjectsWithTag("HealthPotion")) { this.Actions.Add(new GetHealthPotion(this, potion)); } this.Actions.Add(new LevelUp(this)); foreach (var enemy in GameObject.FindGameObjectsWithTag("Skeleton")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Orc")) { this.Actions.Add(new SwordAttack(this, enemy)); this.Actions.Add(new Fireball(this, enemy)); } foreach (var enemy in GameObject.FindGameObjectsWithTag("Dragon")) { this.Actions.Add(new SwordAttack(this, enemy)); //this.Actions.Add(new Fireball(this, enemy)); } var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); //escolher entre MCTS ou GOAP if (MCTSActive) { this.MCTSDecisionMaking = new MCTS(worldModel); } else { this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel, this.Actions, this.Goals); } }
public MCTSBiasedPlayout(CurrentStateWorldModel currentStateWorldModel, IHeuristic heuristic) : base(currentStateWorldModel) { this.Heuristic = heuristic; }
public void Start() { this.draw = true; this.influenceMapDebugMode = 0; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialization of the movement algorithms this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic()); this.aStarPathFinding.NodesPerSearch = 100; 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); steeringPipeline.Actuator = new FollowPathActuator(steeringPipeline); this.Character.Movement = steeringPipeline; //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); //initialization of the GOB decision making //let's start by creating 4 main goals //the eatgoal 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, 2.0f); this.EatGoal = new Goal(EAT_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.RestGoal = new Goal(REST_GOAL, 1.0f); 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); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var tree in GameObject.FindGameObjectsWithTag("Tree")) { this.Actions.Add(new GetArrows(this, tree)); } foreach (var bed in GameObject.FindGameObjectsWithTag("Bed")) { this.Actions.Add(new Sleep(this, bed)); } foreach (var boar in GameObject.FindGameObjectsWithTag("Boar")) { this.Actions.Add(new MeleeAttack(this, boar)); this.Actions.Add(new Shoot(this, boar)); } //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); }
public MCTSBiasedPlayout(CurrentStateWorldModel currentStateWorldModel) : base(currentStateWorldModel) { weights = new float[] { 1, 3, 2, 4, 1 }; }