Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 246043e

Browse files
committed
Create interaction scripts
1 parent 5d86ee3 commit 246043e

6 files changed

Lines changed: 120 additions & 40 deletions

File tree

agent/planner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55

66
class Planner:
7-
def __init__(self, model_name="gpt-3.5-turbo", temperature=0, resume=False, ckpt_dir="ckpt"):
7+
def __init__(self, model_name="gpt-3.5-turbo", temperature=1.0, resume=False, ckpt_dir="ckpt"):
88
load_dotenv(find_dotenv())
99
openai.api_key = os.getenv("OPENAI_API_KEY")
1010
guidance.llm = guidance.llms.OpenAI(model_name, temperature=temperature)

gui/pages/0👤Unity agent.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def create_and_download_cs_file(code_string):
5757
if btn:
5858
os.remove(file_name)
5959

60-
6160
def generate_initial_script(task):
6261
st.write(f"- Received your task to generate a script for: {task}")
6362
st.write("- Retrieving similar plans...")

gui/pages/3🗂️Planner.py

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
sys.path.append("/Users/allyne/Documents/GitHub/Unity-Agent/")
66
import agent as A
77

8+
def get_three_plans(task):
9+
planner= A.Planner()
10+
memory_manager = A.MemoryManager()
11+
examples = memory_manager._get_plan(task)
12+
st.write("Previous plans:\n", examples)
13+
output_1 = planner._generate_plan(task, examples)
14+
output_2 = planner._generate_plan(task, examples)
15+
output_3 = planner._generate_plan(task, [])
16+
st.write("Output 1 is:\n\n ", output_1)
17+
st.write("Output 2 is: \n\n", output_2)
18+
st.write("Output 3 is: \n\n", output_3)
19+
820
def orchestrate(task):
921
planner = A.Planner()
1022
output = planner._orchestrate(task)
@@ -43,51 +55,61 @@ def identify_modify_object_operations(task):
4355

4456
st.title("Testing planning agent")
4557

46-
st.write("1. Identify task type")
47-
task3 = st.text_area(f"Identify task type from task here", key="task3")
48-
if st.button("Run", key="run1"):
58+
st.write("Generate 3 plans")
59+
task = st.text_area(f"Enter task here", key="task")
60+
if st.button("Run", key="run"):
4961
with st.spinner("Processing"):
50-
identify_task_type(task3)
62+
get_three_plans(task)
5163
st.success("Process done!")
5264

53-
st.write("2. Identify prefab to be created, modified, or deleted.")
54-
st.write('All prefabs avail are: ["Chair", "TableLamp", "Table", "Screen", "Push Button"]')
55-
task = st.text_area(f"Identify prefab from task here", key="task")
56-
if st.button("Run", key="run2"):
57-
with st.spinner("Processing"):
58-
identify_prefab(task)
59-
st.success("Process done!")
6065

61-
st.write("3. Identify creation operations")
62-
task5= st.text_area(f"Identify creation operations from task here", key="task5")
63-
if st.button("Run", key="run5"):
64-
with st.spinner("Processing"):
65-
st.write("Location, orientation, size, color")
66-
identify_create_object_operations(task5)
67-
st.success("Process done!")
66+
# st.write("=====Old=====")
6867

69-
st.write("4. Identify modification operations")
70-
task4 = st.text_area(f"Identify modification operations from task here", key="task4")
71-
if st.button("Run", key="run4"):
72-
with st.spinner("Processing"):
73-
st.write("Location, orientation, size, color")
74-
identify_modify_object_operations(task4)
75-
st.success("Process done!")
68+
# st.write("1. Identify task type")
69+
# task3 = st.text_area(f"Identify task type from task here", key="task3")
70+
# if st.button("Run", key="run1"):
71+
# with st.spinner("Processing"):
72+
# identify_task_type(task3)
73+
# st.success("Process done!")
7674

77-
st.write("5. Identify location specification")
78-
st.write('Possible locations are: ["BackWall", "FrontWall", "LeftWall", "RightWall", "Floor", "Ceiling"]')
79-
task2 = st.text_area(f"Identify location specification from task here", key="task2")
80-
if st.button("Run", key="run3"):
81-
with st.spinner("Processing"):
82-
identify_location(task2)
83-
st.success("Process done!")
75+
# st.write("2. Identify prefab to be created, modified, or deleted.")
76+
# st.write('All prefabs avail are: ["Chair", "TableLamp", "Table", "Screen", "Push Button"]')
77+
# task = st.text_area(f"Identify prefab from task here", key="task")
78+
# if st.button("Run", key="run2"):
79+
# with st.spinner("Processing"):
80+
# identify_prefab(task)
81+
# st.success("Process done!")
8482

