From 7b9caa66fc3a6d291160dbcba668a34e843308e5 Mon Sep 17 00:00:00 2001 From: Jack Urbanek Date: Tue, 15 Jun 2021 12:13:16 -0400 Subject: [PATCH] Adding new example copy, passing name and descriptions --- .../custom_world_interactions/run_task.py | 40 +++++++++++++------ .../TaskDescription/Copy/ExamplesCopy.js | 36 +++++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/crowdsourcing/custom_world_interactions/run_task.py b/crowdsourcing/custom_world_interactions/run_task.py index acb0246ed..c9c1e6a0d 100644 --- a/crowdsourcing/custom_world_interactions/run_task.py +++ b/crowdsourcing/custom_world_interactions/run_task.py @@ -58,28 +58,41 @@ class TestScriptConfig(RunScriptConfig): num_tasks: int = DEFAULT_NUM_TASKS -def get_object_list(db_path): +def get_object_lists(db_path): db = LIGHTDatabase(db_path) with db as ldb: - object_list = [dict(obj)["name"] for obj in ldb.get_object()] + all_objects = [dict(obj) for obj in ldb.get_object()] - return object_list + primary_objects = [ + {"name": obj["name"], "desc": obj["physical_description"]} + for obj in all_objects + if obj["is_gettable"] > 0.5 + ] + + secondary_objects = [ + {"name": obj["name"], "desc": obj["physical_description"]} + for obj in all_objects + ] + + return primary_objects, secondary_objects def create_task_data( - object_list, primary_object_list_size, secondary_object_list_size, num_tasks + primary_objects, + secondary_objects, + primary_object_list_size, + secondary_object_list_size, + num_tasks, ): - random.shuffle(object_list) + random.shuffle(primary_objects) + random.shuffle(secondary_objects) task_data_array = [] for idx in range(num_tasks): - obj_name = object_list[idx % len(object_list)] - - random_object_list = random.sample( - object_list, primary_object_list_size + secondary_object_list_size + primary_object_list = random.sample(primary_objects, primary_object_list_size) + secondary_object_list = random.sample( + secondary_objects, secondary_object_list_size ) - primary_object_list = random_object_list[:primary_object_list_size] - secondary_object_list = random_object_list[primary_object_list_size:] task_data_array.append( { @@ -153,9 +166,12 @@ def main(cfg: DictConfig) -> None: def onboarding_always_valid(onboarding_data): return True + primary_objects, secondary_objects = get_object_lists(cfg.light_db_path) + shared_state = SharedStaticTaskState( static_task_data=create_task_data( - get_object_list(cfg.light_db_path), + primary_objects, + secondary_objects, cfg.primary_object_list_size, cfg.secondary_object_list_size, cfg.num_tasks, diff --git a/crowdsourcing/custom_world_interactions/webapp/src/components/TaskDescription/Copy/ExamplesCopy.js b/crowdsourcing/custom_world_interactions/webapp/src/components/TaskDescription/Copy/ExamplesCopy.js index ca1c634ed..a711b9d56 100644 --- a/crowdsourcing/custom_world_interactions/webapp/src/components/TaskDescription/Copy/ExamplesCopy.js +++ b/crowdsourcing/custom_world_interactions/webapp/src/components/TaskDescription/Copy/ExamplesCopy.js @@ -2,17 +2,37 @@ const GoodExamples = [ { primary:"Rusty key", secondary:"Bucket", + primary_desc:"This rusty key is incredibly worn. Ow - it's pretty sharp too.", + secondary_desc:"A pristine looking bucket, without a mark. Must have been made recently.", narration:"You scrape the key on the edge of the bucket. It sounds terrible, and leaves a mark" }, { primary:"Towel", secondary:"Rock", + primary_desc:"A nice, dry towel. You can't help but like the fabric of it.", + secondary_desc:"A grimy rock someone got from a swamp. It might be nicer cleaned.", narration:"You rub the rock with the towel. The rock is now shiny, but the towel could use a cleaning." }, { primary:"Rock", secondary:"Tree", + primary_desc:"A hefty rock. It's hard and heavy.", + secondary_desc:"This tree has more branches in it than you can count. It has no leaves though.", narration:"You throw the rock at the tree. It hits a branch, and a stick falls to the ground." + }, + { + primary:"Cutting board", + secondary:"Benches", + primary_desc:"A perfect surface for slicing and dicing.", + secondary_desc:"These benches are stable and great for sitting.", + narration:"You use the cutting board with benches to create a workbench. It stays steady and allows you to cut safely." + }, + { + primary:"Coarse work clothes", + secondary:"Large wooden door", + primary_desc:"These clothes feel rough to the touch, and wouldn't be fun to wear...", + secondary_desc:"The door is ornate and made of fine wood. A chilly draft is coming in from beneath this door.", + narration:"You use the cutting board with benches to create a workbench. It stays steady and allows you to cut safely." } ] @@ -20,26 +40,42 @@ const BadExamples =[ { primary:"shirt", secondary:"bucket", + primary_desc:"A perfecty normal shirt, from a local market.", + secondary_desc:"A pristine looking bucket, without a mark. Must have been made recently.", narration:"You put the shirt in the bucket and it transforms into a pair of pants.", badReason: "This interaction isn't very plausible. Interactions don't need to be expected or mundane, but they should be a realistic occurrence." }, { primary:"Ball", secondary:"Table", + primary_desc:"A really round ball. It would roll on any uneven surface.", + secondary_desc:"This table is of uncertain quality.", narration:"The ball rolls off of the table and falls on the floor.", badReason: `This interaction isn't written in second person. The correct format would be "You roll the ball on the table. It falls off of the other side onto the floor"` }, { primary:"Tea", secondary:"Table", + primary_desc:"Tea in an unassuming mug. It's still warm.", + secondary_desc:"This table is of uncertain quality.", narration:"You put the tea on the table but it falls off, leaving a mark on the rug.", badReason:"This interaction uses a third object (Rug). It's preferable for the interaction to be generic for any environment, therefore not envolving more than the two objects mentioned." }, { primary:"Magical Ring", secondary:"Magician", + primary_desc:"This ring is arcane and magical in some way. You can't decipher it though.", + secondary_desc:"A true master of magic. This magician knows what they're talking about.", narration:"You call a magician with your cellphone and he shows up to analyze the Magical Ring.", badReason:"Again, this interaction uses a random third object (Cellphone). It also uses an object which should not exist in the medieval fantasy setting (Cellphone)." + }, + { + primary:"Bed", + secondary:"Torn pants", + primary_desc:"This bed has been slept in recently.", + secondary_desc:"There are more holes than you can count in these pants. You wonder if they're salvagable.", + narration:"You sit down on the bed to repair your torn pants.", + badReason:"This interaction isn't between the two objects - the pants don't interact directly with the bed in any way." } ]