Small code changes
This commit is contained in:
@@ -48,7 +48,7 @@ public class AI_Agent : MonoBehaviour
|
||||
actionInvoked = false;
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, taskRange);
|
||||
|
||||
@@ -25,16 +25,19 @@ public class PlanNode
|
||||
states = new Dictionary<string, int>(allStates);
|
||||
|
||||
foreach(KeyValuePair<string, int> state in agentStates)
|
||||
if(!states.ContainsKey(state.Key))
|
||||
{
|
||||
if (!states.ContainsKey(state.Key))
|
||||
{
|
||||
states.Add(state.Key, state.Value);
|
||||
|
||||
}
|
||||
}
|
||||
this.action = action;
|
||||
}
|
||||
}
|
||||
|
||||
public class AI_Planner
|
||||
{
|
||||
private string planDescription;
|
||||
private string m_PlanDescription;
|
||||
|
||||
public Queue<AI_Action> Plan(List<AI_Action> actions, Dictionary<string, int> goal, AIStates agentStates)
|
||||
{
|
||||
@@ -58,7 +61,7 @@ public class AI_Planner
|
||||
}
|
||||
|
||||
PlanNode cheapest = null;
|
||||
foreach (PlanNode leaf in leaves)
|
||||
foreach (var leaf in leaves)
|
||||
{
|
||||
if (cheapest == null)
|
||||
cheapest = leaf;
|
||||
@@ -66,8 +69,8 @@ public class AI_Planner
|
||||
cheapest = leaf;
|
||||
}
|
||||
|
||||
List<AI_Action> result = new List<AI_Action>();
|
||||
PlanNode n = cheapest;
|
||||
var result = new List<AI_Action>();
|
||||
var n = cheapest;
|
||||
while (n != null)
|
||||
{
|
||||
if(n.action != null)
|
||||
@@ -77,17 +80,17 @@ public class AI_Planner
|
||||
n = n.parent;
|
||||
}
|
||||
|
||||
Queue<AI_Action> queue = new Queue<AI_Action>();
|
||||
foreach(AI_Action action in result)
|
||||
var queue = new Queue<AI_Action>();
|
||||
foreach(var action in result)
|
||||
{
|
||||
queue.Enqueue(action);
|
||||
}
|
||||
|
||||
planDescription = "";
|
||||
m_PlanDescription = "";
|
||||
int index = 0;
|
||||
foreach(AI_Action action in queue)
|
||||
{
|
||||
planDescription += index + ": " + action.actionName + "\n";
|
||||
m_PlanDescription += index + ": " + action.actionName + "\n";
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -149,6 +152,6 @@ public class AI_Planner
|
||||
|
||||
public string GetPlanDescription()
|
||||
{
|
||||
return planDescription;
|
||||
return m_PlanDescription;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ namespace Scrips
|
||||
{
|
||||
if (_currentStatePrint != null && planner != null)
|
||||
{
|
||||
// _currentStatePrint.text = "Nurse 1 Action: " + currentAction.actionName + "\n" + planner.GetPlanString();
|
||||
_currentStatePrint.text = "Patient 1 Action: " + currentAction.actionName + "\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public class Robot : AI_Agent {
|
||||
{
|
||||
if (_currentStatePrint != null && planner != null && currentAction != null)
|
||||
{
|
||||
// _currentStatePrint.text = "Nurse 1 Action: " + currentAction.actionName + "\n" + planner.GetPlanString();
|
||||
_currentStatePrint.text =
|
||||
"Nurse 1 Action: " + currentAction.actionName + "\n" + planner.GetPlanDescription();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user