### Task Submission Example Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/react_prompt.txt Example of the JSON structure for submitting a completed task. ```json {"action": "SUBMIT", "arg1": "Task completed!"} ``` -------------------------------- ### Implementing a DiscoveryWorld Interaction Loop Source: https://github.com/allenai/discoveryworld/blob/main/README.md A complete example demonstrating how to load a scenario, observe the environment, execute actions, and check for task completion. ```python # Example of how to use the DiscoveryWorldAPI to interact with the environment def exampleLoop(scenarioName, difficultyStr, randomSeed, maxSteps:int=10): print("Running example loop.") print("Task Theme: " + scenarioName) print("Difficulty: " + difficultyStr) print("Parametric Seed: " + str(randomSeed)) print("\n") # Load the scenario api = DiscoveryWorldAPI(threadID=0) success = api.loadScenario(scenarioName = scenarioName, difficultyStr = difficultyStr, randomSeed = randomSeed, numUserAgents = 1) if (success == False): print("Error: Could not load scenario '" + scenarioName + "' with difficulty '" + difficultyStr + "'.") return None # Run a loop where we observe the environment, take an action, and repeat. lastActionResult = None for stepNum in range(0, maxSteps): # Print the result print("Step " + str(stepNum) + ":") # Get the observation from the environment observation = api.getAgentObservation(agentIdx=0) # TODO: Feed the observation into your model here, and have it generate an action actionJSON = model(api, observation, lastActionResult) print("Action: " + json.dumps(actionJSON)) # Take the action result = api.performAgentAction(agentIdx=0, actionJSON=actionJSON) lastActionResult = result print("Result: " + json.dumps(result)) print("\n") # Check if the task is complete if (api.areTasksComplete()): print("All tasks have been completed. Exiting.") break # Show the final score scorecard = api.getTaskScorecard() print("Scorecard: ") print(json.dumps(scorecard, indent=4, sort_keys=True)) # # Main # if __name__ == "__main__": # Set the scenario and difficulty scenarioName = SCENARIOS[0] difficultyStr = SCENARIO_DIFFICULTY_OPTIONS[0] randomSeed = 0 # Run the example loop exampleLoop(scenarioName=scenarioName, difficultyStr=difficultyStr, randomSeed=randomSeed, numSteps=10) ``` -------------------------------- ### Install Recoma library Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Install the Recoma library directly from the GitHub repository using pip. ```shell pip install git+https://github.com/allenai/recoma.git@b262ab5476841551c5d6874e8ddecef78c71a072 ``` -------------------------------- ### Install DiscoveryWorld Environment Source: https://github.com/allenai/discoveryworld/blob/main/README-USERSTUDY.md Commands to navigate to the directory, create a conda environment, and install project dependencies. ```bash cd discoveryworld ``` ```bash conda create --name discoveryworld python=3.9 conda activate discoveryworld ``` ```bash pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Install Dependencies Source: https://github.com/allenai/discoveryworld/blob/main/README.md Commands to install required Python packages from the requirements file and the local package. ```bash pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Dialog Option Selection Example Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/react_prompt.txt Example of the JSON structure for selecting a dialog option. ```json {"chosen_dialog_option_int": 0} ``` -------------------------------- ### Teleport Action Example Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/react_prompt.txt Example of the JSON structure for the teleportation action. ```json {"action": "TELEPORT_TO_LOCATION", "arg1": "school"} ``` -------------------------------- ### Action with Thought Process Example Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/react_prompt.txt Example of an action JSON including a thought field for reasoning. ```json {"action": "USE", "arg1": 5, "arg2": 12, "thought": "I have the seed in hand and need to plant it. Using the shovel on the soil will allow me to dig a hole to plant the seed. I can then grow a plant from this seed to measure the nutrient richness of this soil."} ``` -------------------------------- ### Task Failure Submission Example Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/react_prompt.txt Example of the JSON structure for submitting a failed task with reasoning. ```json {"action": "SUBMIT", "arg1": "Task failed! Unable to explore the building!"} ``` -------------------------------- ### Run DiscoveryWorld Interface Source: https://github.com/allenai/discoveryworld/blob/main/README-USERSTUDY.md Command to launch the graphical user study interface from the project root. ```bash python scripts/userstudy.py ``` -------------------------------- ### Run Plan & Execute baseline Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Execute the Plan & Execute agent using the specified configuration file. ```shell export DIFF=Easy # Difficulty level export TASK="Space Sick" # Task export MAX_ENV_CALLS=100 # Max env calls export SEED=123 # GPT Seed export OUTPUT_DIR=output_dir/pne/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} export MODEL=gpt-4o-2024-05-13 python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/plan_and_execute.jsonnet ``` -------------------------------- ### Run React baseline Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Execute the React agent on a specific task using the provided configuration file. ```shell export DIFF=Easy # Difficulty level export TASK="Space Sick" # Task export MAX_ENV_CALLS=100 # Max env calls export SEED=123 # GPT Seed export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/react.jsonnet ``` -------------------------------- ### Initialize DiscoveryWorld API and Load Scenario Source: https://github.com/allenai/discoveryworld/blob/main/README.md Instantiate the API and load a specific scenario using the loadScenario function. Ensure numUserAgents is set to 1 as multi-agent support is currently untested. ```python api = DiscoveryWorldAPI(threadID=1) success = api.loadScenario(scenarioName = scenarioName, difficultyStr = difficultyStr, randomSeed = seed, numUserAgents = 1) if (success == False): print("Error: Could not load scenario '" + scenarioName + "' with difficulty '" + difficultyStr + "'.") return None ``` -------------------------------- ### Import Scenario Names Source: https://github.com/allenai/discoveryworld/blob/main/README.md Access the list of recognized task themes programmatically. ```python from discoveryworld.ScenarioMaker import SCENARIO_NAMES ``` -------------------------------- ### Implement Minimal LLM Agent Source: https://github.com/allenai/discoveryworld/blob/main/README.md A template for an agent that constructs prompts based on environment observations and available actions. ```python from discoveryworld.DiscoveryWorldAPI import DiscoveryWorldAPI from discoveryworld.ScenarioMaker import SCENARIOS, SCENARIO_DIFFICULTY_OPTIONS import json # Given an observation, return an action to take def model(api, observation, lastActionResult): prompt = "You are an agent, and must choose an action to perform a task towards a goal." # Add the task description to the prompt prompt += "Your task is: \n" taskDescription = observation["ui"]["taskProgress"][0]["description"] prompt += taskDescription + "\n" # Here is what you currently see: prompt += "You see: \n" prompt += "```json\n" prompt += json.dumps(observation["ui"], indent=4, sort_keys=True) prompt += "```\n" # Here are the actions you can take: prompt += "You can take the following actions: \n" prompt += "```json\n" prompt += json.dumps(api.listKnownActions(limited=False), indent=4, sort_keys=True) prompt += "```\n" # Teleport: Provide a list of valid teleport locations for this task prompt += "Teleporting: To make moving easier, you can teleport to a list of specific locations in the environment, using the teleport action. In this case, 'arg1' is the name of a location, from the list below. An example teleport action would be: `{\"action\": \"TELEPORT_TO_LOCATION\", \"arg1\": \"school\"}).\n" prompt += "```json\n" prompt += json.dumps(api.listTeleportLocationsDict(), indent=4, sort_keys=True) prompt += "```\n" # Result of last action prompt += "The result of your last action, which might help inform your next action, is: \n" prompt += "```json\n" prompt += json.dumps(lastActionResult, indent=4, sort_keys=True) prompt += "```\n" # Format prompt prompt = "\n" prompt += "It's now time for you to choose an action. Please provide a JSON dictionary with your action, below. " prompt += "The dictionary should have a key, `action`, and optionally up to two arguments, `arg1` and `arg2`, which are usually each UUIDs of specific objects, unless described differently in the action list.\n" ``` -------------------------------- ### Run ReAct Agent Small Skills Experiment Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Executes the ReAct agent on the Small Skills task with a 100 environment call limit. ```shell export DIFF=Normal export TASK="Small Skills" export MAX_ENV_CALLS=100 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/react.jsonnet ``` -------------------------------- ### listKnownActions() Source: https://github.com/allenai/discoveryworld/blob/main/README.md Retrieves a dictionary of all available actions, their expected arguments, and descriptions. ```APIDOC ## listKnownActions() ### Description Returns a list of all available actions and the arguments they expect. This is useful for formatting prompts for LLMs. ``` -------------------------------- ### Clone the Repository Source: https://github.com/allenai/discoveryworld/blob/main/README.md Commands to clone the DiscoveryWorld repository and enter the directory. ```bash git clone https://github.com/allenai/discoveryworld.git cd discoveryworld ``` -------------------------------- ### Run ReAct Agent Easy Tasks Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Iterates through a list of Easy tasks for the ReAct agent with a 100 environment call limit. ```shell for t in "Archaeology Dating" "Plant Nutrients" "Space Sick" "Combinatorial Chemistry" "Reactor Lab" "Lost in Translation" "Proteomics" "It's (not)"; do export DIFF=Easy export TASK=${t} export MAX_ENV_CALLS=100 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/react.jsonnet ``` -------------------------------- ### Run Plan & Execute Agent Easy Tasks Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Iterates through a list of Easy tasks for the Plan & Execute agent with a 100 environment call limit. ```shell for t in "Archaeology Dating" "Plant Nutrients" "Space Sick" "Combinatorial Chemistry" "Reactor Lab" "Lost in Translation" "Proteomics" "It's (not)"; do export DIFF=Easy export TASK=${t} export MAX_ENV_CALLS=100 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/plan_and_execute.jsonnet ``` -------------------------------- ### DiscoveryWorldAPI.loadScenario() Source: https://github.com/allenai/discoveryworld/blob/main/README.md Initializes the DiscoveryWorld API and loads a specific scenario with defined difficulty and configuration parameters. ```APIDOC ## DiscoveryWorldAPI.loadScenario() ### Description Initializes the environment and loads a specific task scenario. This function must be called to prepare the world before an agent can begin interacting. ### Parameters - **scenarioName** (string) - Required - The name of the task theme to load. - **difficultyStr** (string) - Required - The difficulty level (e.g., 'Easy', 'Normal', 'Challenge'). - **randomSeed** (int) - Required - Seed value for parametric variation (nominally 0-4). - **numUserAgents** (int) - Required - Number of agents in the scenario (currently limited to 1). ### Returns - **success** (boolean) - Returns True if the scenario loaded successfully, False otherwise. ``` -------------------------------- ### Run Plan & Execute Agent Normal Tasks Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Iterates through a list of tasks for the Plan & Execute agent with a 1000 environment call limit. ```shell for t in "Archaeology Dating" "Plant Nutrients" "Space Sick" "Combinatorial Chemistry" "Reactor Lab" "Lost in Translation" "Proteomics" "It's (not)"; do export DIFF=Challenge export TASK=${t} export MAX_ENV_CALLS=1000 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/plan_and_execute.jsonnet ``` -------------------------------- ### Run Plan & Execute Agent Small Skills Experiment Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Executes the Plan & Execute agent on the Small Skills task with a 100 environment call limit. ```shell export DIFF=Normal export TASK="Small Skills" export MAX_ENV_CALLS=100 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/plan_and_execute.jsonnet ``` -------------------------------- ### Create Conda Environment Source: https://github.com/allenai/discoveryworld/blob/main/README.md Commands to create and activate a Python 3.9 environment for the project. ```bash conda create --name discoveryworld python=3.9 conda activate discoveryworld ``` -------------------------------- ### Run ReAct Agent Normal Tasks Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/README.md Iterates through a list of tasks for the ReAct agent with a 1000 environment call limit. ```shell for t in "Archaeology Dating" "Plant Nutrients" "Space Sick" "Combinatorial Chemistry" "Reactor Lab" "Lost in Translation" "Proteomics" "It's (not)"; do export DIFF=Challenge export TASK=${t} export MAX_ENV_CALLS=1000 export SEED=123 # Used for GPT export MODEL=gpt-4o-2024-05-13 export OUTPUT_DIR=output_dir/react/${DIFF}_${MAX_ENV_CALLS}env_${MODEL}_s${SEED}/${TASK// /_} python agents/recoma/run_recoma.py \ --output_dir ${OUTPUT_DIR} \ --config agents/recoma/configs/react.jsonnet ``` -------------------------------- ### Notebook Formatting Templates Source: https://github.com/allenai/discoveryworld/blob/main/README-USERSTUDY.md Required templates for documenting scenario metadata, tools used, and experimental hypotheses. ```text START OF NOTES FOR: Scenario: Reactor Lab Difficulty: Normal Variation: 1 ``` ```text TOOLS I USED WHEN SOLVING THIS SCENARIO: Spreadsheet: Excel Statistics: R ``` ```text HYPOTHESIS: SUPPORTING EVIDENCE: - - - ``` -------------------------------- ### List Known Actions Source: https://github.com/allenai/discoveryworld/blob/main/README.md Retrieves a dictionary of available actions and their expected arguments, formatted for LLM consumption. ```python actionDescriptions = { ActionType.PICKUP.name: {"args": ["arg1"], "desc": "pick up an object (arg1)"}, ActionType.DROP.name: {"args": ["arg1"], "desc": "drop an object (arg1)"}, ActionType.PUT.name: {"args": ["arg1", "arg2"], "desc": "put an object (arg1) in/on another object (arg2), or give an object (arg1) to another agent (arg2)"}, ActionType.OPEN.name: {"args": ["arg1"], "desc": "open an object (arg1)"}, ActionType.CLOSE.name: {"args": ["arg1"], "desc": "close an object (arg1)"}, ActionType.ACTIVATE.name: {"args": ["arg1"], "desc": "activate an object (arg1)"}, ActionType.DEACTIVATE.name: {"args": ["arg1"], "desc": "deactivate an object (arg1)"}, ActionType.TALK.name: {"args": ["arg1"], "desc": "talk to another agent (arg1)"}, ActionType.EAT.name: {"args": ["arg1"], "desc": "eat an object (arg1)"}, ActionType.READ.name: {"args": ["arg1"], "desc": "read an object (arg1)"}, ActionType.USE.name: {"args": ["arg1", "arg2"], "desc": "use an object (arg1), e.g. a thermometer, on another object (arg2), e.g. water."}, ActionType.MOVE_DIRECTION.name: {"args": ["arg1"], "desc": "move in a specific direction (arg1), which is one of 'north', 'east', 'south', or 'west'."}, ActionType.ROTATE_DIRECTION.name: {"args": ["arg1"], "desc": "rotate to face a specific direction (arg1), which is one of 'north', 'east', 'south', or 'west'."}, ActionType.TELEPORT_TO_LOCATION.name: {"args": ["arg1"], "desc": "teleport to a specific location (arg1), by name. A list of valid teleport locations is provided elsewhere."}, ActionType.TELEPORT_TO_OBJECT.name: {"args": ["arg1"], "desc": "teleport beside a specific object (arg1). 'arg1' should be the UUID of the object to teleport to."}, ActionType.DISCOVERY_FEED_GET_UPDATES.name: {"args": [], "desc": "read the latest status updates on discovery feed"}, ActionType.DISCOVERY_FEED_GET_POST_BY_ID.name: {"args": ["arg1"], "desc": "read a specific post on discovery feed (arg1). 'arg1' should be the integer ID of the post."}, } ``` -------------------------------- ### Run Hypothesizer Agent via Command Line Source: https://github.com/allenai/discoveryworld/blob/main/agents/README.md Template for executing the Hypothesizer Agent with configurable scenario parameters. ```bash python discoveryworld/DiscoveryWorldAPIUsageExample.py --scenario=$TASK_THEME --difficulty=$DIFFICULTY --numSteps=$NUM_STEPS --seed=$SEED --model=$MODEL --video --maxCostDollars=$MAX_COST_DOLLARS ``` ```bash python agents/HypothesizerAgent.py --scenario="Combinatorial Chemistry" --difficulty="Normal" --numSteps=10 --seed=0 --model=gpt-4o-2024-05-13 --video --maxCostDollars=5 ``` ```bash python agents/HypothesizerAgent.py --scenario="Small Skills: Dialog Test" --difficulty="Normal" --numSteps=25 --seed=0 --model=gpt-4o-2024-05-13 --video --maxCostDollars=5 ``` -------------------------------- ### Run Random Agent Source: https://github.com/allenai/discoveryworld/blob/main/agents/README.md Execute the Random Agent from the root directory using scenario, difficulty, seed, and step count parameters. ```bash python agents/RandomAgent.py --scenario=$TASK_THEME --difficulty=$DIFFICULTY --seed=$SEED --numSteps=$NUM_STEPS ``` ```bash python agents/RandomAgent.py --scenario="Space Sick" --difficulty="Challenge" --seed=0 --numSteps=10 ``` -------------------------------- ### Perform an Agent Action Source: https://github.com/allenai/discoveryworld/blob/main/README.md Constructs an action packet with object UUIDs and executes it using the performAgentAction method. ```python # Assemble an action packet actionName = "USE" actionCommand = { "action": actionName, "arg1": None, "arg2": None } # Arguments are the UUIDs of specific objects. These typically come from the `uuid` field of an object found in the observation # Here we'll just assume `accessibleObjects` is a list of nearby and accessible objects, taken from the observation, and # randomly pick two objects from it to serve as arguments. obj1 = r.choice(accessibleObjects) actionCommand[arg1] = obj1["uuid"] obj2 = r.choice(accessibleObjects) actionCommand[arg1] = obj2["uuid"] # Perform the action result = api.performAgentAction(agentIdx=0, actionJSON=actionCommand) ``` -------------------------------- ### CuteRPG World Asset License Terms Source: https://github.com/allenai/discoveryworld/blob/main/README.md Summary of usage rights and restrictions for the CuteRPG World art assets used in the project. ```text License - You can use it on your project, personal or commercial. - You can modify and edit it to fit your project. - Credits to PixyMoon. - You cannot resell this asset pack! ``` -------------------------------- ### Scenario List Source: https://github.com/allenai/discoveryworld/blob/main/README-USERSTUDY.md The list of available scenarios to be played during the user study. ```text Tutorial Archaeology Dig -- Normal and Challenge Combinatorial Chemistry -- Normal and Challenge (note that Challenge may take a while) Plant Nutrients -- Normal and Challenge Proteomics -- Normal and Challenge Reactor Lab -- Normal and Challenge Lost in Translation -- Normal and Challenge Space Sick -- Normal and Challenge It's (not) Rocket Science -- Normal (*Challenge* is not yet ready, and should not be played) ``` -------------------------------- ### Import Difficulty Options Source: https://github.com/allenai/discoveryworld/blob/main/README.md Access the list of recognized difficulty levels programmatically. ```python from discoveryworld.ScenarioMaker import SCENARIO_DIFFICULTY_OPTIONS ``` -------------------------------- ### Constructing LLM Prompts for Dialog Source: https://github.com/allenai/discoveryworld/blob/main/README.md Logic for detecting if an agent is in a dialog state and formatting the prompt to request a JSON response. ```python # Dialog promptDialogStr = "" if (api.isAgentInDialog(agentIdx=0)): promptDialogStr = "*** NOTE: You are currently in a dialog. Please ignore the above instructions about choosing an action, and instead choose which option you would like to say in the dialog. ***\n" promptDialogStr = "For reference, here is the dialog that you are currently in:\n" promptDialogStr += "```json\n" dialog = observation["ui"]["dialog_box"] promptDialogStr += json.dumps(dialog, indent=4, sort_keys=True) promptDialogStr += "```\n" promptDialogStr = "The expected response format is JSON, in between code brackets (```), as a dictionary with a single key: `chosen_dialog_option_int` (as well as `memory` and `running_hypothesis`). The value should be an integer, corresponding to the dialog option you would like to select. You can write prose before the JSON code block, if that helps you think.\n" prompt += promptDialogStr ## Submit the prompt to the model response = submitLLMPrompt(prompt=prompt) ## TODO: Implement this function ## Parse the response into valid JSON actionJSON = json.loads(response) ## The action JSON is often in the following format: # actionJSON = { # "action": "USE", # "arg1": OBJ_UUID1, # "arg2": OBJ_UUID2 # } # Return the action JSON return actionJSON ``` -------------------------------- ### Update DiscoveryWorld Environment Source: https://github.com/allenai/discoveryworld/blob/main/README.md Manually update the environment state after submitting agent actions. ```python # Perform the world tick api.tick() ``` -------------------------------- ### Action JSON Format Source: https://github.com/allenai/discoveryworld/blob/main/agents/recoma/prompts/executer_prompt.txt The standard JSON structure required for defining actions in the executer prompt. ```json {"action": ..., "arg1": ...} ``` -------------------------------- ### Random Agent Output Format Source: https://github.com/allenai/discoveryworld/blob/main/agents/README.md The agent generates a JSON file containing summary statistics of the execution run. ```json { "agentName": "RandomAgent", "completed": 0, "completedSuccessfully": 0, "difficulty": "Challenge", "finalNormalizedScore": 0.0, "numSteps": 10, "scenario": "Space Sick", "seed": 0, "stepsPerSecond": 3.6337145107164717, "threadId": 6638643 } ``` -------------------------------- ### getAgentObservation(agentIdx) Source: https://github.com/allenai/discoveryworld/blob/main/README.md Retrieves the current observation for a specific agent, returning a dictionary containing environment state, UI information, and visual data. ```APIDOC ## getAgentObservation(agentIdx) ### Description Retrieves the current observation for a specific agent. The returned dictionary contains a 'ui' key with environment state information and a 'vision' key with base64 encoded images. ### Parameters - **agentIdx** (int) - Required - The index of the agent to retrieve observations for. ### Response - **ui** (dict) - Contains environment state keys: accessibleEnvironmentObjects, agentLocation, dialog_box, discoveryFeed, extended_action_message, inventoryObjects, lastActionMessage, nearbyAgents, nearbyObjects, taskProgress, world_steps. - **vision** (dict) - Contains base64 encoded images: base64_no_grid, base64_with_grid. - **errors** (list) - Contains error information if encountered. ``` -------------------------------- ### Export World History Logs Source: https://github.com/allenai/discoveryworld/blob/main/README.md Export detailed world state records to JSON files. Note that log files can be large and are split into 100-step parts. ```python # Example suffix logfileSuffix = "any-information-you-prefer-in-your-filename" # Save log file verboseLogDirectory = "logs/myagent-" + logFileSuffix logInfo = { "scenarioName": scenarioName, "difficulty": difficultyStr, "seed": seed, "numSteps": numSteps, "includeImages": includeImages, "exportVideo": exportVideo, "threadId": threadId, "dateStarted": time.strftime("%Y-%m-%d %H:%M:%S"), # Make a verbose filename for the log "verboseLogDirectory": verboseLogDirectory, "verboseLogFilename": verboseLogDirectory + "/" + "out-myagent-world" + logFileSuffix + ".json", } # Try to make the 'logs' directory, if it doesn't exist try: os.makedirs("logs") except FileExistsError: pass # Try to make the full directory try: os.makedirs(verboseLogDirectory) except FileExistsError: pass print("Saving world history...") try: api.world.exportWorldHistoryJSON(logInfo, logInfo["verboseLogFilename"], None, None, None) # Keyboard/ctrl-c interrupt except KeyboardInterrupt: print("Keyboard interrupt detected. Exiting.") exit(1) # Kill signal except SystemExit: print("System exit detected. Exiting.") exit(1) except Exception as e: print("Error saving world history: " + str(e)) ``` -------------------------------- ### performAgentAction(agentIdx, actionJSON) Source: https://github.com/allenai/discoveryworld/blob/main/README.md Executes a specific action for a given agent. The action is defined by an action name and its required arguments. ```APIDOC ## performAgentAction(agentIdx, actionJSON) ### Description Performs an action for the specified agent. This function is analogous to the step() function in the OpenAI Gym API. ### Parameters - **agentIdx** (int) - Required - The index of the agent performing the action. - **actionJSON** (dict) - Required - A dictionary containing the 'action' name and arguments ('arg1', 'arg2'). ### Request Example { "action": "USE", "arg1": "uuid-123", "arg2": "uuid-456" } ``` -------------------------------- ### Retrieve Agent Observation Source: https://github.com/allenai/discoveryworld/blob/main/README.md Call this function to obtain the current state of the agent's environment. ```python observation = api.getAgentObservation(agentIdx=0) ``` -------------------------------- ### BibTeX Citation for DiscoveryWorld Source: https://github.com/allenai/discoveryworld/blob/main/index.html Use this BibTeX entry to cite the DiscoveryWorld paper in LaTeX documents. ```bibtex @inproceedings{ jansen2024discoveryworld, title={DiscoveryWorld: A Virtual Environment for Developing and Evaluating Automated Scientific Discovery Agents}, author={Peter Jansen and Marc-Alexandre C{\^o}t{\'e} and Tushar Khot and Erin Bransom and Bhavana Dalvi Mishra and Bodhisattwa Prasad Majumder and Oyvind Tafjord and Peter Clark}, booktitle={The Thirty-eight Conference on Neural Information Processing Systems Datasets and Benchmarks Track}, year={2024}, url={https://openreview.net/forum?id=cDYqckEt6d} } ``` -------------------------------- ### Retrieve Task Scorecard Source: https://github.com/allenai/discoveryworld/blob/main/README.md Accesses the current performance scorecard for the agent's task. ```python scorecard = api.getTaskScorecard() ``` -------------------------------- ### getTaskScorecard() Source: https://github.com/allenai/discoveryworld/blob/main/README.md Retrieves the current task scorecard containing performance metrics and task status. ```APIDOC ## getTaskScorecard() ### Description Returns the current scorecard for the agent's performance on a task. ### Response - **taskName** (string) - Internal unique name of the task. - **taskDescription** (string) - Plain-text description of the task. - **completed** (boolean) - Whether the task has been completed. - **completedSuccessfully** (boolean) - Whether the task was completed successfully. - **scoreNormalized** (float) - Normalized (0-1) partial progress score. - **scoreCard** (list) - List of specific subgoals and their status. - **criticalQuestions** (set) - Binary questions regarding accumulated knowledge. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.