85-
st.write("6. Orchestrate")
86-
task1 = st.text_area(f"Create entire plan here", key="task1")
87-
if st.button("Run", key="run6"):
88-
with st.spinner("Processing"):
89-
orchestrate(task1)
90-
st.success("Process done!")
83+
# st.write("3. Identify creation operations")
84+
# task5= st.text_area(f"Identify creation operations from task here", key="task5")
85+
# if st.button("Run", key="run5"):
86+
# with st.spinner("Processing"):
87+
# st.write("Location, orientation, size, color")
88+
# identify_create_object_operations(task5)
89+
# st.success("Process done!")
90+
91+
# st.write("4. Identify modification operations")
92+
# task4 = st.text_area(f"Identify modification operations from task here", key="task4")
93+
# if st.button("Run", key="run4"):
94+
# with st.spinner("Processing"):
95+
# st.write("Location, orientation, size, color")
96+
# identify_modify_object_operations(task4)
97+
# st.success("Process done!")
98+
99+
# st.write("5. Identify location specification")
100+
# st.write('Possible locations are: ["BackWall", "FrontWall", "LeftWall", "RightWall", "Floor", "Ceiling"]')
101+
# task2 = st.text_area(f"Identify location specification from task here", key="task2")
102+
# if st.button("Run", key="run3"):
103+
# with st.spinner("Processing"):
104+
# identify_location(task2)
105+
# st.success("Process done!")
106+
107+
# st.write("6. Orchestrate")
108+
# task1 = st.text_area(f"Create entire plan here", key="task1")
109+
# if st.button("Run", key="run6"):
110+
# with st.spinner("Processing"):
111+
# orchestrate(task1)
112+
# st.success("Process done!")
91113

92114
# st.write("3. Identify number of elements")
93115
# task3 = st.text_area(f"Identify number of elements from task here", key="task3")

unity_scripts/ZombieFollowUser.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using UnityEngine;
2+
using UnityEngine.AI;
3+
using UnityEngine.Events;
4+
using UnityEngine.XR.Interaction.Toolkit;
5+
using System;
6+
using System.Collections.Generic;
7+
using Enums;
8+
public class ZombieFollowUser : SceneAPI
9+
{
10+
private NavMeshAgent navMeshAgent;
11+
private GameObject zombie1GameObject;
12+
private void Start()
13+
{
14+
15+
// 1. Retrieve the object
16+
// 2. Check if it has a NavMeshAgent component
17+
// 3. If it doesn't, add one
18+
// 4. For continuous movement of the object, use Update() to set the destination of the NavMeshAgent
19+
20+
foreach (GameObject obj in allObjectsInScene)
21+
{
22+
if (obj.name=="Zombie1"){
23+
Debug.Log("Found Zombie1");
24+
zombie1GameObject = obj;
25+
break;
26+
}
27+
}
28+
29+
if(zombie1GameObject == null)
30+
{
31+
Debug.LogError("Zombie1 object not found in the scene!");
32+
return;
33+
}
34+
35+
// Try to get the NavMeshAgent component from the Zombie1 object
36+
navMeshAgent = zombie1GameObject.GetComponent<NavMeshAgent>();
37+
38+
// If the zombie doesn't have a NavMeshAgent, add one
39+
if (navMeshAgent == null)
40+
{
41+
navMeshAgent = zombie1GameObject.AddComponent<NavMeshAgent>();
42+
43+
// Set some default properties for the NavMeshAgent.
44+
navMeshAgent.speed = 3.5f;
45+
navMeshAgent.angularSpeed = 120;
46+
navMeshAgent.acceleration = 8;
47+
}
48+
}
49+
50+
private void Update()
51+
{
52+
Vector3D userFeetPosition3D = GetUsersFeetPosition();
53+
Vector3 userFeetPosition = userFeetPosition3D.ToVector3();
54+
if (navMeshAgent != null)
55+
{
56+
navMeshAgent.SetDestination(userFeetPosition);
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)