Files
factorio-learning-environment/data/prompts/finetuning_prompts/user_message.md
kiankyars a62f7f208c Restructure (#274)
* add changes

* refactor: clean up unused Docker scripts and redundant files

Remove unused and redundant files from fle/cluster/docker/:

- main.py: Redundant Python script that duplicates run_local.sh functionality
  with hardcoded ports and basic container management. Not used in workflow.

- install-docker.sh: AWS EC2-specific setup script with hardcoded instance
  (ec2-18-133-239-115) and outdated Amazon Linux commands. Current workflow
  uses docker-compose instead.

- probe.sh: Simple port checking script using lsof. Redundant since
  docker-compose handles health checks and container status monitoring.

- setup_docker_repo.sh: AWS ECR-specific setup with hardcoded AWS account
  (216370203482). Contains mostly commented code and unused ECR repository
  configuration. Not used in current workflow.

- requirements.txt: Redundant Python dependency file. Docker is a system
  dependency, not a Python package. The Python docker SDK is already
  included in pyproject.toml dependencies.

Kept essential files: Dockerfile, build scripts, run scripts, config/,
mods/, and README.md which are actively used in the Docker workflow.

* refactor: move lib/ and tools/ to mods/, clean up fle/env/utils/ (all deleted files were unused), prep for entrypoints/ refactor

* readd

* last undo

* refactor: move evaluator.py to algorithms/mcts, move experiment entrypoints to entrypoints/, update imports accordingly

* version info

* incorrect gitignore

* style: replace all relative imports in fle.agents with absolute imports

* simplify gitignore

* commit

* gitignore

* redo

* update

* No code is importing the fle.agents.data package/module

* exclude data/prompts from ruff lint/format in pre-commit

* yaml

* Files were cleared but not deleted

* finalize Neel's suggestions

* Jul 12, 2025 at 13:29

* Jul 12, 2025 at 15:47

* push

* Jul 12, 2025 at 16:03

* Jul 12, 2025 at 16:03

* Jul 12, 2025 at 16:03

* fix

* fix

* fix

* push

* push

* Jul 12, 2025 at 17:48

* remove publish on merge
2025-07-17 17:12:47 +03:00

7.5 KiB

Use the API to write a Python script to achieve the objective given. Analyse the scripts that have been run and their error messages and use them to create a working script. Here is an example of an objective, a script that failed and the ERROR ANALYSIS and ERROR CORRECTION stages

EXAMPLE USER INPUT Objective: Create an automated copper transportation system from a mining drill to a chest that is away from the drill. The final setup should be checked by looking if the chest has copper in their inventory. The initial inventory is {{'iron-plate': 50, 'coal': 100, 'copper-plate': 50, 'iron-chest': 2, 'burner-mining-drill': 3, 'electric-mining-drill': 1, 'assembling-machine-1': 1, 'stone-furnace': 9, 'transport-belt': 500, 'boiler': 1, 'burner-inserter': 32, 'pipe': 15, 'steam-engine': 1, 'small-electric-pole': 10, 'wooden-chest': 1, 'iron-gear-wheel': 3, 'electronic-circuit': 3, 'offshore-pump': 1}}"

LATEST SCRIPT RUN python\n# [PLANNING] We need to first place the drill on a copper patch and fuel it with coal\n# Then we need to place a chest at a distance from the drill, add an inserter next to the chest and rotate it towards the chest\n# Finally we need to connect the drill drop position to the inserter pickup position with transport belts [END OF PLANNING]\n# Find nearest copper patch\ncopper_position = nearest(Resource.CopperOre)\nmove_to(copper_position)\ncopper_patch = get_resource_patch(Resource.CopperOre, copper_position, radius=10)\nassert copper_patch, "No copper patch found within radius"\nprint(f"Copper patch found at {{copper_patch.bounding_box.center}}")\n\n# Place burner mining drill on copper patch\ndrill = place_entity(Prototype.BurnerMiningDrill, Direction.DOWN, copper_patch.bounding_box.center)\nassert drill, "Failed to place burner mining drill"\nprint(f"Burner mining drill placed at {{drill.position}}")\n\n# Fuel burner mining drill with coal\ndrill_with_coal = insert_item(Prototype.Coal, drill, quantity=5)\nassert drill_with_coal.fuel_inventory.get(Prototype.Coal) > 0, "Failed to fuel burner mining drill"\n\n# Place wooden chest away from the drills drop position in direction down \nchest_pos = Position(x=drill.position.x , y=drill.position.y - 6) # Adjusted for spacing\nchest = place_entity(Prototype.WoodenChest, Direction.UP, chest_pos)\nassert chest is not None, f"Failed to place wooden chest at {{chest_pos}}"\nprint(f"Wooden chest placed at {{chest.position}}")\n\n# add inserter next to the chest facing towards it\ninserter_chest = place_entity_next_to(Prototype.BurnerInserter,\n reference_position=chest.position,\n direction=Direction.DOWN,\n spacing=0)\n\nassert inserter_chest is not None , "Failed to place inserter"\nprint(f"Inserter placed at {{inserter_chest.position}}")\ninsert_item(Prototype.Coal,inserter_chest ,quantity = 2)\n\n# Connect drills drop position and chests inserters pickup position with transport belts \nbelts_placed = connect_entities(drill.drop_position,inserter_chest.pickup_position , Prototype.TransportBelt)\nassert belts_placed is not None and len(belts_placed) > 0 , "Failed to connect entities"\n\nsleep(10) # Wait for some resources to be produced\n\nmax_attempts = 5\nfor _ in range(max_attempts):\n inventory_after_sleep = inspect_inventory(chest)\n if inventory_after_sleep.get(Prototype.CopperOre) >= 1:\n break\n sleep(10) # Wait a bit more if no resources are ready\n\nfinal_inventory_check = inspect_inventory(chest).get(Prototype.CopperOre)\nassert final_inventory_check >= 1 , f"No Copper ore was produced after maximum wait time. Check fuel levels or connections."\nprint("Successfully created automated Copper production system!")

ERROR MESSAGE Error at lines 37-37: ('Could not connect transport-belt from x=25.5 y=26.5 to x=25.5 y=19.5.', '[string "-- connect_entities.lua..."]:152: Cannot place entity at position (25.5, 19.5) due to overlapping wooden-chest.')'

EXAMPLE OUTPUT ERROR ANALYSIS Analysing the script it seems that the inserter was not rotated. To put items into the chest we need to rotate the inserter as by default when placed next to an entity the inserter takes items from the entity not puts items to it. Thus we need to add one extra step after placing the entity that is rotation of the inserter ERROR CORRECTION python\n# [PLANNING] We need to first place the drill on a copper patch and fuel it with coal\n# Then we need to place a chest at a distance from the drill, add an inserter next to the chest and rotate it towards the chest\n# Finally we need to connect the drill drop position to the inserter pickup position with transport belts [END OF PLANNING]\n# Find nearest copper patch\ncopper_position = nearest(Resource.CopperOre)\nmove_to(copper_position)\ncopper_patch = get_resource_patch(Resource.CopperOre, copper_position, radius=10)\nassert copper_patch, "No copper patch found within radius"\nprint(f"Copper patch found at {{copper_patch.bounding_box.center}}")\n\n# Place burner mining drill on copper patch\ndrill = place_entity(Prototype.BurnerMiningDrill, Direction.DOWN, copper_patch.bounding_box.center)\nassert drill, "Failed to place burner mining drill"\nprint(f"Burner mining drill placed at {{drill.position}}")\n\n# Fuel burner mining drill with coal\ndrill_with_coal = insert_item(Prototype.Coal, drill, quantity=5)\nassert drill_with_coal.fuel_inventory.get(Prototype.Coal) > 0, "Failed to fuel burner mining drill"\n\n# Place wooden chest away from the drills drop position in direction down \nchest_pos = Position(x=drill.position.x , y=drill.position.y - 6) # Adjusted for spacing\nchest = place_entity(Prototype.WoodenChest, Direction.UP, chest_pos)\nassert chest is not None, f"Failed to place wooden chest at {{chest_pos}}"\nprint(f"Wooden chest placed at {{chest.position}}")\n\n# add inserter next to the chest facing towards it\ninserter_chest = place_entity_next_to(Prototype.BurnerInserter,\n reference_position=chest.position,\n direction=Direction.DOWN,\n spacing=0)\n\nassert inserter_chest is not None , "Failed to place inserter"\nprint(f"Inserter placed at {{inserter_chest.position}}")\n# We need to rotate the inserter as it currently is taking from the chest not putting into it\n# The direction is up as the inserter is put down from the chest the chest\ninserter_chest = rotate_entity(inserter_chest, Direction.UP)\n# We also need to fuel the inserter\ninsert_item(Prototype.Coal,inserter_chest ,quantity = 2)\n\n# Connect drills drop position and chests inserters pickup position with transport belts \nbelts_placed = connect_entities(drill.drop_position,inserter_chest.pickup_position , Prototype.TransportBelt)\nassert belts_placed is not None and len(belts_placed) > 0 , "Failed to connect entities"\n\nsleep(10) # Wait for some resources to be produced\n\nmax_attempts = 5\nfor _ in range(max_attempts):\n inventory_after_sleep = inspect_inventory(chest)\n if inventory_after_sleep.get(Prototype.CopperOre) >= 1:\n break\n sleep(10) # Wait a bit more if no resources are ready\n\nfinal_inventory_check = inspect_inventory(chest).get(Prototype.CopperOre)\nassert final_inventory_check >= 1 , f"No Copper ore was produced after maximum wait time. Check fuel levels or connections."\nprint("Successfully created automated Copper production system!")\n\n

USER INPUT {objective}

PREVIOUS SCRIPTS WITH ERROR MESSAGES {error_history}

LATEST SCRIPT RUN {last_executed_policy}

ERROR MESSAGE {error_message}