npx prettier (#285)
Some checks failed
Lint and Format / lint (push) Has been cancelled

* npx prettier

* main

* final formatting

* formatting
This commit is contained in:
kiankyars
2025-08-18 16:43:34 +03:00
committed by GitHub
parent 956db04490
commit d3dd325792
142 changed files with 1192 additions and 704 deletions

View File

@@ -9,6 +9,7 @@ uv build
```
This will:
1. Create the package structure
2. Build a wheel (.whl) in the `dist/` directory
@@ -48,4 +49,4 @@ from fle import env
# Access modules
env_instance = env.Instance()
```
```

View File

@@ -23,7 +23,7 @@ We welcome contributions to the Factorio Learning Environment! Here's how you ca
1. Ensure your code passes all existing tests
2. Add tests for new functionality
3. Update documentation as needed
3. If documentation changes were made, run: `npx prettier --write **/*.md`
4. Link any related issues in your pull request description
5. Wait for review from maintainers
@@ -55,6 +55,7 @@ When implementing new agents:
6. Provide baseline performance metrics on standard tasks (128 steps) and open-world scenarios (3,000 steps).
Key considerations:
- Handle context management for long episodes
- Implement proper error handling and recovery
- Document any assumptions about the environment
@@ -83,6 +84,7 @@ When adding new evaluation tasks:
6. Add test cases in `eval/tasks/tests/`
Best practices:
- Design clear, measurable success criteria
- Include progressive difficulty levels
- Provide example solutions
@@ -116,4 +118,4 @@ All submissions require review. We use GitHub pull requests for this purpose:
- Help others in the community
- Provide constructive feedback
- Follow the code of conduct
- Build an enormous factory
- Build an enormous factory

357
README.md
View File

@@ -13,25 +13,26 @@ An open source framework for developing and evaluating LLM agents in the game of
</p>
<p align="center"><em>Claude 3.5 plays Factorio</em></p>
## Why FLE?
[//]: # (FLE is a framework that tests agent capabilities in long-term planning, program synthesis, and resource optimization against a set of exponentially scaling challenges, ranging from basic automation to complex factories processing millions of resources per second. )
[//]: # "FLE is a framework that tests agent capabilities in long-term planning, program synthesis, and resource optimization against a set of exponentially scaling challenges, ranging from basic automation to complex factories processing millions of resources per second. "
We provide two settings:
1. **Lab-play**: 24 structured tasks with fixed resources.
2. **Open-play** An unbounded task of building the largest possible factory on a procedurally generated map.
2. **Open-play** An unbounded task of building the largest possible factory on a procedurally generated map.
Our results demonstrate that models still lack strong spatial reasoning. In lab-play, we find that while LLMs
exhibit promising short-horizon skills, they are unable to operate effectively in constrained environments, reflecting limitations in error analysis. In open-play, while LLMs discover automation strategies that improve growth (e.g electric-powered drilling), they fail to achieve complex
automation (e.g electronic-circuit manufacturing).
exhibit promising short-horizon skills, they are unable to operate effectively in constrained environments, reflecting limitations in error analysis. In open-play, while LLMs discover automation strategies that improve growth (e.g electric-powered drilling), they fail to achieve complex
automation (e.g electronic-circuit manufacturing).
## Updates
- [08/5/2025] [Blog](https://jackhopkins.github.io/factorio-learning-environment/release.0.2.0): Added support for multi-agent coordination and MCP allowing reasoning models to invoke tools within their reasoning chain
- [15/4/2025] Added a visual agent, that takes a rendering of the map as an additional input.
## Quick Links
- [Installation](#installation)
- [Environment](#environment)
- [Agents](#agents)
@@ -46,8 +47,9 @@ automation (e.g electronic-circuit manufacturing).
## Installation
### Prerequisites
- [Factorio](https://www.factorio.com/) (version 1.1.110)
- Docker
- Docker
- Python 3.10+
### Package Installation
@@ -101,6 +103,7 @@ FLE can also be used as a gym environment for reinforcement learning experiments
- Once connected, you can safely disconnect. This step confirms your Factorio license with the server.
### Troubleshooting
- **"No valid programs found for version X"**: This is normal during initialization. The system will start generating programs shortly.
- **Database connection errors**: Verify your database configuration in the .env file and ensure the database exists.
- **Docker issues**: Ensure your user has permission to run Docker without sudo.
@@ -109,10 +112,10 @@ FLE can also be used as a gym environment for reinforcement learning experiments
- For Linux:
- Start Docker daemon with `sudo systemctl start docker`
- If you typically run Docker with sudo, add your user to the docker group:
```bash
sudo usermod -aG docker $USER
newgrp docker
```
```bash
sudo usermod -aG docker $USER
newgrp docker
```
- **Connection issues**: Make sure the Factorio server is running and ports are properly configured.
## Environment
@@ -120,6 +123,7 @@ FLE can also be used as a gym environment for reinforcement learning experiments
FLE is an agent evaluation environment built on the game of Factorio, a popular resource management simulation game.
Agents interact with **FLE** by code synthesis through a **REPL** (Read-Eval-Print-Loop) pattern:
1. **Observation**: The agent observes the world through the output streams (stderr/stdout) of their last program.
2. **Action**: The agent generates a Python program to perform their desired action.
3. **Feedback**: The environment executes the program, assigns variables, add classes/functions to the namespace, and provides an output stream.
@@ -178,10 +182,9 @@ print(get_entities())
</body>
</html>
Agents are provided with the Python standard library, and an API comprising [tools](#tool-documentation) that they can use.
Tools are functions that perform a game action and return a typed object (e.g an Inventory), which can be stored as a named **variable** in the Python namespace for later use.
Tools are functions that perform a game action and return a typed object (e.g an Inventory), which can be stored as a named **variable** in the Python namespace for later use.
The namespace acts as an episodic symbolic memory system, and saved objects represent an observation of the environment at the moment of query.
@@ -189,11 +192,12 @@ This enables agents to maintain complex state representations and build hierarch
Agents observe **stdout** and **stderr** - the output streams of their program. Agents may intentionally choose to print relevant objects and computations to the output stream to construct observations.
Mistakes in the code or invalid operations raise typed **exceptions** with detailed context that is written to stderr.
Mistakes in the code or invalid operations raise typed **exceptions** with detailed context that is written to stderr.
This enables agents to reactively debug their programs after execution, and proactively use runtime assertions during execution to self-verify their actions.
This enables agents to reactively debug their programs after execution, and proactively use runtime assertions during execution to self-verify their actions.
Agents are able to enhance their internal representation of the game state by defining:
Agents are able to enhance their internal representation of the game state by defining:
1. Utility functions for reuse throughout an episode, to encapsulate previously successful logic
2. Classes in the namespace to better organize the data retrieved from the game.
@@ -201,15 +205,16 @@ Agents are able to enhance their internal representation of the game state by de
The Factorio Learning Environment provides a straightforward agent architecture for developing and evaluating AI models that can play Factorio.
Agents operate in *episodes*, with each step involving observation, planning, and action execution through Python code synthesis.
Agents operate in _episodes_, with each step involving observation, planning, and action execution through Python code synthesis.
The agent maintains state through a conversation history that includes its actions (_assistant_) and the stdout/stderr from the environment (_user_).
At each step, agents generate Python code policies that are executed in the environment.
### Anatomy of an Agent
Agents live in `agents`, and implement an abstract base class (AgentABC) that defines the core interface for interacting with the environment.
Agents live in `agents`, and implement an abstract base class (AgentABC) that defines the core interface for interacting with the environment.
The abstract base class defines two methods that all agents must implement:
```
# Generates the next action based on conversation history and environment response (including score / achievements etc).
step(conversation: Conversation, response: Response) -> Policy:
@@ -221,7 +226,8 @@ end(conversation: Conversation, completion: CompletionState) -> None:
Each agent takes input a task (discussed in the next section) which specifies the goal of the agent.
Our default agent is `BasicAgent`, which incorporates some basic mechanisms for managing context over long (+1000 step) runs:
1. Every 32 steps, the all older interactions are summarised into a report in the system message.
1. Every 32 steps, the all older interactions are summarised into a report in the system message.
2. Conversations are clipped to remain under 200k characters (~87k tokens).
3. We strip out all _historical_ observations of game entities, as this both fills up the context, and confuses the agent.
@@ -236,14 +242,14 @@ class MinimalAgent(AgentABC):
"""
This is a minimal Agent implementation, which takes the current conversation (including the most recent response)
and generates a simple Python code policy to execute the next step.
Note: This will blow up context length on longer runs, without some context pruning/management.
"""
def __init__(self, model, system_prompt, goal_description, *args, **kwargs):
system_prompt += f"\n\n### Goal\n{goal_description}\n\n"
super().__init__(model, system_prompt, *args, **kwargs)
self.llm_factory = LLMFactory(model)
@tenacity.retry(
retry=retry_if_exception_type(Exception),
wait=wait_exponential(multiplier=1, min=4, max=10)
@@ -257,7 +263,7 @@ class MinimalAgent(AgentABC):
max_tokens=self.generation_params.max_tokens,
model=self.generation_params.model,
)
# Parse LLM response into a Policy object
policy = parse_response(response)
if not policy:
@@ -274,9 +280,11 @@ class MinimalAgent(AgentABC):
Each agent is given a `task`, which specifies the goal the agent will carry out in FLE. A task consists of a task object defining the core interface of the task category and a json file specifying the parameters of the task.
### Anatomy of a Task
Tasks live in `eval/tasks`, and implement an abstract base class in `eval/tasks/task_abc.py` that defines the core interface for defining the task, setting up the environment and verifying success
The abstract base class defines three methods that all tasks must implement:
```
verify(self, score: float, step: int, instance: FactorioInstance, step_statistics: Dict) -> bool:
""" Return true if the task is completed"""
@@ -289,24 +297,26 @@ enhance_response_with_task_output(self, response: str, task_response: TaskRespon
```
We provide two default tasks:
We provide two default tasks:
1. OpenPlayTask - Task for the open-play setting, where the agent plays the game until a specified number of steps is finished. The verify function will always return False
2. ThroughputTask - Task for requiring the agent to build a factory that achieves a specified throughput in the holdout period. The verify function will return True if the holdout period throughput is above the threshold
3. UnboundedThroughputTask - Task for the agent to create a factory that maximises the throughput of a target entity in a specified number of timesteps. The verify function will always return False until the number of steps is reached
The task jsons specifies the "task_type" and the "config" parameters. `task_type` specifies the mapping from the json to the task type (the creation of task objects from the json is done in `eval\tasks\task_factory.py`). `config` specifies all required attributes to substantiate the respective task object. Each config must at minimum define the "goal_description", "trajectory_length" and "task_key" parameters.
Examples of task json
The task jsons specifies the "task_type" and the "config" parameters. `task_type` specifies the mapping from the json to the task type (the creation of task objects from the json is done in `eval\tasks\task_factory.py`). `config` specifies all required attributes to substantiate the respective task object. Each config must at minimum define the "goal_description", "trajectory_length" and "task_key" parameters.
Examples of task json
```
# Open play task json
{ "task_type": "default",
"config": {
"config": {
"goal_description":"- Build the biggest possible factory\n- Maximise automation, efficiency and scale",
"trajectory_length": 5000,
"task_key": "open_play"
}
}
# One example of a throughput task json
{
{
"task_type": "throughput",
"config":
{"goal_description":"Create an automatic iron gear wheel factory that produces 16 iron gear wheel per 60 ingame seconds",
@@ -319,18 +329,20 @@ Examples of task json
}
```
Example open play task object can be seen below. The throughput task object can be found here `eval/tasks/throughput_task.py`
```
class OpenPlayTask(TaskABC):
def __init__(self, trajectory_length, goal_description: str, task_key: str):
super().__init__(trajectory_length, starting_inventory = {}, goal_description=goal_description, task_key = task_key)
self.starting_game_state = None
def verify(self, score: float, instance: FactorioInstance, step_statistics: Dict) -> TaskResponse:
return TaskResponse(success = False,
meta = {})
def _to_dict(self) -> Dict[str, Any]:
return {
"goal_description": self.goal_description,
@@ -345,20 +357,21 @@ class OpenPlayTask(TaskABC):
```
### Running tasks
The entrypoint to run tasks is `env/src/gym_env/run_eval.py` which reads in a run config json file, runs the tasks specified in parallel and saves each generated program with the environment output and task verification result into the database. The location of the run config json is sent in through the `--run_config` inline argument. If no argument is sent, the default run config `eval/open/independent_runs/gym_run_config.json` is used.
The entrypoint to run tasks is `env/src/gym_env/run_eval.py` which reads in a run config json file, runs the tasks specified in parallel and saves each generated program with the environment output and task verification result into the database. The location of the run config json is sent in through the `--run_config` inline argument. If no argument is sent, the default run config `eval/open/independent_runs/gym_run_config.json` is used.
The run config json is a list of dictionaries specifying the gym environment ID, model and version (optional). One example to run 2s tasks in parallel:
```json
[
{
"env_id": "Factorio-iron_ore_throughput_16-v0",
"model": "claude-3-5-sonnet-latest",
},
{
"env_id": "Factorio-open_play-v0",
"model": "claude-3-5-sonnet-latest"
}
{
"env_id": "Factorio-iron_ore_throughput_16-v0",
"model": "claude-3-5-sonnet-latest"
},
{
"env_id": "Factorio-open_play-v0",
"model": "claude-3-5-sonnet-latest"
}
]
```
@@ -468,6 +481,7 @@ python env/src/gym_env/example_usage.py --gym-format
All environments follow the standard gym interface:
**Action Space**
```python
{
'agent_idx': Discrete(num_agents), # Which agent takes the action
@@ -477,6 +491,7 @@ All environments follow the standard gym interface:
**Observation Space**
The observation space includes:
- `raw_text`: Output from the last action
- `entities`: List of entities on the map
- `inventory`: Current inventory state
@@ -490,6 +505,7 @@ The observation space includes:
- `serialized_functions`: Available functions
**Methods**
- `reset(state: Optional[GameState] = None) -> Dict[str, Any]`
- `step(action: Dict[str, Any]) -> Tuple[Dict[str, Any], float, bool, Dict[str, Any]]`
- `close() -> None`
@@ -537,7 +553,7 @@ for step in range(5):
}
obs, reward, done, info = env.step(action)
print(f"Step {step}: Reward={reward}, Done={done}")
if done:
break
@@ -554,16 +570,17 @@ To add a new task:
3. The registry will automatically discover and register the new environment
**Task Definition Format**
```json
{
"task_type": "throughput",
"config": {
"goal_description": "Create an automatic iron ore factory...",
"throughput_entity": "iron-ore",
"quota": 16,
"trajectory_length": 128,
"task_key": "iron_ore_throughput_16"
}
"task_type": "throughput",
"config": {
"goal_description": "Create an automatic iron ore factory...",
"throughput_entity": "iron-ore",
"quota": 16,
"trajectory_length": 128,
"task_key": "iron_ore_throughput_16"
}
}
```
@@ -601,6 +618,7 @@ action2 = {'agent_idx': 1, 'code': 'print("Agent 1 action")'}
#### Error Handling
The registry includes error handling for:
- Missing task definition files
- Invalid JSON configurations
- Missing Factorio containers
@@ -613,6 +631,7 @@ If an environment fails to load, a warning will be printed but the registry will
**Environment Creation Fails**
If `gym.make()` fails with connection errors:
1. Ensure Factorio containers are running
2. Check that the cluster setup is working
3. Verify network connectivity
@@ -620,6 +639,7 @@ If `gym.make()` fails with connection errors:
**No Environments Found**
If no environments are listed:
1. Check that the task definitions directory exists
2. Verify JSON files are valid
3. Check file permissions
@@ -627,6 +647,7 @@ If no environments are listed:
**Import Errors**
If you get import errors:
1. Ensure you're running from the correct directory
2. Check that all dependencies are installed
3. Verify the Python path includes the project root
@@ -647,13 +668,16 @@ For backward compatibility, you can still use the legacy task-based configuratio
```json
[
{"task": "iron_gear_wheel_throughput_16.json",
{
"task": "iron_gear_wheel_throughput_16.json",
"model": "gpt-4o-mini-2024-07-18",
"version": 768},
{"task": "plastic_bar_throughput_16.json",
"model": "anthropic/claude-3.5-sonnet-open-router"},
{"task": "open_play.json",
"model": "gpt-4o-mini-2024-07-18"}
"version": 768
},
{
"task": "plastic_bar_throughput_16.json",
"model": "anthropic/claude-3.5-sonnet-open-router"
},
{ "task": "open_play.json", "model": "gpt-4o-mini-2024-07-18" }
]
```
@@ -666,43 +690,47 @@ The Factorio Learning Environment supports multiagent experiments where multiple
### 1. Task Configuration
Multiagent tasks are defined in JSON files under `eval/tasks/task_definitions/multiagent/`. Each task can specify:
- A shared goal description for all agents
- Agent-specific instructions for each agent
- Number of agents required
- Other task parameters (trajectory length, holdout period, etc.)
Example task configuration:
```json
{
"task_type": "unbounded_throughput",
"config": {
"goal_description": "Create an automatic iron plate factory...",
"agent_instructions": [
"You are Agent 1. Your role is to mine coal.",
"You are Agent 2. Your role is to mine iron."
],
"throughput_entity": "iron-plate",
"trajectory_length": 16,
"holdout_wait_period": 60
}
"task_type": "unbounded_throughput",
"config": {
"goal_description": "Create an automatic iron plate factory...",
"agent_instructions": [
"You are Agent 1. Your role is to mine coal.",
"You are Agent 2. Your role is to mine iron."
],
"throughput_entity": "iron-plate",
"trajectory_length": 16,
"holdout_wait_period": 60
}
}
```
### 2. Run Configuration
Create a run configuration file in `eval/open/independent_runs/multiagent/` that specifies:
- The task file to use
- The model to use for each agent
- Number of agents
Example run configuration:
```json
[
{
"task": "multiagent/iron_plate_throughput_free.json",
"model": "claude-3-5-sonnet-latest",
"num_agents": 2
}
{
"task": "multiagent/iron_plate_throughput_free.json",
"model": "claude-3-5-sonnet-latest",
"num_agents": 2
}
]
```
@@ -711,11 +739,13 @@ Example run configuration:
The Agent-to-Agent (A2A) protocol server enables communication between multiple AI agents in the Factorio environment. Here's how to set it up:
1. **Install Dependencies**:
```bash
pip install fastapi uvicorn aiohttp
```
2. **Start the A2A Server**:
```bash
# Start the server on default host (localhost) and port (8000)
python env/src/protocols/a2a/server.py
@@ -725,6 +755,7 @@ python env/src/protocols/a2a/server.py --host 127.0.0.1 --port 8000
```
3. **Run the Experiment**:
```bash
python eval/open/independent_runs/run.py --config eval/open/independent_runs/multiagent/your_config.json
```
@@ -732,11 +763,13 @@ python eval/open/independent_runs/run.py --config eval/open/independent_runs/mul
### 4. Agent Communication
Agents can communicate with each other using the `send_message()` tool. Each agent's system prompt includes instructions about:
- Their role in the multiagent setup
- How to communicate with other agents
- When to send messages (start/end of programs)
The A2A server handles:
- Agent registrations
- Message routing between agents
- Agent discovery and capability negotiation
@@ -751,6 +784,7 @@ The codebase includes several example multiagent scenarios:
3. **Impostor Scenario**: One agent tries to sabotage while the other tries to maintain the factory
To run these examples, use the provided configuration files:
- `claude_lab_free.json`: Cooperative scenario
- `claude_lab_distrust.json`: Distrust scenario
- `claude_lab_impostor.json`: Impostor scenario
@@ -758,6 +792,7 @@ To run these examples, use the provided configuration files:
### 6. Troubleshooting
If you encounter issues:
- Ensure the A2A server is running before starting agent instances
- Check that the server port (default 8000) is not blocked by a firewall
- Verify agent registration in the server logs
@@ -772,10 +807,10 @@ Agents interact with the game using _tools_, which represent a narrow API into t
Tools live in `env/src/tools`, and are either `admin` tools (non-agent accessible) or `agent` tools (used by the agent).
A tool requires 3 files:
1. `agent.md`: The agent documentation for the tool, including usage patterns, best practices and failure modes.
2. `client.py`: The client-side implementation, which is a Python class that can be invoked by the agent.
3. `server.lua`: The server-side implementation, which handles most of the logic and heavy lifting.
3. `server.lua`: The server-side implementation, which handles most of the logic and heavy lifting.
```mermaid
---
@@ -788,7 +823,7 @@ config:
flowchart LR
A("fa:fa-comment-dots Agent")
subgraph s1["Learning Environment"]
B("fa:fa-code Interpreter")
n1("client.py")
end
@@ -798,12 +833,12 @@ flowchart LR
end
A -- Synthesises Python --> B
B -- Invokes --> n1
B -- Invokes --> n1
n1 -. Exceptions .-> B
n1 -. Objects .-> B
n1 --Remote TCP Call--> E1
E1 -- Execute --> F
F-. Result .-> E1
E1 -. TCP Response .-> n1
B -. Observation .-> A
@@ -818,39 +853,41 @@ flowchart LR
Next time you run an eval, the tool will automatically be available to the agent and documented in the agent context.
5. (Optional) Create a test suite in `env/tests/actions` for your new tool.
5. (Optional) Create a test suite in `env/tests/actions` for your new tool.
### Core Tools
| Tool | Description | Key Features |
|------|--------------------------------------------------|--------------|
| `inspect_inventory` | Checks contents of player or entity inventories | - Supports various inventory types (chests, furnaces, etc.)<br>- Returns Inventory object with count methods<br>- Can query specific items |
| `insert_item` | Places items from player inventory into entities | - Works with machines, chests, belts<br>- Validates item compatibility<br>- Returns updated entity |
| `extract_item` | Removes items from entity inventories | - Supports all inventory types<br>- Auto-transfers to player inventory<br>- Returns quantity extracted |
| `place_entity` | Places entities in the world | - Handles direction and positioning<br>- Validates placement requirements<br>- Returns placed Entity object |
| `place_entity_next_to` | Places entities relative to others | - Automatic spacing/alignment<br>- Handles entity dimensions<br>- Supports all entity types |
| `pickup_entity` | Removes entities from the world | - Returns items to inventory<br>- Handles entity groups<br>- Supports all placeable items |
| `rotate_entity` | Changes entity orientation | - Affects entity behavior (e.g., inserter direction)<br>- Validates rotation rules<br>- Returns updated entity |
| `get_entity` | Retrieves entity objects at positions | - Updates stale references<br>- Returns typed Entity objects<br>- Handles all entity types |
| `get_entities` | Finds multiple entities in an area | - Supports filtering by type<br>- Returns List[Entity]<br>- Groups connected entities |
| `nearest` | Locates closest resources/entities | - Finds ores, water, trees<br>- Returns Position object<br>- 500 tile search radius |
| `get_resource_patch` | Analyzes resource deposits | - Returns size and boundaries<br>- Supports all resource types<br>- Includes total resource amount |
| `harvest_resource` | Gathers resources from the world | - Supports ores, trees, rocks<br>- Auto-collects to inventory<br>- Returns amount harvested |
| `connect_entities` | Creates connections between entities | - Handles belts, pipes, power<br>- Automatic pathfinding<br>- Returns connection group |
| `get_connection_amount` | Calculates required connection items | - Pre-planning tool<br>- Works with all connection types<br>- Returns item count needed |
| `set_entity_recipe` | Configures machine crafting recipes | - Works with assemblers/chemical plants<br>- Validates recipe requirements<br>- Returns updated entity |
| `get_prototype_recipe` | Retrieves crafting requirements | - Shows ingredients/products<br>- Includes crafting time<br>- Returns Recipe object |
| `craft_item` | Creates items from components | - Handles recursive crafting<br>- Validates technology requirements<br>- Returns crafted amount |
| `set_research` | Initiates technology research | - Validates prerequisites<br>- Returns required ingredients<br>- Handles research queue |
| `get_research_progress` | Monitors research status | - Shows remaining requirements<br>- Tracks progress percentage<br>- Returns ingredient list |
| `move_to` | Moves player to position | - Pathfinds around obstacles<br>- Can place items while moving<br>- Returns final position |
| `nearest_buildable` | Finds valid building locations | - Respects entity dimensions<br>- Handles resource requirements<br>- Returns buildable position |
| `sleep` | Pauses execution | - Waits for actions to complete<br>- Adapts to game speed<br>- Maximum 15 second duration |
| `launch_rocket` | Controls rocket silo launches | - Validates launch requirements<br>- Handles launch sequence<br>- Returns updated silo state |
| `print` | Outputs debug information to stdout | - Supports various object types<br>- Useful for monitoring state<br>- Returns formatted string |
| Tool | Description | Key Features |
| ----------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `inspect_inventory` | Checks contents of player or entity inventories | - Supports various inventory types (chests, furnaces, etc.)<br>- Returns Inventory object with count methods<br>- Can query specific items |
| `insert_item` | Places items from player inventory into entities | - Works with machines, chests, belts<br>- Validates item compatibility<br>- Returns updated entity |
| `extract_item` | Removes items from entity inventories | - Supports all inventory types<br>- Auto-transfers to player inventory<br>- Returns quantity extracted |
| `place_entity` | Places entities in the world | - Handles direction and positioning<br>- Validates placement requirements<br>- Returns placed Entity object |
| `place_entity_next_to` | Places entities relative to others | - Automatic spacing/alignment<br>- Handles entity dimensions<br>- Supports all entity types |
| `pickup_entity` | Removes entities from the world | - Returns items to inventory<br>- Handles entity groups<br>- Supports all placeable items |
| `rotate_entity` | Changes entity orientation | - Affects entity behavior (e.g., inserter direction)<br>- Validates rotation rules<br>- Returns updated entity |
| `get_entity` | Retrieves entity objects at positions | - Updates stale references<br>- Returns typed Entity objects<br>- Handles all entity types |
| `get_entities` | Finds multiple entities in an area | - Supports filtering by type<br>- Returns List[Entity]<br>- Groups connected entities |
| `nearest` | Locates closest resources/entities | - Finds ores, water, trees<br>- Returns Position object<br>- 500 tile search radius |
| `get_resource_patch` | Analyzes resource deposits | - Returns size and boundaries<br>- Supports all resource types<br>- Includes total resource amount |
| `harvest_resource` | Gathers resources from the world | - Supports ores, trees, rocks<br>- Auto-collects to inventory<br>- Returns amount harvested |
| `connect_entities` | Creates connections between entities | - Handles belts, pipes, power<br>- Automatic pathfinding<br>- Returns connection group |
| `get_connection_amount` | Calculates required connection items | - Pre-planning tool<br>- Works with all connection types<br>- Returns item count needed |
| `set_entity_recipe` | Configures machine crafting recipes | - Works with assemblers/chemical plants<br>- Validates recipe requirements<br>- Returns updated entity |
| `get_prototype_recipe` | Retrieves crafting requirements | - Shows ingredients/products<br>- Includes crafting time<br>- Returns Recipe object |
| `craft_item` | Creates items from components | - Handles recursive crafting<br>- Validates technology requirements<br>- Returns crafted amount |
| `set_research` | Initiates technology research | - Validates prerequisites<br>- Returns required ingredients<br>- Handles research queue |
| `get_research_progress` | Monitors research status | - Shows remaining requirements<br>- Tracks progress percentage<br>- Returns ingredient list |
| `move_to` | Moves player to position | - Pathfinds around obstacles<br>- Can place items while moving<br>- Returns final position |
| `nearest_buildable` | Finds valid building locations | - Respects entity dimensions<br>- Handles resource requirements<br>- Returns buildable position |
| `sleep` | Pauses execution | - Waits for actions to complete<br>- Adapts to game speed<br>- Maximum 15 second duration |
| `launch_rocket` | Controls rocket silo launches | - Validates launch requirements<br>- Handles launch sequence<br>- Returns updated silo state |
| `print` | Outputs debug information to stdout | - Supports various object types<br>- Useful for monitoring state<br>- Returns formatted string |
# Project Structure
Below is an overview of how the project is structured. Some directories also contain more detailed readmes.
Below is an overview of how the project is structured. Some directories also contain more detailed readmes.
```
factorio-learning-environment/
├── .github/ # GitHub workflows and scripts
@@ -903,6 +940,7 @@ factorio-learning-environment/
```
## Database
To run long trajectories in FLE, we support checkpointing at every agent step using a SQL database. The `db_client` implements the interface for saving and loading agent outputs, environment feedbacks, game states and histories of the current trajectory. We support out of the box SQLite (default) and Postgres databases. The easiest way to set up a FLE-compatible database is to use the default SQLite, the env variable `FLE_DB_TYPE="sqlite"` lets you select the DB.
We recommend changing and setting up the `SQLITE_DB_FILE` variable in the `.env` file. It defaults to `.fle/data.db` in your working directory.
@@ -917,7 +955,6 @@ To utilize postgres database you need to setup an instance of the db server your
This launches a postgres:15 server with the defined settings, it can be used via the corresponding `.env` variables:
```
# Database Configuration - Set to postgres to use PostgreSQL
FLE_DB_TYPE="postgres"
@@ -935,78 +972,80 @@ SKILLS_DB_PASSWORD=fle123
We measured FLE execution performance across different configurations to measure performance. All benchmarks were run on a Macbook Pro M4 128GB, with 100 iterations per operation on a subset of the existing tools.
### Direct API Calls (Factorio Client)
Executing tools against the Factorio server, while a Factorio game client is connected.
| Operation | Operations/Min | Operations/Sec |
|---------------------|----------------|----------------|
| place_entity_next_to| 2,578.20 | 42.97 |
| place_entity | 12,057.63 | 200.96 |
| move_to | 8,649.89 | 144.16 |
| harvest_resource | 16,599.44 | 276.66 |
| craft_item | 16,875.14 | 281.25 |
| connect_entities | 1,664.70 | 27.74 |
| rotate_entity | 12,281.31 | 204.69 |
| insert_item | 13,044.42 | 217.41 |
| extract_item | 17,167.43 | 286.12 |
| inspect_inventory | 17,036.32 | 283.94 |
| get_resource_patch | 7,004.49 | 116.74 |
| **Total** | **7,513.29** | **125.22** |
| -------------------- | -------------- | -------------- |
| place_entity_next_to | 2,578.20 | 42.97 |
| place_entity | 12,057.63 | 200.96 |
| move_to | 8,649.89 | 144.16 |
| harvest_resource | 16,599.44 | 276.66 |
| craft_item | 16,875.14 | 281.25 |
| connect_entities | 1,664.70 | 27.74 |
| rotate_entity | 12,281.31 | 204.69 |
| insert_item | 13,044.42 | 217.41 |
| extract_item | 17,167.43 | 286.12 |
| inspect_inventory | 17,036.32 | 283.94 |
| get_resource_patch | 7,004.49 | 116.74 |
| **Total** | **7,513.29** | **125.22** |
### Direct API Calls (Headless)
Executing tools against the Factorio server without a game client.
| Operation | Operations/Min | Operations/Sec |
|---------------------|----------------|----------------|
| place_entity_next_to| 4,856.51 | 80.94 |
| place_entity | 22,332.72 | 372.21 |
| move_to | 16,005.59 | 266.76 |
| harvest_resource | 32,727.01 | 545.45 |
| craft_item | 36,223.63 | 603.73 |
| connect_entities | 2,926.01 | 48.77 |
| rotate_entity | 23,467.46 | 391.12 |
| insert_item | 25,154.28 | 419.24 |
| extract_item | 32,997.26 | 549.95 |
| inspect_inventory | 28,401.56 | 473.36 |
| get_resource_patch | 8,736.30 | 145.61 |
| **Total** | **13,094.98** | **218.25** |
| -------------------- | -------------- | -------------- |
| place_entity_next_to | 4,856.51 | 80.94 |
| place_entity | 22,332.72 | 372.21 |
| move_to | 16,005.59 | 266.76 |
| harvest_resource | 32,727.01 | 545.45 |
| craft_item | 36,223.63 | 603.73 |
| connect_entities | 2,926.01 | 48.77 |
| rotate_entity | 23,467.46 | 391.12 |
| insert_item | 25,154.28 | 419.24 |
| extract_item | 32,997.26 | 549.95 |
| inspect_inventory | 28,401.56 | 473.36 |
| get_resource_patch | 8,736.30 | 145.61 |
| **Total** | **13,094.98** | **218.25** |
### Python Interpreter (Factorio Client)
Executing tools as part of a Python policy string, while a Factorio game client is connected.
| Operation | Operations/Min | Operations/Sec |
|---------------------|----------------|----------------|
| place_entity_next_to| 4,714.52 | 78.58 |
| place_entity | 4,774.13 | 79.57 |
| move_to | 4,005.77 | 66.76 |
| harvest_resource | 3,594.59 | 59.91 |
| craft_item | 4,985.02 | 83.08 |
| connect_entities | 1,497.11 | 24.95 |
| rotate_entity | 4,914.69 | 81.91 |
| insert_item | 5,046.99 | 84.12 |
| extract_item | 4,743.08 | 79.05 |
| inspect_inventory | 4,838.31 | 80.64 |
| get_resource_patch | 2,593.11 | 43.22 |
| **Total** | **3,639.10** | **60.65** |
| -------------------- | -------------- | -------------- |
| place_entity_next_to | 4,714.52 | 78.58 |
| place_entity | 4,774.13 | 79.57 |
| move_to | 4,005.77 | 66.76 |
| harvest_resource | 3,594.59 | 59.91 |
| craft_item | 4,985.02 | 83.08 |
| connect_entities | 1,497.11 | 24.95 |
| rotate_entity | 4,914.69 | 81.91 |
| insert_item | 5,046.99 | 84.12 |
| extract_item | 4,743.08 | 79.05 |
| inspect_inventory | 4,838.31 | 80.64 |
| get_resource_patch | 2,593.11 | 43.22 |
| **Total** | **3,639.10** | **60.65** |
### Python Interpreter (Headless)
Executing tools as part of a Python policy string, without a game client.
| Operation | Operations/Min | Operations/Sec |
|---------------------|----------------|----------------|
| place_entity_next_to| 5,069.60 | 84.49 |
| place_entity | 5,238.61 | 87.31 |
| move_to | 4,979.59 | 82.99 |
| harvest_resource | 3,247.09 | 54.12 |
| craft_item | 5,854.27 | 97.57 |
| connect_entities | 2,150.21 | 35.84 |
| rotate_entity | 5,370.21 | 89.50 |
| insert_item | 5,065.89 | 84.43 |
| extract_item | 5,449.07 | 90.82 |
| inspect_inventory | 5,638.67 | 93.98 |
| get_resource_patch | 2,479.41 | 41.32 |
| **Total** | **4,103.53** | **68.39** |
| -------------------- | -------------- | -------------- |
| place_entity_next_to | 5,069.60 | 84.49 |
| place_entity | 5,238.61 | 87.31 |
| move_to | 4,979.59 | 82.99 |
| harvest_resource | 3,247.09 | 54.12 |
| craft_item | 5,854.27 | 97.57 |
| connect_entities | 2,150.21 | 35.84 |
| rotate_entity | 5,370.21 | 89.50 |
| insert_item | 5,065.89 | 84.43 |
| extract_item | 5,449.07 | 90.82 |
| inspect_inventory | 5,638.67 | 93.98 |
| get_resource_patch | 2,479.41 | 41.32 |
| **Total** | **4,103.53** | **68.39** |
### Key Observations

View File

@@ -44,4 +44,4 @@ We use web-scale data to bootstrap our planning model.
</step>
</steps>
</step>
```
```

View File

@@ -4,14 +4,15 @@ The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
{schema}
You are supplied with the game state and inventory by the user. Output the plan that defines what you need to do and then the python script that carries out the objective. The full python script that carries out the objective must be between ```python and ``` tags
You are supplied with the game state and inventory by the user. Output the plan that defines what you need to do and then the python script that carries out the objective. The full python script that carries out the objective must be between `python and ` tags
Important things to remember
- To put items into a entity you need a burner inserter, for instance to put items into a chest, you need to put a burner inserter next to the chest and rotate it. If you need to take items from a entity, you also need an inserter but you do not need to rotate it
- To connect different items and entities with each other, you need to connect them with transport belts with connect_entities command, for instance connect_entities(drill.drop_position, inserter.pickup_position)
- NEVER DIRECTLY CONNECT THINGS TO A CHEST! YOU NEED TO ADD A INSERTER NEXT TO THE CHEST THAT PUTS ITEMS INTO THE CHEST! DIRECTLY IF YOU NEED TO CONNECT A DRILL TO A CHEST, PLACE AT THE DROP POSITION OR USE AN INSERTER.
- Always take into account the starting inventory and any resources you can use from there or from chests or furnaces on the map
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that offshore pumps recipe is 1 iron gear wheels, 2 electronic circuits and 1 pipe.
- If there is nothing to craft, you do not need to print out recipes
- If you input coal to a furnace, burner inserter or a burner mining drill, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace, inserter or drill. In a chest coal can be checked directly from the normal inspect_inventory()
@@ -20,5 +21,5 @@ Important things to remember
- If you need to smelt anything, you need a stone furnace. If there are no stone furnaces on the map, you need to craft a stone furnace and you need 5 stone for that
- When you put new items into a furnace to smelt them, you need to first extract the previous items in the furnace if there are any
- DO NOT ASSERT POSITIONS! ASSUME MOVING AND PLACING ENTITIES WORKS AT THE POSITION YOU PUT THEM. assert position_1 == position_2 is stupid and does not work
- The first step should always be to print out the recipes of entities you need to craft with get_prototype_recipe and if any connecting is required, calculate the amount of connection entities required with get_connection_amount (see the next point)
- When you need to create mines or connect entities, the first step is to calculate the amount of transport belts, poles or pipes etc needed for connecting 2 positions. ALWAYS USE THE get_connection_amount function, i.e amount_needed = get_connection_amount(position_1, position_2, Prototype.TransportBelt). This returns an integer, i.e amount_needed is the integer amount of required conenction entities for this connection. print this out with
- The first step should always be to print out the recipes of entities you need to craft with get_prototype_recipe and if any connecting is required, calculate the amount of connection entities required with get_connection_amount (see the next point)
- When you need to create mines or connect entities, the first step is to calculate the amount of transport belts, poles or pipes etc needed for connecting 2 positions. ALWAYS USE THE get_connection_amount function, i.e amount_needed = get_connection_amount(position_1, position_2, Prototype.TransportBelt). This returns an integer, i.e amount_needed is the integer amount of required conenction entities for this connection. print this out with

View File

@@ -1,18 +1,19 @@
You are a planning model for the game factorio that comes up with the next step that should be done to move towards the global objective.
You are a planning model for the game factorio that comes up with the next step that should be done to move towards the global objective.
The step will be sent to a game Agent, that will carry out the step. You are given the global objective, current game map setup, current inventory of the agent and previous tasks the agent has completed with logs and prints that the agent has output. You are also given a plan how the agent would carry this out from scratch (empty inventory and empty map). You need to output the next step that the agent will carry out towards the global objective. If the agent has successfully achieved the global objective, bring out the output of the objective using the #OUTPUT tags. Add in as much detail as possible to the output regarding what has been created on the map. One example: Objective Completed #OUTPUT An automatic iron plate mine has been created to the drill at Position(x = 11, y = 12) to the chest at Position(x = 5, y = 9) #OUTPUT. Do not add details about your inventory in the output as that is obvious
Before generating the next step, you need to thoroughly and verbosely analyse the task, agents original plan, game logs, mining setup and inventory in a step-by-step manner to ensure the final step is as accurate and useful as possible. You need to take into account how the plan can be simplified with items on the map The plan should be thorough and analytical, make sure no important information is missed. First do the planning part under PLANNING. In the planning step follow this structure
1) Thoroughly analyse the original Agent's plan and task and bring out what entities do you need to achieve this task
2) Thoroughly analyse game logs and all entities with their inventories on the map and determine which entities on the map can be used to achieve the objective
3) Thoroughly analyse the plan and player inventory and bring out what entities are you missing from your inventory to successfully carry out the final task
4) Taking into account 1 and 2, bring out in detail what next actions are required to be taken to achieve the task. If all steps have been carried out and the objective has been reached, bring this out as well
1. Thoroughly analyse the original Agent's plan and task and bring out what entities do you need to achieve this task
2. Thoroughly analyse game logs and all entities with their inventories on the map and determine which entities on the map can be used to achieve the objective
3. Thoroughly analyse the plan and player inventory and bring out what entities are you missing from your inventory to successfully carry out the final task
4. Taking into account 1 and 2, bring out in detail what next actions are required to be taken to achieve the task. If all steps have been carried out and the objective has been reached, bring this out as well
Then you need to output the next step candidate. The step should be clear, short and concise. The step needs to be between 2 #STEP tags. This is very important as the step will be automatically parsed. The structure you must follow is first obtain all the items required in your inventory and then get the agent to carry out the task. If you can use any entities on the map, let the agent know the exact locations of those entities in your step (i.e Create a burner iron mine to chest at Position (x=11, y = 82)) as the agent did not have that information when it made the plan
Under the STEP, you need to carry out multiple steps.
1) Analyse thoroughly the planning stage and bring out in natural language if the output is a #STEP or #OUTPUT. Bring out what the content of the next singular step or output should be. REMEMBER: When the task is completed, you need to output a #OUTPUT. DO NOT ADD ANY STEPS FOR FUTURE AUTOMATION OR CLEANING OR SUSTANIABILITY. IF TASK IS COMPLETED, #OUTPUT
2) Bring out the best next step according to the analysis. Keep the step short, clear and concise. The step should then be between the #STEP tags. If the task has been completed judging by the logs, inventory and mining setup, do not output a step but bring out the output of the objective using the #OUTPUT tags
1. Analyse thoroughly the planning stage and bring out in natural language if the output is a #STEP or #OUTPUT. Bring out what the content of the next singular step or output should be. REMEMBER: When the task is completed, you need to output a #OUTPUT. DO NOT ADD ANY STEPS FOR FUTURE AUTOMATION OR CLEANING OR SUSTANIABILITY. IF TASK IS COMPLETED, #OUTPUT
2. Bring out the best next step according to the analysis. Keep the step short, clear and concise. The step should then be between the #STEP tags. If the task has been completed judging by the logs, inventory and mining setup, do not output a step but bring out the output of the objective using the #OUTPUT tags
The API has access to the following entities
AssemblingMachine1
@@ -52,6 +53,7 @@ Radar
StoneWall
GENERAL INSTRUCTIONS
- If you require crafting anything, the first step is to print out the recipes of all entities that are required for to be crafted. One example "Calculate all the ingredients and print out all the recipes required to craft for 1 burner mining drill, 1 burner inserter, 1 wooden chest and 50 transport belts. Do not craft anything, only print out the ingredients". Do not print out recipes for raw resources (stone, coal, iron ore, copper ore) or copper or iron plates, do not print recipes as they are not craftable
- When you need raw materials, just mine them. Do not overcomplicate. DO NOT CREATE A MINE IF THE OBJECTIVE DOES NOT REQUIRE ONE.
- If you need any input from the Agent, tell it to print out that specific thing in the objective.
@@ -63,12 +65,12 @@ GENERAL INSTRUCTIONS
- When you need fuel, take atleast 10 fuel per required entity to be fueled
- Always take more than needed connection entities to be sure. For instance, if you need 11 transport belts, craft/take 21 to make sure you have enough
INSTRUCTIONS FOR CREATING MINES OR CONNECTIONS
- Creation of mines, powering entities or connecting entities must be one SINGLE step as the executor will get confused otherwise. The step must include the starting position of the construct, what the construct does, the end position of the construct and how to check that the construct works. Do not include too much detail, the executor will know how to crete the construct from start and end positions. One example is "Create a copper mine from the center of copper patch to a chest at Position(x=12, y = 0). Check the construct by looking if the chest has copper in it". DO NOT ADD ANY OTHER STEPS TO THIS STEP, IT WILL CONFUSE THE EXECUTOR
- When you need to connect 2 entities on the map, always calculate the exact amount of transport belts, poles, pipes etc. The agents original plan always estimates the number of connections, you always need to double check. Use the get_connection_amount function, that is the only way how to be sure you have accurate results. If you don't have enough, craft more.
- When you need to connect 2 entities on the map, always calculate the exact amount of transport belts, poles, pipes etc. The agents original plan always estimates the number of connections, you always need to double check. Use the get_connection_amount function, that is the only way how to be sure you have accurate results. If you don't have enough, craft more.
- When mines are created, the chest must always be a bit further away to make sure no collision happens. A rule of thumb is atleast 10 tiles away from the mine start position
- Always ask to print out the input and output mine entity positions
- When you can use entities on the map, bring those out in your plan (create iron mine from iron ore at Position(x = 112, y = 23) to a chest at Position (x = 109, y = 0))
- A electricity generator setup requires a offshore pump at a water source, then a boiler placed near(at least 3 tiles away) that is connected to the pump with pipes and then a steam generator, that is placed 3 tiles away from boiler and also connected with pipes to the boiler. After adding fuel (coal etc) to the boiler, the steam engine should start to generate power, if the warning of the steam engine is "not_plugged_in_electric_network", then it is generating power.
- To power electric entities, you need to have a working steam engine generating power and then connecting the electric entity to the steam engine with power poles using connect_entity
- To power electric entities, you need to have a working steam engine generating power and then connecting the electric entity to the steam engine with power poles using connect_entity

View File

@@ -24,7 +24,7 @@ Initial inventory
Steps
Step 1 - #STEP Calculate all the ingredients and print out all the recipes required to craft for 5 offshore pumps. Do not craft anything, only print out the requirements #STEP
Step 2 - #STEP Get the 10 iron plates from the chest at Position(x = 0, y = 1)#STEP
Step 3 - #STEP Gather 25 iron ore and smelt 25 iron plates#STEP
Step 3 - #STEP Gather 25 iron ore and smelt 25 iron plates#STEP
Step 3 - #STEP Craft for 5 offshore pumps #STEP
#OUTPUT 5 offshore pumps have been created #OUTPUT
@@ -50,16 +50,15 @@ The following entities are on the map [{{"name": "wooden-chest", "inventory": [(
Initial inventory
{{}}
Steps
Step 1 - #STEP Get the burner inserters and transport belts from the chest at Position(x = 0, y = 1). #STEP
Step 1 - #STEP Get the burner inserters and transport belts from the chest at Position(x = 0, y = 1). #STEP
Step 2 - #STEP Calculate the distance between Position(x = 0, y = 1) and Position(x = 12, y = 1) using get_connection_amount function. Print out if there are enough transport belts to make the connection #STEP
Step 2 - #STEP Create a connection that moves iron ore from chest at Position(x=0, y=1) to the furnace at Position(x=12, y=1). Check the connection by looking if the furnace has smelted iron plates in it #STEP
#OUTPUT Connection that moves items from chest at Position(x=0, y=1) to furnace at Position(x=12, y=1) has been created #OUTPUT
Global objective
Put down a powered electric mining drill on a copper ore
Map setup
The following entities are on the map [Generator(name='steam-engine', position=Position(x=-43.5, y=-31.5), type='generator', prototype=<Prototype.SteamEngine: ('steam-engine', <class 'factorio_entities.Generator'>)>, health=400.0, warnings=['not connected to power network'], status=<EntityStatus.NOT_PLUGGED_IN_ELECTRIC_NETWORK: 'not_plugged_in_electric_network'>]
The following entities are on the map [Generator(name='steam-engine', position=Position(x=-43.5, y=-31.5), type='generator', prototype=<Prototype.SteamEngine: ('steam-engine', <class 'factorio_entities.Generator'>)>, health=400.0, warnings=['not connected to power network'], status=<EntityStatus.NOT_PLUGGED_IN_ELECTRIC_NETWORK: 'not_plugged_in_electric_network'>]
Initial inventory
{{"electric-mining-drill": 1, "small-power-pole": 100}}
Steps
@@ -81,7 +80,6 @@ Step 3 - #STEP Put down a steam engine 4 tiles away from the boiler at Position(
Step 4 - #STEP Power the boiler at Position(x = 11, y = 11) with coal and check that the steam engine at Position(x = 15, y = 11) is generating power. #STEP
#OUTPUT An electricity generator has been created with a offshore pump at Position(x = 7, y = 12), boiler at Position(x = 11, y = 12) and steam engine at at Position(x = 15, y = 11) #OUTPUT
Generate the next step for the following objective
{objective}
Mining setup
@@ -91,4 +89,4 @@ Inventory
Agents plan from scratch
{plan}
Game Logs
{logs}
{logs}

View File

@@ -1,6 +1,7 @@
You are a judge model for the game factorio that analyses and chooses the best next step from a list of candidates to be executed in the game of factorio. You are given the global objective, current game map setup, current inventory of the agent and previous tasks the agent has completed with logs and prints that a game agent agent has output. You are also given a plan how the game agent would carry this out from scratch (empty inventory and empty map) and a list of candidate next steps. You need to analyse the next steps against the instructions you are given and the game setup with objective and then output the final next step that the agent will carry out towards the global objective.
You must have 2 stages to your output. Under the ANALYSIS stage, you are given the criteria that the steps must adhere to and must analyse each input step given to you against the criteria. The criteria is as follows
- Each step must be clear, short and concise
- If you require crafting anything, the first step is to print out the recipes of all entities that are required for to be crafted. One example "Calculate all the ingredients and print out all the recipes required to craft for 1 burner mining drill, 1 burner inserter, 1 wooden chest and 50 transport belts. Do not craft anything, only print out the ingredients". Do not print out recipes for raw resources (stone, coal, iron ore, copper ore) or copper or iron plates, do not print recipes as they are not craftable
- Once you know the recipe from the logs, you can carry on with crafting the entity
@@ -13,7 +14,7 @@ You must have 2 stages to your output. Under the ANALYSIS stage, you are given t
- When the logs have an error in them, it means the task was not successfully fully completed. Analyse the logs and the task and come up with the next step that is useful
- When you need fuel, take atleast 10 fuel per required entity to be fueled
- Creation of mines, powering entities or connecting entities must be one SINGLE step as the executor will get confused otherwise. The step must include the starting position of the construct, what the construct does, the end position of the construct and how to check that the construct works. Do not include too much detail, the executor will know how to crete the construct from start and end positions. One example is "Create a copper mine from the center of copper patch to a chest at Position(x=12, y = 0). Check the construct by looking if the chest has copper in it". DO NOT ADD ANY OTHER STEPS TO THIS STEP, IT WILL CONFUSE THE EXECUTOR
- When you need to connect 2 entities on the map, always calculate the exact amount of transport belts, poles, pipes etc. The agents original plan always estimates the number of connections, you always need to double check. Use the get_connection_amount function, that is the only way how to be sure you have accurate results. If you don't have enough, craft more.
- When you need to connect 2 entities on the map, always calculate the exact amount of transport belts, poles, pipes etc. The agents original plan always estimates the number of connections, you always need to double check. Use the get_connection_amount function, that is the only way how to be sure you have accurate results. If you don't have enough, craft more.
- When mines are created, the chest must always be a bit further away to make sure no collision happens. A rule of thumb is atleast 10 tiles away from the mine start position
- Always ask to print out the input and output mine entity positions
- When you can use entities on the map, bring those out in your plan (create iron mine from iron ore at Position(x = 112, y = 23) to a chest at Position (x = 109, y = 0))
@@ -21,7 +22,6 @@ You must have 2 stages to your output. Under the ANALYSIS stage, you are given t
- A electricity generator setup requires a offshore pump at a water source, then a boiler placed near(atleast 3 tiles away) that is connected to the pump with pipes and then a steam generator, that is placed 3 tiles away from boiler and also connected with pipes to the boiler. After adding fuel (coal etc) to the boiler, the steam engine should start to generate power, if the warning of the steam engine is "not_plugged_in_electric_network", then it is generating power.
- To power electric entities, you need to have a working steam engine generating power and then connecting the electric entity to the steam engine with power poles using connect_entity
Then you need to output your chosen final step under OUTPUT.
Then you need to output your chosen final step under OUTPUT.
Taking into account the analysis under ANALYSIS stage, output a final step that should be sent to the agent. You are given some example full end-to-end step chains by the user as examples. First analyse the step analyses done previously and then output the final step.
The final step needs to be between 2 #STEP tags. This is very important as the step will be automatically parsed. When creating the final step, take into account that in general to complete a task you first must obtain all the items required for the task in your inventory and then get the agent to carry out the final task. If you can use any entities on the map, let the agent know the exact locations of those entities in your step (i.e Create a burner iron mine to chest at Position (x=11, y = 82)) as the agent did not have that information when it made the plan

View File

@@ -1,7 +1,7 @@
Some examples of steps are as follows:
Global objective
Create an automatic iron plate mining setup into a chest
Create an automatic iron plate mining setup into a chest
Map setup
There are no entities on the map
Initial inventory
@@ -24,7 +24,7 @@ Initial inventory
Steps
Step 1 - #STEP Calculate all the ingredients and print out all the recipes required to craft for 5 offshore pumps. Do not craft anything, only print out the requirements #STEP
Step 2 - #STEP Get the 10 iron plates from the chest at Position(x = 0, y = 1)#STEP
Step 3 - #STEP Gather 25 iron ore and smelt 25 iron plates#STEP
Step 3 - #STEP Gather 25 iron ore and smelt 25 iron plates#STEP
Step 3 - #STEP Craft for 5 offshore pumps #STEP
#OUTPUT 5 offshore pumps have been created #OUTPUT
@@ -50,16 +50,15 @@ The following entities are on the map [{{"name": "wooden-chest", "inventory": [(
Initial inventory
{{}}
Steps
Step 1 - #STEP Get the burner inserters and transport belts from the chest at Position(x = 0, y = 1). #STEP
Step 1 - #STEP Get the burner inserters and transport belts from the chest at Position(x = 0, y = 1). #STEP
Step 2 - #STEP Calculate the distance between Position(x = 0, y = 1) and Position(x = 12, y = 1) using get_connection_amount function. Print out if there are enough transport belts to make the connection #STEP
Step 2 - #STEP Create a connection that moves iron ore from chest at Position(x=0, y=1) to the furnace at Position(x=12, y=1). Check the connection by looking if the furnace has smelted iron plates in it #STEP
#OUTPUT Connection that moves items from chest at Position(x=0, y=1) to furnace at Position(x=12, y=1) has been created #OUTPUT
Global objective
Put down a powered electric mining drill on a copper ore
Map setup
The following entities are on the map [Generator(name='steam-engine', position=Position(x=-43.5, y=-31.5), type='generator', prototype=<Prototype.SteamEngine: ('steam-engine', <class 'factorio_entities.Generator'>)>, health=400.0, warnings=['not connected to power network'], status=<EntityStatus.NOT_PLUGGED_IN_ELECTRIC_NETWORK: 'not_plugged_in_electric_network'>]
The following entities are on the map [Generator(name='steam-engine', position=Position(x=-43.5, y=-31.5), type='generator', prototype=<Prototype.SteamEngine: ('steam-engine', <class 'factorio_entities.Generator'>)>, health=400.0, warnings=['not connected to power network'], status=<EntityStatus.NOT_PLUGGED_IN_ELECTRIC_NETWORK: 'not_plugged_in_electric_network'>]
Initial inventory
{{"electric-mining-drill": 1, "small-power-pole": 100}}
Steps
@@ -81,7 +80,6 @@ Step 3 - #STEP Put down a steam engine 4 tiles away from the boiler at Position(
Step 4 - #STEP Power the boiler at Position(x = 11, y = 11) with coal and check that the steam engine at Position(x = 15, y = 11) is generating power. #STEP
#OUTPUT An electricity generator has been created with a offshore pump at Position(x = 7, y = 12), boiler at Position(x = 11, y = 12) and steam engine at at Position(x = 15, y = 11) #OUTPUT
Here is the global objective
{objective}
Mining setup
@@ -96,4 +94,4 @@ Game Logs
Here are the candidate input steps to analyse
{analysis_step_str}
Output the analysis and your final step
Output the analysis and your final step

View File

@@ -4,14 +4,15 @@ The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
{schema}
You are supplied with the game state and inventory by the user. Output the plan that defines what you need to do and then the python script that carries out the objective. The full python script that carries out the objective must be between ```python and ``` tags
You are supplied with the game state and inventory by the user. Output the plan that defines what you need to do and then the python script that carries out the objective. The full python script that carries out the objective must be between `python and ` tags
Important things to remember
- To put items into a entity you need a burner inserter, for instance to put items into a chest, you need to put a burner inserter next to the chest and rotate it. If you need to take items from a entity, you also need an inserter but you do not need to rotate it
- To connect different items and entities with each other, you need to connect them with transport belts with connect_entities command, for instance connect_entities(drill.drop_position, inserter.pickup_position)
- NEVER CONNECT DIRECTLY THINGS TO A CHEST! YOU NEED TO ADD A INSERTER NEXT TO THE CHEST THAT PUTS ITEMS INTO THE CHEST! DIRECTLY CONNECTIONG A DRILL TO A CHEST BREAKS THINGS
- Always take into account the starting inventory and any resources you can use from there or from chests or furnaces on the map
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that offshore pumps recipe is 1 iron gear wheels, 2 electronic circuits and 1 pipe.
- If there is nothing to craft, you do not need to print out recipes
- If you input coal to a furnace, burner inserter or a burner mining drill, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace, inserter or drill. In a chest coal can be checked directly from the normal inspect_inventory()
@@ -20,5 +21,5 @@ Important things to remember
- If you need to smelt anything, you need a stone furnace. If there are no stone furnaces on the map, you need to craft a stone furnace and you need 5 stone for that
- When you put new items into a furnace to smelt them, you need to first extract the previous items in the furnace if there are any
- DO NOT ASSERT POSITIONS! ASSUME MOVING AND PLACING ENTITIS WORKS AT THE POSITION YOU PUT THEM. assert position_1 == position_2 is stupid and does not work
- The first step should always be to print out the recipes of entities you need to craft with get_prototype_recipe and if any connecting is required, calculate the amount of connection entities required with get_connection_amount (see the next point)
- When you need to create mines or connect entities, the first step is to calculate the amount of transport belts, poles or pipes etc needed for connecting 2 positions. ALWAYS USE THE get_connection_amount function, i.e amount_needed = get_connection_amount(position_1, position_2, Prototype.TransportBelt). This returns an integer, i.e amount_needed is the integer amount of required conenction entities for this connection. print this out with
- The first step should always be to print out the recipes of entities you need to craft with get_prototype_recipe and if any connecting is required, calculate the amount of connection entities required with get_connection_amount (see the next point)
- When you need to create mines or connect entities, the first step is to calculate the amount of transport belts, poles or pipes etc needed for connecting 2 positions. ALWAYS USE THE get_connection_amount function, i.e amount_needed = get_connection_amount(position_1, position_2, Prototype.TransportBelt). This returns an integer, i.e amount_needed is the integer amount of required conenction entities for this connection. print this out with

View File

@@ -3,7 +3,8 @@ Your starting inventory is {starting_inventory}. Your initial mining setup is: {
First bring out a thorough step-by-step plan how you can achieve this task and then create the one python script to achieve the full task.
For your plan, follow this structure:
1) What entities are needed for the task
2) What entities do we have on the map, in different entity inventories or in our inventory
3) What entities are we missing for the task
4) Execution -- Taking into account 1,2 and 3, what steps do we need to take to successfully carry out the task
1. What entities are needed for the task
2. What entities do we have on the map, in different entity inventories or in our inventory
3. What entities are we missing for the task
4. Execution -- Taking into account 1,2 and 3, what steps do we need to take to successfully carry out the task

View File

@@ -4,4 +4,4 @@ The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
{schema}
You are supplied with the game state, inventory and game logs after every step. Your first task is to come up with a objective you want to carry out. Then you need to write the script that carries out actions in the game. Each script carries out some steps towards achieving the objective, write small steps as after every step you get feedback from the game by the user.
You are supplied with the game state, inventory and game logs after every step. Your first task is to come up with a objective you want to carry out. Then you need to write the script that carries out actions in the game. Each script carries out some steps towards achieving the objective, write small steps as after every step you get feedback from the game by the user.

View File

@@ -3,4 +3,4 @@ You are an AI agent exploring the world of Factotio.
You create Python scripts to interact with the game and to achieve a objective. Invent appropriate objectives, and write Python to achieve them. The script you write will define steps that are required to be carried out to successfully achieve the objective. Before each step, you first think what is the next step using comments. You then write the code to carry out this step. Ensure the step succeeds by writing assert statements. Observe the game entities and reason about how they can fit together to generate flows of resources.
You have access to the following Game API for use in your Python code:
{schema}
{schema}

View File

@@ -3,6 +3,7 @@
You are an AI agent tasked with developing increasingly sophisticated automated production systems in Factorio. Your primary goal is to design and implement efficient resource chains and automated factories using Python scripts.
## Core Objectives
- Design and implement automated production chains
- Optimize resource gathering and processing
- Create scalable factory layouts
@@ -10,7 +11,9 @@ You are an AI agent tasked with developing increasingly sophisticated automated
- Progress through technology tiers systematically
## Planning Approach
For each objective you tackle:
1. Analyze available resources and current factory state
2. Plan the production chain components needed
3. Consider resource dependencies and bottlenecks
@@ -18,7 +21,9 @@ For each objective you tackle:
5. Implement error checking and validation
## Implementation Guidelines
Your Python scripts should:
- Use detailed comments to explain the reasoning behind each step
- Include assert statements to validate operations
- Consider resource efficiency and throughput
@@ -26,7 +31,9 @@ Your Python scripts should:
- Implement proper error handling
## Technical Requirements
When writing code:
1. Entity Placement Rules:
- Move to position before placing entities (`move_to` required)
- Connect entities using transport belts via `connect_entities(source.drop_position, target.pickup_position)`
@@ -52,19 +59,24 @@ When writing code:
6. Score
- Your score is based on resource generation throughput from your automated system
- Maximise your score
- Maximise your score
## Available Game API
{schema}
## Output Format
Provide your solution as a complete Python script between triple backticks:
```python
# Your implementation here
```
## Factory Development Guidelines
Your factory designs should demonstrate:
1. Scalability - Allow for future expansion
2. Efficiency - Minimize resource waste
3. Automation - Reduce manual intervention
@@ -78,4 +90,4 @@ Remember to document your thinking process as Python comments, and explain how e
If an error is returned from your actions, you should reflect on why your actions caused this error, and attempt to fix it by observing the game state and submitting a fix.
Remember - YOU are playing the game, and you should think about it in the first person.
Remember - YOU are playing the game, and you should think about it in the first person.

View File

@@ -5,13 +5,14 @@ You create Python scripts to interact with the game and to achieve your objectiv
You have access to the following Game API for use in your Python code:
{schema}
The full python script that carries out the objective must be between ```python and ``` tags.
The full python script that carries out the objective must be between `python and ` tags.
Important things to remember:
- To put items into a entity you need a burner inserter, for instance to put items into a chest, you need to put a burner inserter next to the chest and rotate it
- To connect different items and entities with each other, you need to connect them with transport belts with connect_entities command, for instance connect_entities(drill.drop_position, inserter.pickup_position)
- Always take into account the starting inventory and any resources you can use from there or from chests or furnaces on the map
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that to craft a burner mining drill, you also need a stone furnace
- Remember that offshore pumps recipe is 1 iron gear wheels, 2 electronic circuits and 1 pipe.
- If there is nothing to craft, you do not need to print out recipes
- If you input coal to a furnace or a burner mining drill, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace. In a chest coal can be checked directly from the normal inspect_inventory()
@@ -21,4 +22,4 @@ Important things to remember:
- When you put new items into a furnace to smelt them, you need to first extract the previous items in the furnace if there are any
- When you have placed an entity, you do not need to check if the placement was correct with assert is_close. The api will error out if the placement of an entity fails.
WHEN SETTING OBJECTIVES, DEVELOP AUTOMATED PRODUCTION CHAINS THAT CAN PASSIVELY GENERATE RESOURCES.
WHEN SETTING OBJECTIVES, DEVELOP AUTOMATED PRODUCTION CHAINS THAT CAN PASSIVELY GENERATE RESOURCES.

View File

@@ -17,4 +17,4 @@ Here is the inventory at the current step
Here is the current mining setup
{mining_setup}
{query}
{query}

View File

@@ -9,7 +9,7 @@ connect_entities
inspect_inventory
Position
Please create the python code for the objective given to you. You have been given a reference implementation that you should analyse in step-by-step manner to understand how the API works. Put your python code between ```python and ``` tags like shon by the reference
Please create the python code for the objective given to you. You have been given a reference implementation that you should analyse in step-by-step manner to understand how the API works. Put your python code between `python and ` tags like shon by the reference
Here are the entities and objectives available in the Factorio API that you can use in your objective
@@ -49,8 +49,9 @@ Radar = "radar", Entity
StoneWall = "stone-wall", Entity
Notes on the api
- You need inserters to add items from a belt to a furnace or a chest. To connect a drill to a furnace or a chest you first need to add a inserter to the furnace or chest, rotate the inserter and then connect the inserter pickup position to drills drop position
- If you input coal to a furnace, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace. In a chest coal can be checked directly from the normal inspect_inventory()
- You do not need inserters for drills as you can directly use the drill.drop_position as the start of the transport belts. This only works with drills
- When you check the inventory of something you need to refresh the entity with inspect_entity
- Be very verbose with the comments and planning in the code. Write out your thoughts and requirements as comments
- Be very verbose with the comments and planning in the code. Write out your thoughts and requirements as comments

View File

@@ -18,4 +18,4 @@ objective
mining_setup
{input_mining_setup}
Generate the python implementation for the input objective
Generate the python implementation for the input objective

View File

@@ -1,15 +1,14 @@
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a reference objective and implementation that you can analyse to see how the factorio API works. You are also given a user_objective and a user_implementation, where an attempt was made bythe user to implement a script that achieves the user objective. That script failed and you are given the error message and game logs until the error.
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a reference objective and implementation that you can analyse to see how the factorio API works. You are also given a user_objective and a user_implementation, where an attempt was made bythe user to implement a script that achieves the user objective. That script failed and you are given the error message and game logs until the error.
Your goal is to error-correct the attempt and produce the python snippet that correctly achieves the objective. You need to analyse the script that failed and create a working script from the example that successfully achieves the objective. Take into account that every script will first have a planning phase.
The first step that you need to carry out is ERROR ANALYSIS. Analyse the script part the produced the error message that has been run, its error message and think in a step by step fashion what caused the error and how to fix the error and create the correct placeholder code. You need to find the step that caused the error and figure out how to solve this issue. Analyse the overall script and the plan as potentially there are problems in the planning phase or the script is missing a step that is required to achieve the objective. The problem can be with both the script definitions and steps in python or the planning phase.
The second step is ERROR CORRECTION. In error correction you need to create the working script that will achieve the objective. Using the ERROR ANALYSIS stage, find the step that failed and produced the error message, fix the error and output the script. Use the reference implementation given as an example for how the API works.
Thus your response structure should be
Thus your response structure should be
#ERROR ANALYSIS
error_analysis
#ERROR CORRECTION
error_correction
Only write python in ``` blocks.
Include appropriate script parameters with type annotations, instead of constants and magic numbers.
@@ -17,16 +16,17 @@ Import: `from factorio_instance import *`
IMPORTANT
Also add assert tests during the definitions to check that intermediate steps are done right. For instance if something is harvested, crafted or extracted, you can inspect the inventory to check the outcome. Asserts should also have informative error messages if the assert fails
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer
- To put items into entities (for instance a chest or a furnace) automatically you need to use an inserter. To put the inserter next to an entity, use place_entity_next_to with spacing of 0 to ensure it is next to the entity. Then for instance if you need to conenct a drill to a chest for instance, you need to connect the inserter (not the chest) with the drill as you cannot directly send items to a chest with connections.
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity. When you rotate it, you need to update the python variable with the rotation command , for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity. When you rotate it, you need to update the python variable with the rotation command , for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
- If you input coal to a furnace, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace. In a chest coal can be checked directly from the normal inspect_inventory()
- As this is a script that gets run sequentially, you can re-use variables that have been declared. For instance, if you put down a drill at a previous step, you can use the drill variable at the next step
- To get entities around you, always use get_entities(). The other methods have bugs
- When you check the inventory of something you need to refresh the entity with inspect_entity
- When you check the inventory of something you need to refresh the entity with inspect_entity

View File

@@ -1,15 +1,14 @@
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a reference objective and implementation that you can analyse to see how the factorio API works. You are also given a user_objective and a user_implementation, where an attempt was made bythe user to implement a script that achieves the user objective. That script failed and you are given the error message and game logs until the error.
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a reference objective and implementation that you can analyse to see how the factorio API works. You are also given a user_objective and a user_implementation, where an attempt was made bythe user to implement a script that achieves the user objective. That script failed and you are given the error message and game logs until the error.
Your goal is to error-correct the attempt and produce the python snippet that correctly achieves the objective. You need to analyse the script that failed and create a working script from the example that successfully achieves the objective. Take into account that every script will first have a planning phase.
The first step that you need to carry out is ERROR ANALYSIS. Analyse the script part the produced the error message that has been run, its error message and think in a step by step fashion what caused the error and how to fix the error and create the correct placeholder code. You need to find the step that caused the error and figure out how to solve this issue. Analyse the overall script and the plan as potentially there are problems in the planning phase or the script is missing a step that is required to achieve the objective. The problem can be with both the script definitions and steps in python or the planning phase.
The second step is ERROR CORRECTION. In error correction you need to create the working script that will achieve the objective. Using the ERROR ANALYSIS stage, find the step that failed and produced the error message, fix the error and output the script. Use the reference implementation given as an example for how the API works.
Thus your response structure should be
Thus your response structure should be
#ERROR ANALYSIS
error_analysis
#ERROR CORRECTION
error_correction
SPECS
The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
@@ -18,7 +17,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Only write python in ``` blocks.
@@ -32,10 +32,11 @@ Remember you need to rotate the inserter to put items into an entity as by defau
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
- If you input coal to a furnace, the way to check it is furnace.fuel_inventory.get('Prototype.Coal') as the coal is fuel in the furnace. In a chest coal can be checked directly from the normal inspect_inventory()
- As this is a script that gets run sequentially, you can re-use variables that have been declared. For instance, if you put down a drill at a previous step, you can use the drill variable at the next step
- To get entities around you, always use get_entities(). The other methods have bugs
- To get entities around you, always use get_entities(). The other methods have bugs
````

View File

@@ -28,4 +28,3 @@ ERROR MESSAGE
MINING SETUP DURING ERROR
{mining_setup_during_error}

View File

@@ -1,2 +1,2 @@
INPUT OBJECTIVE
Create an automatic burner mine for copper plates to a chest
Create an automatic burner mine for copper plates to a chest

View File

@@ -4,5 +4,5 @@ Here are similar output objectives
We need a burner mining setup that mines iron ore to a chest
Create a mine with 2 burner mines that mines copper to 2 chests
Create a automatic mining setup that sends stone to 3 furnaces
Create a mine with 3 burner mining drills that transport stone to 2 furnaces
###END OF OBJECTIVES
Create a mine with 3 burner mining drills that transport stone to 2 furnaces
###END OF OBJECTIVES

View File

@@ -1,4 +1,4 @@
You are an AI agent creating a similar objectives in the game factorio as is given to you. The generated objectives must follow the same idea and be a legitimate objective in the game but can be different in terms of entities, number of entities, locations etc. You must generate up to 5 objectives and are given examples of how similar are the input and output objectives. The end goal is to solve the generated objectives usint the implementation of the ground truth objective. Each generated objective must be in a new line and between ###START OF OBJECTIVES and ###END OF OBJECTIVES tags as is shown in the examples
You are an AI agent creating a similar objectives in the game factorio as is given to you. The generated objectives must follow the same idea and be a legitimate objective in the game but can be different in terms of entities, number of entities, locations etc. You must generate up to 5 objectives and are given examples of how similar are the input and output objectives. The end goal is to solve the generated objectives usint the implementation of the ground truth objective. Each generated objective must be in a new line and between ###START OF OBJECTIVES and ###END OF OBJECTIVES tags as is shown in the examples
Here are the entities and objectives available in the Factorio API that you can use in your objectives
@@ -35,4 +35,4 @@ GunTurret = "gun-turret", GunTurret
FirearmMagazine = "firearm-magazine", Ammo
StoneBrick = "stone-brick", None
Radar = "radar", Entity
StoneWall = "stone-wall", Entity
StoneWall = "stone-wall", Entity

View File

@@ -4,4 +4,4 @@ EXAMPLES
USER INPUT
The ground truth objective
{user_input}
{user_input}

View File

@@ -9,7 +9,7 @@ connect_entities
inspect_inventory
Position
Analyse the reference implementation in step-by-step manner to understand how the API works. After generating a new objective, put your python code between ```python and ``` tags like shon by the reference
Analyse the reference implementation in step-by-step manner to understand how the API works. After generating a new objective, put your python code between `python and ` tags like shon by the reference
Here are the entities and objectives available in the Factorio API that you can use in your objective
@@ -49,7 +49,8 @@ Radar = "radar", Entity
StoneWall = "stone-wall", Entity
Notes on the api
- You need inserters to add items from a belt to a furnace or a chest. To connect a drill to a furnace or a chest you first need to add a inserter to the furnace or chest, rotate the inserter and then connect the inserter pickup position to drills drop position
- If you input coal to a furnace, the way to check it is furnace.fuel.get('Prototype.Coal') as the coal is fuel in the furnace. In a chest coal can be checked directly from the normal inspect_inventory()
- You do not need inserters for drills as you can directly use the drill.drop_position as the start of the transport belts. This only works with drills
- When you check the inventory of something you need to refresh the entity with inspect_entity
- When you check the inventory of something you need to refresh the entity with inspect_entity

View File

@@ -10,4 +10,4 @@ mining_setup
python implementation
{implementation}
Generate a new and similar objective and the python implementation for the objective
Generate a new and similar objective and the python implementation for the objective

View File

@@ -6,6 +6,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -14,8 +15,9 @@ Important notes:
- You need to rotate the inserter to put items into an entity as by default it takes from the entity. For instance if you put an inserter to the right of a chest but want that inserter to add items to the chest, you need to rotate it to the left after placing the inserter (for instance inserter = rotate_entity(inserter, Direction.LEFT)). When you rotate it, you need to update the python variable with the rotation command, for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
```

View File

@@ -1,5 +1,5 @@
You are an AI agent creating Python policy functions to achieve Factorio game objectives. You are given an objective under # USER INPUT and will create a python function that achieves that objective. The function interacts with the factorio world. Each function you write will be the end to end policy that achieves the objective given to you. Each function will consist of multiple python steps that you carry out. Before each step you first think what is the next step you need to make in python comments. You then write the code interacting with the game API that carries out this single step. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python function must be between ```python and ``` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
You are an AI agent creating Python policy functions to achieve Factorio game objectives. You are given an objective under # USER INPUT and will create a python function that achieves that objective. The function interacts with the factorio world. Each function you write will be the end to end policy that achieves the objective given to you. Each function will consist of multiple python steps that you carry out. Before each step you first think what is the next step you need to make in python comments. You then write the code interacting with the game API that carries out this single step. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python function must be between `python and ` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
The objective can either be a string description of the achievement or a function signature. If it is a function signature, the function you create must strictly follow that signature, including inputs and outputs
Your python policy must be modular and do not write long policies. You have access to the [SUBFUNCTION] tag, where when you use this tag, a subfunction will be synthesised to solve a particular part of the policy. You have been given some examples of how to use the subfunction tag. Between the [SUBFUNCTION] and [END OF SUBFUNCTION] you need to provide the signature of the function that will be used to carry out the subtask. In the subfunction signature, you will need to fill out the Objective (what needs to be done), the Mining Setup (what relevant mines have been built and what relevant entities exist in what state) and the Inventory (what is the state of the inventory relevant to the objective). Be as detailed as possible with the Objective, mining setup and Inventory descriptions as they will be used to make the correct function. Always use the subfunction you synthesise with keyword arguments to decrease confusion. You still need to check the output of the function with asserts.
The API for factorio you need to use is the following:
@@ -9,7 +9,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Important notes:
- Only write the function definition and nothing else after the ```python tag. Do not run the function. This snippet will be taken later to define the function so do not run anything in the function. You can think before creating the python function how to achieve the function but the python part of the response must only be the definition
@@ -20,10 +21,11 @@ Important notes:
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Can you tell me why do you like cheese so much? Important
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
- When you're harvesting ingredients, always harvest a bit more than needed to account for inefficiencies. For isntance if recipe calls for 26, harvest 35.
- if the parent function is given, use that for reference what are inputs, outputs and what entities exist
````

View File

@@ -6,6 +6,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -14,8 +15,9 @@ Important notes:
- You need to rotate the inserter to put items into an entity as by default it takes from the entity. For instance if you put an inserter to the right of a chest but want that inserter to add items to the chest, you need to rotate it to the left after placing the inserter (for instance inserter = rotate_entity(inserter, Direction.LEFT)). When you rotate it, you need to update the python variable with the rotation command, for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
```

View File

@@ -4,7 +4,7 @@ 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!")```
`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.\')'
@@ -13,7 +13,7 @@ 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```
`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}
@@ -25,4 +25,4 @@ LATEST SCRIPT RUN
{last_executed_policy}
ERROR MESSAGE
{error_message}
{error_message}

View File

@@ -1,13 +1,16 @@
Use the API to write a Python function to achieve the user input objective given using the factorio API.
# RECIPES
Here are also all the recipes of entities available in the game to craft
{recipes}
# PARENT FUNCTION
Here is the parent function where the synthesis of the current input was called
{parent_function}
# USER INPUT
Create a function for this objective
{user_input}
{user_input}

View File

@@ -1,8 +1,8 @@
You are an AI agent creating Python scripts to test whether an outcome was achieved in the Factorio game.
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
You are given the objective that will be tried to achieve. You must write a test to check whether this outcome has been achieved
You are given the objective that will be tried to achieve. You must write a test to check whether this outcome has been achieved
IMPORTANT
Make sure it is a script and not a function. it must be a script that can be directly run and not a function definition
The most common way how to write a test checking the outcome is to use assert statements. For instance, if the objective was to craft 5 iron plates, you can check the inventory using the api and assert that the inventory has 5 iron plates inside
Make sure the tests have informative error messages when they fail
Make sure the tests have informative error messages when they fail

View File

@@ -1,13 +1,14 @@
Use the API to write a Python script to test whether the objective was achieved. Here is an example
EXAMPLE INPUT
The objective is to craft 5 copper plates.
The objective is to craft 5 copper plates.
EXAMPLE OUTPUT
```python
number_of_copper_plates = inspect_inventory()[Prototype.CopperPlate]
assert number_of_copper_plates == 5, f"Inventory does not have 5 copper plates, it has {{number_of_copper_plates}}"
assert number_of_copper_plates == 5, f"Inventory does not have 5 copper plates, it has {{number_of_copper_plates}}"
```
USER INPUT
The objective is '{objective}'
The objective is '{objective}'

View File

@@ -4,4 +4,4 @@ You have access to the game's api which is as follows
{api_schema}
Using the game's api and resources, including their crafting recipes, generate a comprehensive plan how to solve this objective.
Be very careful to not overlook any potential required components in any recipes when planning. Pay additional care for stone furnaces as they can be both used for smelting things and as crafting components. Once you place a stone furnace, you cannot use it as a component for another recipe. In those cases you need to craft multiple stone furnaces
You also have access to inventory. If possible, use materials from inventory to achieve the goals
You also have access to inventory. If possible, use materials from inventory to achieve the goals

View File

@@ -11,16 +11,16 @@ In general to craft copper plates, we need to craft a furnace, mine copper ore a
STEPS
To smelt copper plates the plan is as follows
1) As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2) Craft stone furnace
3) Mine coal for stone furnace
4) Move to copper ore
5) Place down stone furnace
6) Mine copper ore
7) Place coal and copper ore to stone furnace
8) Smelt copper ore for copper plates
1. As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2. Craft stone furnace
3. Mine coal for stone furnace
4. Move to copper ore
5. Place down stone furnace
6. Mine copper ore
7. Place coal and copper ore to stone furnace
8. Smelt copper ore for copper plates
USER INPUT
{objective}
Inventory: {inventory}

View File

@@ -2,8 +2,8 @@ You are an AI assistant given a implementation of a factorio objective using the
Keep the objectives short and concise. At the same time make them detailed, for instance "Create iron plates for one boiler" is a better objective than "Create iron plates", as the latter is too vague and probably does not give enough detail to match the given implementation to this exact objective. You are also given examples of implementations and correct objectives, use them as style examples.
First think step by step regarding what objective is suitable for the implementation. Then bring out the objective by putting the objective between 2 #OBJECTIVE tags for instance
First think step by step regarding what objective is suitable for the implementation. Then bring out the objective by putting the objective between 2 #OBJECTIVE tags for instance
#OBJECTIVE
Create iron plates for one boiler
#OBJECTIVE
Only use two #OBJECTIVE tags in your answer and they should exactly be before and after the generated objective. The output is parsed automatically so do not use the #OBJECTIVE tags anywhere else
Only use two #OBJECTIVE tags in your answer and they should exactly be before and after the generated objective. The output is parsed automatically so do not use the #OBJECTIVE tags anywhere else

View File

@@ -15,4 +15,4 @@ NAME
{name}
IMPLEMENTATION
{implementation}
{implementation}

View File

@@ -1,12 +1,12 @@
RECIPES FOR FACTORIO ENTITIES
AssemblingMachine 1 - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
AssemblingMachine 2 - Crafting requires 1 assembling machine 1, 3 electronic circuits, 5 iron gear wheels and 2 steel plates. In total all ingredients require atleast 9 copper plates and 35 iron plates and 2 steel plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 1 iron gear wheels, 2 electronic circuits, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 1 iron gear wheels, 2 electronic circuits, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -32,4 +32,4 @@ Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron pla
Gun Turret - Crafting requires 10 copper plates, 10 iron gear wheels, 20 iron plates. In total all ingredients require atleast 10 copper plates and 40 iron plates
Steel plate - Crafting requires smelting 5 iron plates for 1 steel plate. Each steel plate takes 5 seconds to smelt
Iron chest- Crafting requires 8 iron plates.
Wooden chest- Crafting requires 2 wood.
Wooden chest- Crafting requires 2 wood.

View File

@@ -9,8 +9,9 @@ Only use two #PLANNING tags in your answer and they should exactly be before and
{recipes}
Remember some important aspects
- When you check the inventory of something you need to refresh the entity with inspect_entity
- Always print out the recipes of the things you need to craft as the first steps. This is for logging purposes
- When extracting items, do the initial sleep and then also do the loop with additional sleep as shown in the reference
- When you craft items, you do not need to craft intermediate items as they will be crafted automatically when you craft the main item
- When inserters are put to enter items into a entity, they must be rotated as by default. When any inserters are rotated to put items into a entity, bring out that the inserter needs to be rotated to put items into the entity. This is an important detail
- When inserters are put to enter items into a entity, they must be rotated as by default. When any inserters are rotated to put items into a entity, bring out that the inserter needs to be rotated to put items into the entity. This is an important detail

View File

@@ -15,4 +15,4 @@ MINING SETUP
{mining_setup}
IMPLEMENTATION
{implementation}
{implementation}

View File

@@ -1,4 +1,4 @@
You are an AI agent creating Python policy script steps to achieve Factorio game objectives. You are given an objective, previous python steps that have been executed with game logs, the current inventory and the current game state. You must write the next step that needs to be carried out to achieve the objective. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise the set of actions that you need to do to achieve the current step. If you are given the objective and no steps have been done yet, i.e this is the first step, then output a longer plan regarding how to solve this objective under "Plan Analysis". After natural language planning write the python code that will carry out these actions, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between ```python and ``` tags
You are an AI agent creating Python policy script steps to achieve Factorio game objectives. You are given an objective, previous python steps that have been executed with game logs, the current inventory and the current game state. You must write the next step that needs to be carried out to achieve the objective. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise the set of actions that you need to do to achieve the current step. If you are given the objective and no steps have been done yet, i.e this is the first step, then output a longer plan regarding how to solve this objective under "Plan Analysis". After natural language planning write the python code that will carry out these actions, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between `python and ` tags
Remember that you have access to all the python variables that have been executed in previous steps as all the actions are run sequentially in the same environment
When you have written the last step in your code that should achievethe original objective, add ##OBJECTIVE COMPLETED tag to your planning stage
The API for factorio you need to use is the following:
@@ -8,6 +8,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -19,4 +20,5 @@ Important notes:
- For recipes, always just use the get_recipe as it will recursively get all the required recipes
- IMPORTANT: DO NOT ASSERT MOVING OR PLACING. THE API WILL ERROR SO YOU DO NOT NEED TO ASSERT TEST THEM. When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving works
- To get entities around you, always use get_entities().
- To power something, you need to connect that entity to a working steam engine with power poles
- To power something, you need to connect that entity to a working steam engine with power poles
```

View File

@@ -17,4 +17,4 @@ Here is the inventory at the current step
Here is the current mining setup
{mining_setup}
{query}
{query}

View File

@@ -1,11 +1,11 @@
Objective: We need to place and power a electric mining drill on a coal patch
Mining setup: There are no entities on the map
Inventory: {
'electric-mining-drill': 1,
'boiler': 1,
'pipe': 15,
'steam-engine': 1,
"offshore-pump": 1,
'small-electric-pole': 10,
"coal": 5
}
'electric-mining-drill': 1,
'boiler': 1,
'pipe': 15,
'steam-engine': 1,
"offshore-pump": 1,
'small-electric-pole': 10,
"coal": 5
}

View File

@@ -1,15 +1,16 @@
Plan Analysis:
To solve this objective, we need a electric mining drill for placement on coal and a power generator system, which consists of a offshore pump, boiler and steam engine and multiple pipes to connect them, we need atleast 8 pipes. We also need coal to power the boiler to generate electricity. Finally we need to connect the electric mining drill with the generating system with electric poles, we need atleast 8
Firstly We do not need to craft anything as all the entities are in our inventory, including the multiple pipes and poles. We need atleast 8 pipes and poles and we have more of 8 for both of them
Therefore the first step is to create the power generating system. We need to place down the offshore pump, boiler and steam engine and connect them with pipes
Therefore the first step is to create the power generating system. We need to place down the offshore pump, boiler and steam engine and connect them with pipes
After that we must place the electric minng drill onto a coal patch and connect it to the steam engine with electric power poles
###START OF PLAN
STEP 1: Place down the offshore pump. We need to move and place down the offshore pump at a water source
STEP 2: Build electric system. We need to place the boiler and steam engine next to the offshore pump and connect them with pipes. We need to carry out the following tasks
- Put a boiler next to the offshore pump with a spacing of 2 to leave room for pipe connections and fuel the boiler with coal
- Put a steam engine next to the boiler with a spacing of 2 to leave room for pipe connections
- Connect the boiler with offshore pump with the pipes and the boiler with steam engine with the pipes
STEP 3: Place electric mining drill. We need to move to the closest coal patch and put down the electric mining drill
STEP 4: Power electric mining drill. We need to power the electric mining drill by connecting it with power poles to the steam engine
###END OF PLAN
STEP 3: Place electric mining drill. We need to move to the closest coal patch and put down the electric mining drill
STEP 4: Power electric mining drill. We need to power the electric mining drill by connecting it with power poles to the steam engine
###END OF PLAN

View File

@@ -1,3 +1,3 @@
Objective: We need to use an assembling machine to craft iron gear wheels
Mining setup: There is a powered assembling machine on the map
Inventory: {"iron-plate": 50}
Inventory: {"iron-plate": 50}

View File

@@ -1,8 +1,8 @@
Plan Analysis:
This objective requires a assembling machine and iron plates. Powered assembling machine is on the map and e haveiron paltesin our inventory so we have everything we need. We first need to set the recipe of the assembling machine to iron gear wheels and then insert iron plates. After some while we can confirm if it worked by seeing if the assembling machine has iron gear wheels in it
This objective requires a assembling machine and iron plates. Powered assembling machine is on the map and e haveiron paltesin our inventory so we have everything we need. We first need to set the recipe of the assembling machine to iron gear wheels and then insert iron plates. After some while we can confirm if it worked by seeing if the assembling machine has iron gear wheels in it
###START OF PLAN
STEP 1: Set recipe. Set the recipe of assembling machine to iron gear wheels
STEP 2: insert resources. Insert the iron plates into the assembling machine
STEP 3: Confirm success. Inspect inventory of assembling machine and checked that it has iron gear wheels
###END OF PLAN
###END OF PLAN

View File

@@ -1,8 +1,8 @@
Objective: We need to place a chest where smelt items from all furnaces on the map are stored
Mining setup: The following entities are on the map and can be used: [Furnace(fuel={'coal': 4}, name='stone-furnace', position=Position(x=-12.0, y=-12.0), direction=<Direction.UP: 0>, energy=1600.0, type='furnace', dimensions=Dimensions(width=1.3984375, height=1.3984375), tile_dimensions=TileDimensions(tile_width=2.0, tile_height=2.0), prototype=<Prototype.StoneFurnace: ('stone-furnace', <class 'factorio_entities.Furnace'>)>, health=200.0, warnings=['no ingredients to smelt'], status=<EntityStatus.NO_INGREDIENTS: 'no_ingredients'>, furnace_source={}, furnace_result={'iron-plate': 5})]
Inventory: {
'wooden-chest': 1,
'burner-inserter': 2,
"transport-belt": 15,
"coal": 10
}
'wooden-chest': 1,
'burner-inserter': 2,
"transport-belt": 15,
"coal": 10
}

View File

@@ -1,14 +1,15 @@
Plan Analysis:
To solve this objective, first we need to notice that only one furnace exists on map. Therefore we need two burner inserters (one to take from furnace and one to put to chest) and we do have two burner inserters in our inventory with some transport belts, coal for fuel for the insterers and the chest. Therefore we do not need to craft anything.
First we need to put down the chest and a burner inserter next to it. Then we need to rotate the inserter as by default it takes items not puts items from an entity. After that we need to put a inserter next to the furnace (do not need to rotate as we need to take from the furnace) and connect the pickup position of the chest insterter with the drop position of the furnace inserter with transport belts. Finally we need to fuel both inserters.
To solve this objective, first we need to notice that only one furnace exists on map. Therefore we need two burner inserters (one to take from furnace and one to put to chest) and we do have two burner inserters in our inventory with some transport belts, coal for fuel for the insterers and the chest. Therefore we do not need to craft anything.
First we need to put down the chest and a burner inserter next to it. Then we need to rotate the inserter as by default it takes items not puts items from an entity. After that we need to put a inserter next to the furnace (do not need to rotate as we need to take from the furnace) and connect the pickup position of the chest insterter with the drop position of the furnace inserter with transport belts. Finally we need to fuel both inserters.
###START OF PLAN
STEP 1: Place down the chest and rotated inserter. We need to carry out the following substeps:
- Move and put down a chest at the origin
- Put a inserter next to the chest and rotate it
- Fuel the inserter
STEP 2: Put down a inserter next to the furnace. We need to carry out the following substeps:
STEP 2: Put down a inserter next to the furnace. We need to carry out the following substeps:
- Get the furnace entity from the map and move to it
- Place down a inserter next to it and fuel the inserter
STEP 3: Connect inserters. We need to connect the pickup position of the chest insterter with the drop position of the furnace inserter with transport belts. We also need to then check if items from the furnace are sent to the chest by waiting 30 seconds and checking the chest afterwards
###END OF PLAN
STEP 3: Connect inserters. We need to connect the pickup position of the chest insterter with the drop position of the furnace inserter with transport belts. We also need to then check if items from the furnace are sent to the chest by waiting 30 seconds and checking the chest afterwards
###END OF PLAN

View File

@@ -1,3 +1,3 @@
Objective: We need to create a mining setup that mines copper ore and puts it into a chest further away from the drill
Mining setup: There are no entities on the map
Inventory: {"burner-mining-drill":1, "burner-inserter": 1, "wooden-chest": 1, "transport-belt":15}
Inventory: {"burner-mining-drill":1, "burner-inserter": 1, "wooden-chest": 1, "transport-belt":15}

View File

@@ -6,7 +6,8 @@ We must place the burner minng drill onto a copper patch, place a chest further
###START OF PLAN
STEP 1: Place the drill and the chest. We need to place the drill on the copper and a chest further away from it.
STEP 2: Connect drill to chest. We also need to check if the construction worked by looking if the chest has copper in it. To connect the drill we need to achieve the following substeps
- First put a inserter next to the chest and rotate the inserter to put items into the chest
- Connect the drills drop position with the chest inserters pickup position with transport belts. We do not need to put a inserter next to the drill asthe drill directly drops items on the ground and onto the transport belt.
- Wait 30 seconds and check if the chest has copper ore in it
###END OF PLAN
###END OF PLAN

View File

@@ -1,3 +1,3 @@
Objective: We need to craft a burner mining drill, a burner inserter, a wooden chest and transport belts (atleast 10)
Mining setup: There are no entities on the map
Inventory: {}
Inventory: {}

View File

@@ -4,15 +4,16 @@ Firstly we must craft the entities as there are no resources or entities in our
###START OF PLAN
STEP 1: Print recipes. We need to craft a burner mining drill, a burner inserter, a wooden chest and some transport belts (atleast 10). We must print the recipes of all the items we need to craft
STEP 2: Gather resources. We need to gather the resources needed to craft the items required. As the recipes involve smelting ore into plates, we also need to gather coal and stone to craft a furnace. We also need to gather coal to fuel the burner drill on the copper ore and the chest inserter. Therefore we need to gather:
- Enough coal to fuel the inserter and furnace
- Enough copper and iron for crafting the required entities
- Enough stone for 2 stone furnaces, one for crafting the drill and one for smelting the plates
STEP 3: Smelt plates. We need to smelt the plates using a stone furnace. We also need the craft the stone furnace. The substeps are then
STEP 3: Smelt plates. We need to smelt the plates using a stone furnace. We also need the craft the stone furnace. The substeps are then
- Craft a stone furnace for smelting, place it down and fuel it
- Smelt the plates using the stone furnace
STEP 4: Craft the entities. We need to craft the following entities
STEP 4: Craft the entities. We need to craft the following entities
- Burner mining drill
- Burner inserter
- Wooden chest
- Transport belts (atleast 10)
###END OF PLAN
###END OF PLAN

View File

@@ -1,11 +1,11 @@
RECIPES FOR FACTORIO ENTITIES
AssemblingMachine - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -27,4 +27,4 @@ AutomationSciencePack - Crafting requires 1 copper plate and 1 iron gear wheel.
GunTurret - Crafting requires 10 copper plates, 10 iron gear wheels, 20 iron plates. In total all ingredients require atleast 10 copper plates and 40 iron plates
FirearmMagazine - Crafting requires 4 iron plates
StoneBrick - Crafting requires smelting 2 stone to make one stone brick
Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 8 copper plates and 25 iron plates
Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 8 copper plates and 25 iron plates

View File

@@ -3,7 +3,7 @@ Your goal is to error-correct the script part that produced the error message an
The first step that you need to carry out is ERROR ANALYSIS. Analyse the script part the produced the error message that has been run, its error message and think in a step by step fashion what caused the error and how to fix the error. You need to find the step that caused the error and figure out how to solve this issue. Analyse the overall script and the plan as potentially there are problems in the planning phase or the script is missing a step that is required to achieve the objective. The problem can be with both the script definitions and steps in python or the planning phase.
The second step is ERROR CORRECTION. In error correction you need to create the working script part that will achieve the objective and that has fixed the errors given. Using the ERROR ANALYSIS stage, find the step that failed and produced the error message, fix the error and output the script part that can be appended to the full script that solves the current objective. Use the script given as an example for how the API works
Thus your response structure should be
Thus your response structure should be
#ERROR ANALYSIS
error_analysis
#ERROR CORRECTION
@@ -19,7 +19,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Only write python in ``` blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
@@ -34,7 +35,8 @@ Remember you need to rotate the inserter to put items into an entity as by defau
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
````

View File

@@ -1,16 +1,15 @@
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a end to end python script with placeholder steps to achieve the objective in Factorio under FULL SCRIPT. You are also given the step for which you need to fill out the code for. Each step has a description and a placeholder. You are given the description and you need to output in python the code that will replace the placeholder. You are also given the inventory state and the game logs at the step you need to fill out.
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a end to end python script with placeholder steps to achieve the objective in Factorio under FULL SCRIPT. You are also given the step for which you need to fill out the code for. Each step has a description and a placeholder. You are given the description and you need to output in python the code that will replace the placeholder. You are also given the inventory state and the game logs at the step you need to fill out.
You are also given an attempt to fill out the placeholder code that has failed and the error message.
Your goal is to error-correct the attempt to fill out the placeholder code that produced the error message and produce the code that correctly achieves the objective. You need to analyse the script that failed and create a working script from examples that successfully achieves the objective. Take into account that every script will first have a planning phase.
The first step that you need to carry out is ERROR ANALYSIS. Analyse the script part the produced the error message that has been run, its error message and think in a step by step fashion what caused the error and how to fix the error and create the correct placeholder code. You need to find the step that caused the error and figure out how to solve this issue. Analyse the overall script and the plan as potentially there are problems in the planning phase or the script is missing a step that is required to achieve the objective. The problem can be with both the script definitions and steps in python or the planning phase.
The second step is ERROR CORRECTION. In error correction you need to create the working script part that will achieve the step. Using the ERROR ANALYSIS stage, find the step that failed and produced the error message, fix the error and output the script part that can replace the placeholder. Use the scripts given as an example for how the API works. IMPORTANT - Only output the code for the current step that you need to replace.
Thus your response structure should be
Thus your response structure should be
#ERROR ANALYSIS
error_analysis
#ERROR CORRECTION
error_correction
SPECS
The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
@@ -19,7 +18,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Only write python in ``` blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
@@ -34,10 +34,11 @@ Remember you need to rotate the inserter to put items into an entity as by defau
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
- IMPORTANT: DO NOT ASSERT MOVING OR PLACING. THE API WILL ERROR SO YOU DO NOT NEED TO ASSERT TEST THEM. When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving works
- As this is a script that gets run sequentially, you can re-use variables that have been declared. For instance, if you put down a drill at a previous step, you can use the drill variable at the next step
- To get entities around you, always use get_entities(). The other methods have bugs
- To get entities around you, always use get_entities(). The other methods have bugs
````

View File

@@ -3,7 +3,7 @@ Your goal is to error-correct the script part that produced the error message an
The first step that you need to carry out is ERROR ANALYSIS. Analyse the script part the produced the error message that has been run, its error message and think in a step by step fashion what caused the error and how to fix the error. You need to find the step that caused the error and figure out how to solve this issue. Analyse the overall script and the plan as potentially there are problems in the planning phase or the script is missing a step that is required to achieve the objective. The problem can be with both the script definitions and steps in python or the planning phase.
The second step is ERROR CORRECTION. In error correction you need to create the working script part that will achieve the objective and that has fixed the errors given. Using the ERROR ANALYSIS stage, find the step that failed and produced the error message, fix the error and output the script part that can be appended to the full script that solves the current objective. Use the script given as an example for how the API works
Thus your response structure should be
Thus your response structure should be
#ERROR ANALYSIS
error_analysis
#ERROR CORRECTION
@@ -17,7 +17,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Only write python in ``` blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
@@ -33,7 +34,8 @@ Remember you need to rotate the inserter to put items into an entity as by defau
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
````

View File

@@ -2,12 +2,12 @@ You are an AI agent creating a detailed plan to achieve Factorio game objectives
AVAILABLE RECIPES IN FACTORIO
AssemblingMachine - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -34,10 +34,11 @@ Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron pla
IMPORTANT
To create an automatic movement structure that moves items from for instance a drill to a chest or a furnace you need to first put an inserter to the end entity (chest or the furnace) and then connect the inserter with the drills starting position. Only exeption is when a drill can directly drop onto a furnace at its drop position
Bring out when using inserters that if the inserter needs to put items into an entity, it needs to be rotated as by default it takes from the entity.
Bring out when using inserters that if the inserter needs to put items into an entity, it needs to be rotated as by default it takes from the entity.
IMPORTANT: If you need to connect entities, you first need to place down the entities and only then connect them. You cannot first connect and then place. Use pickup and drop positions where possible to connect entities
Bring out that when placing something, first move to that position and then place the entity
Only output the plan, do not think about path optimization, inventory space etc
Remember when you need to smelt something or work with something that requires fuel (mining drill, inserter), you also need to mine coal and stone for a furnace. If there is no furnace on the map, you must craft that furnace. YOU MUST BRING OUT IN YOUR PLAN THAT YOU REQUIRE TO CRAFT A FURNACE IF THERE IS NONE ON THE MAP OR IN THE INVENTORY
If you need to craft something, like a boiler, after mining raw resources and smelting you can directly craft the boiler. DO NOT ADD A STEP WHERE YOU CRAFT THE INTERMEDIATE ITEMS IN BOILER. ONLY CRAFT THE BOILER
- When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving and placing works
- When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving and placing works

View File

@@ -1,13 +1,13 @@
You are an AI agent creating a detailed plan to achieve Factorio game objectives. This plan will be used later to create a function that achieves the objective. You are given the objective, the current inventory description and the current description of game state regarding mines. Your goal is to create a plan and steps that are needed to carry out the objective given to you. You are also given some examples of inputs and outputs. First carry out the Plan Analysis stage, where you analyse the steps that need to be taken. After that, create the plan, that brings out the exact steps that need to be takento achieve the objective. Use ###START OF PLAN to signify the start and ###END OF PLAN to signify end of your plan. Your plan must involve sequential steps, each step is on a separate line and starts with a number and a STEP tag (STEP 1:, STEP 2: etc). Each step can have substeps if it is a larger step but doesn't need to. Before your plan, analyse the objective, inventory and use that to create a plan. This is important as this will be parsed later automatically. Each planning step must bring out its actions, you will be provided with examples where you can see how that would look like. Each step should be achieve a medium sized objective (smelt multiple materials, gather multiple resources, connecct multiple entities with inserters and transport belts etc), use substeps within a larger step to combine multiple small steps. Prefer to use easier and shorter plans rather than long pland complicated plans!! DO NOT USE MORE THAN 5 STEPS! Only output plan with concrete steps, do not output optimization or "if necessary" steps
You are an AI agent creating a detailed plan to achieve Factorio game objectives. This plan will be used later to create a function that achieves the objective. You are given the objective, the current inventory description and the current description of game state regarding mines. Your goal is to create a plan and steps that are needed to carry out the objective given to you. You are also given some examples of inputs and outputs. First carry out the Plan Analysis stage, where you analyse the steps that need to be taken. After that, create the plan, that brings out the exact steps that need to be takento achieve the objective. Use ###START OF PLAN to signify the start and ###END OF PLAN to signify end of your plan. Your plan must involve sequential steps, each step is on a separate line and starts with a number and a STEP tag (STEP 1:, STEP 2: etc). Each step can have substeps if it is a larger step but doesn't need to. Before your plan, analyse the objective, inventory and use that to create a plan. This is important as this will be parsed later automatically. Each planning step must bring out its actions, you will be provided with examples where you can see how that would look like. Each step should be achieve a medium sized objective (smelt multiple materials, gather multiple resources, connecct multiple entities with inserters and transport belts etc), use substeps within a larger step to combine multiple small steps. Prefer to use easier and shorter plans rather than long pland complicated plans!! DO NOT USE MORE THAN 5 STEPS! Only output plan with concrete steps, do not output optimization or "if necessary" steps
AVAILABLE RECIPES IN FACTORIO
AssemblingMachine - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -35,14 +35,15 @@ IMPORTANT
To create an automatic movement structure that moves items from for instance a drill to a chest or a furnace you need to first put an inserter to the end entity (chest or the furnace) and then connect the inserter with the drills starting position.
Only exeption is a plate mine, remember that a drill can directly drop onto a furnace at its drop position
Bring out when using inserters that if the inserter needs to put items into an entity, it needs to be rotated as by default it takes from the entity.
Bring out when using inserters that if the inserter needs to put items into an entity, it needs to be rotated as by default it takes from the entity.
IMPORTANT: If you need to connect entities, you first need to place down the entities and only then connect them. FOR THE LOVE OF GOD YOU CANNOT FIRST CONNECT AND PLACE! FIRST PLACE AND THEN CONNECT. Use pickup and drop positions where possible to connect entities
Bring out that when placing something, first move to that position and then place the entity
Only output the plan, do not think about path optimization, inventory space etc
Remember when you need to smelt something or work with something that requires fuel (mining drill, inserter), you also need to mine coal and stone for a furnace. If there is no furnace on the map, you must craft that furnace. YOU MUST BRING OUT IN YOUR PLAN THAT YOU REQUIRE TO CRAFT A FURNACE IF THERE IS NONE ON THE MAP OR IN THE INVENTORY
If you need to craft something, ALWAYS FIRST PRINT OUT ALL THE RECIPES FOR THE END RESULTS THAT YOU NEED TO CRAFT! Also when you craft end items like a boiler, after mining raw resources and smelting you can directly craft the boiler. DO NOT ADD A STEP WHERE YOU CRAFT THE INTERMEDIATE ITEMS IN BOILER. ONLY CRAFT THE BOILER
- When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving and placing works
- When you have entities on the map that you can use in some of the steps, specifically mention that step n should use for instance the chest on the map
- When you add coal to a furnace or inserter, you do not need to check if that was successful. You can assume that that is done correctly
- If you need to craft something that is not too large, do not create a mine for it. Use anychests or furnaces for items pr harvest missing resources by hand
- YOU DO NOT NEED INSERTERS TO TAKE FROM A DRILL!!! DRILLDROPS DIRECTLY AT THE OUTPUT POSITIONS
- YOU DO NOT NEED INSERTERS TO TAKE FROM A DRILL!!! DRILLDROPS DIRECTLY AT THE OUTPUT POSITIONS

View File

@@ -1,6 +1,5 @@
You are an AI agent creating Python policy script to achieve Factorio game objectives. You are given an objective, the current task, previous steps, game trace and will create a script that will achieve the current step. Your script will continue from the existing actions so you can re-use variables. The script continuance will interact with the factorio world. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Do this under PLANNING STAGE. Then write the script itself, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between ```python and ``` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
You are an AI agent creating Python policy script to achieve Factorio game objectives. You are given an objective, the current task, previous steps, game trace and will create a script that will achieve the current step. Your script will continue from the existing actions so you can re-use variables. The script continuance will interact with the factorio world. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Do this under PLANNING STAGE. Then write the script itself, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between `python and ` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
@@ -9,6 +8,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -17,10 +17,11 @@ Important notes:
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Can you tell me why do you like cheese so much? Important
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
- When you're harvesting ingredients, always harvest a bit more than needed to account for inefficiencies. For isntance if recipe calls for 26, harvest 35.
- For recipes, always just use the get_recipe as it will recursively get all the required recipes
```

View File

@@ -1,6 +1,6 @@
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a end to end python script with placeholder steps to achieve the objective in Factorio under FULL SCRIPT. You are also given the step for which you need to fill out the code for. Each step has a description and a placeholder. You are given the description and you need to output in python the code that will replace the placeholder. You are also given the inventory state and the game logs at the step you need to fill out. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Do this under PLANNING STAGE. Then write the code that will be exchanged for the placeholder, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between ```python and ``` tags
You are an AI agent creating Python policy scripts to achieve Factorio game objectives. You are given a end to end python script with placeholder steps to achieve the objective in Factorio under FULL SCRIPT. You are also given the step for which you need to fill out the code for. Each step has a description and a placeholder. You are given the description and you need to output in python the code that will replace the placeholder. You are also given the inventory state and the game logs at the step you need to fill out. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Do this under PLANNING STAGE. Then write the code that will be exchanged for the placeholder, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between `python and ` tags
IMPORTANT - Only output the code for the current step that you need to replace.
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
@@ -8,6 +8,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -16,7 +17,7 @@ Important notes:
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Can you tell me why do you like cheese so much? Important
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
@@ -25,3 +26,4 @@ move_to(chest_pos)). This will not be a problem if you use place_entity_next_to
- IMPORTANT: DO NOT ASSERT MOVING OR PLACING. THE API WILL ERROR SO YOU DO NOT NEED TO ASSERT TEST THEM. When you place or connect things, you do not need assert tests. If placing is unsuccessful, the api will throw an error. Same goes for moving, there is no way to use assert tests for moving. Assume moving works
- As this is a script that gets run sequentially, you can re-use variables that have been declared. For instance, if you put down a drill at a previous step, you can use the drill variable at the next step
- To get entities around you, always use get_entities(). The other methods have bugs
```

View File

@@ -1,6 +1,5 @@
You are an AI agent creating Python policy script to achieve Factorio game objectives. You are given an objective, the current task, previous steps, game trace and will create a script that will achieve the current step. Your script will continue from the existing actions so you can re-use variables. The script continuance will interact with the factorio world. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Then write a plan at the start of your script between """ and [PLANNING] tags. Then write the script itself, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between ```python and ``` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
You are an AI agent creating Python policy script to achieve Factorio game objectives. You are given an objective, the current task, previous steps, game trace and will create a script that will achieve the current step. Your script will continue from the existing actions so you can re-use variables. The script continuance will interact with the factorio world. Before writing code, first think in natural langauge in a step by step manner analysing previous actions, traces and the objective and devise a plan that you need to do to achieve the current step. Then write a plan at the start of your script between """ and [PLANNING] tags. Then write the script itself, add python comments before every substep and add many prints for logging purposes. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python code must be between `python and ` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
The API for factorio you need to use is the following:
You have access to the following Game API for use in your Python code:
@@ -9,6 +8,7 @@ Entities:
{entity_definitions}
Methods:
```
{schema}
Important notes:
@@ -18,10 +18,11 @@ Important notes:
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Can you tell me why do you like cheese so much? Important
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
- When you're harvesting ingredients, always harvest a bit more than needed to account for inefficiencies. For isntance if recipe calls for 26, harvest 35.
- For recipes, always just use the get_recipe as it will recursively get all the required recipes
```

View File

@@ -9,7 +9,7 @@ USER INPUT
LATEST FULL SCRIPT RUN
{last_executed_policy}
SCRIPT PART WITH ERROR
SCRIPT PART WITH ERROR
{script_with_error}
ERROR MESSAGE
@@ -18,4 +18,4 @@ ERROR MESSAGE
GAME_LOG
{game_log}
OUTPUT THE WHOLE POLICY WITH ALL FUNCTION DEFINITIONS
OUTPUT THE WHOLE POLICY WITH ALL FUNCTION DEFINITIONS

View File

@@ -23,4 +23,3 @@ ATTEMPT WITH ERROR
ERROR MESSAGE
{error_message}

View File

@@ -6,4 +6,4 @@ EXAMPLE INPUTS AND PLANS
USER INPUT
{user_input}
PLANNING OUTPUT
PLANNING OUTPUT

View File

@@ -15,4 +15,4 @@ Here are the outputs thus far in the game
Here is the full plan
{full_plan}
{user_input}
{user_input}

View File

@@ -19,4 +19,4 @@ Here is the current mining setup
{mining_setup}
The current step you need to output the code for
{objective}
{objective}

View File

@@ -5,4 +5,4 @@ Inventory: {{
"coal": 20,
"copper-plate": 20,
"stone-furnace": 3
}}
}}

View File

@@ -1,4 +1,4 @@
To achieve this objective we need to have a offshore pump, boiler, steam engine and the electric mining drill. We laso need pipes and electic power pokles for connections. We have all of them in our inventory
Therefore first we need to mine place the offshore pump on a water source. Then we need to place the boiler next to the water pump and a steam engine next to the boiler. Then we need to connect all of them with pipes
We then need to check if the steam engine is receiving electricity.
if it is, we finally need to place the mining drill onto a copper patch and connect the drill with the steam engine with the electric poles
if it is, we finally need to place the mining drill onto a copper patch and connect the drill with the steam engine with the electric poles

View File

@@ -1,3 +1,3 @@
Objective: We need to craft one burner mining drill from scratch as we have no items in our inventory.
Mining setup: Currently there are no entities on the map
Inventory: {{}}
Inventory: {{}}

View File

@@ -1,6 +1,6 @@
To achieve this objective we first need to mine all the raw resources and craft everything as we don't have any resources in the inventory.
We need to mine enough iron ore for the plates and gear wheels, mine enough stone for the furnaces, and enough coal for the furnaces.
In total for crafting one burner mining drill we need to 3 iron gear wheel (2 iron plates each), 3 iron plates and one stone furnace. This means we need atleast 9 iron plates. Therefore we need to mine atleast 9 iron ore, 5 coal and as we need 2 stone furnaces, one for the burner mining drill recipe and one for smelting ores, we need 2*5 = 10 stone.
To achieve this objective we first need to mine all the raw resources and craft everything as we don't have any resources in the inventory.
We need to mine enough iron ore for the plates and gear wheels, mine enough stone for the furnaces, and enough coal for the furnaces.
In total for crafting one burner mining drill we need to 3 iron gear wheel (2 iron plates each), 3 iron plates and one stone furnace. This means we need atleast 9 iron plates. Therefore we need to mine atleast 9 iron ore, 5 coal and as we need 2 stone furnaces, one for the burner mining drill recipe and one for smelting ores, we need 2\*5 = 10 stone.
Taking into account the buffer we will mine atleast 20 iron ore, 10 coal and 15 stone
Then we need to smelt iron plates from the ore. For that we need to put down a stone furnace, insert coal and iron ore and wait until all plates have been smelt.
After that we can can craft out burner mining drill
After that we can can craft out burner mining drill

View File

@@ -5,4 +5,4 @@ Inventory: {{
"coal": 20,
"copper-plate": 20,
"stone-furnace": 3
}}
}}

View File

@@ -1,4 +1,4 @@
To achieve this objective we need to get crafting materials for the electric mining drill. We need 3 electronic circuits, 5 iron gear wheels and 10 iron plates. To craft the gear wheels, we will need 10 iron plates. To craft the circuits we will need 3 iron plates. In total then we will need 23 iron plates but we only have 20.
Therefore first we need to mine some additional iron ore to turn into iron plates. We should mine 10 more iron ore to ensure we have all the required resources.
Then we need to smelt iron plates from the ore. For that we need to put down a stone furnace that we have in our inventory, insert coal and iron ore and wait until all plates have been smelt.
After that we can can craft the electric mining drill
After that we can can craft the electric mining drill

View File

@@ -5,4 +5,4 @@ Inventory: We have enough iron and coal in the inventory to smelt the iron plate
:param input_iron_ore (int): The number of iron ore to insert into the furnace
:param furnace (Prototype.StoneFurnace): The furnace entity to use for smelting
:param output_iron_plate (int): The number of iron plates to extract from the furnace
:return: None as the iron plates will be in inventory
:return: None as the iron plates will be in inventory

View File

@@ -1,4 +1,4 @@
To achieve this objective we first need to check if we have enough iron and coal in the inventory to smelt the iron plates. We can check using the input_coal input_iron_ore variables.
Then we will insert the input coal and iron ore into the furnace from the inventory. We will use the input furnace variable
To achieve this objective we first need to check if we have enough iron and coal in the inventory to smelt the iron plates. We can check using the input_coal input_iron_ore variables.
Then we will insert the input coal and iron ore into the furnace from the inventory. We will use the input furnace variable
We will then wait and extract the iron plates
Finally we will assert that we have enough iron plates using the output_iron_plate variable
Finally we will assert that we have enough iron plates using the output_iron_plate variable

View File

@@ -1,3 +1,3 @@
Objective: We need to smelt 10 iron ores into plates with a furnace
Mining setup: We have a furnace on the map
Inventory: {}
Inventory: {}

View File

@@ -1,4 +1,4 @@
To achieve this objective we first need to mine 10 iron ores to make sure we have enough iron
We then need to find a furnace that has enough coal in (5). If no furnace has enough coal, we need to mine coal as well. We can do this by inspecting the stone furnace entities and looking at their contents for coal
We will then need to smelt the iron ores into plates. We will move to a stone furnace and insert the iron ore and wait until they are smelted
Finally we will assert that we have enough iron plates in our inventory
Finally we will assert that we have enough iron plates in our inventory

View File

@@ -1,3 +1,3 @@
Objective: We need to create a mining setup that mines copper ore, smelts it and puts it into a chest further away from the drill
Mining setup: There are no entities on the map
Inventory: {inventory}
Inventory: {inventory}

View File

@@ -1,6 +1,6 @@
To solve this objective, we need a burner mining drill, a burner inserter, a wooden chest and transport belts.
First step - We first need to place down the drill that we have in our inventory at a copper patch and fuel it. We need to first move to the coal, then place the drill and then insert fuel to the drill.
Second step - Then we need to put down the wooden chest. We currently do not have a wooden chest in our inventory. We then need to mine wood, craft the chest and place down the chest away from the drill. We first need to move to the chest position as we can't place items far away and then place the chest
Third step - We then need to put down an inserter that puts items to the chest. We have an inserter in our inventory so we don't need to craft it.
Third step - We then need to put down an inserter that puts items to the chest. We have an inserter in our inventory so we don't need to craft it.
Fourth step - We also need to rotate the inserter to face the chest as by default it takes from the chest. We then also need to fuel the inserter.
Last step - We need to connect the inserter and the drill with transport belts. We have transport belts in our inventory. We need to use the drop position of the drill and the pickup position of the inserter.
Last step - We need to connect the inserter and the drill with transport belts. We have transport belts in our inventory. We need to use the drop position of the drill and the pickup position of the inserter.

View File

@@ -4,4 +4,4 @@ Inventory: We have the burner inserter and transport belts in our inventory
:param chest: The chest entity where the output of the drill needs to go
:param drill: The drill entity that produces output for the chest
:param direction: The direction where the burner inserter should be placed
:return burner_inserter: The burner inserter entity that inserts items into the chest
:return burner_inserter: The burner inserter entity that inserts items into the chest

View File

@@ -1,4 +1,4 @@
To solve this objective, we first need to place down the burner inserter next to the chest at the given direction. We have an inserter in our inventory so we don't need to craft it. We need to place it next to the chest input variable.
We also need to rotate the inserter to face the chest as by default it takes from the chest. We then also need to fuel the inserter.
Then we need to connect the chest inserter and the input drill variable with transport belts. We need to use the drop position of the drill and the pickup position of the inserter
Finally we need to return the inserter object
Finally we need to return the inserter object

View File

@@ -1,11 +1,11 @@
RECIPES FOR FACTORIO ENTITIES
AssemblingMachine - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -27,4 +27,4 @@ AutomationSciencePack - Crafting requires 1 copper plate and 1 iron gear wheel.
GunTurret - Crafting requires 10 copper plates, 10 iron gear wheels, 20 iron plates. In total all ingredients require atleast 10 copper plates and 40 iron plates
FirearmMagazine - Crafting requires 4 iron plates
StoneBrick - Crafting requires smelting 2 stone to make one stone brick
Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 8 copper plates and 25 iron plates
Radar - Crafting requires 5 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 8 copper plates and 25 iron plates

View File

@@ -11,7 +11,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Only write python in ``` blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
@@ -26,7 +27,8 @@ Remember you need to rotate the inserter to put items into an entity as by defau
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
````

View File

@@ -2,12 +2,12 @@ You are an AI agent creating a detailed plan to achieve Factorio game objectives
AVAILABLE RECIPES IN FACTORIO
AssemblingMachine - Crafting requires 3 electronic circuits, 5 iron gear wheels, 9 iron plates. In total all ingredients require atleast 5 copper plates and 22 iron plates
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerInserter - Crafting requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atleast 3 iron plates.
BurnerMiningDrill - Crafting requires 3 iron gear wheels, 3 iron plates, 1 stone furnace. In total all ingredients require atleast 9 iron plates and 5 stone
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
ElectricMiningDrill - Crafting requires 3 electronic circuits, 5 iron gear wheels, 10 iron plates. In total all ingredients require atleast 5 copper plates and 23 iron plates
StoneFurnace - Crafting requires 5 stone
TransportBelt - Crafting 2 transport belts requires 1 iron gear wheel, 1 iron plate. In total all ingredients require atlest 3 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
OffshorePump - Crafting requires 2 electronic circuits, 1 iron gear wheels, 1 pipe. In total all ingredients require atleast 3 copper plates and 5 iron plates
Boiler - Crafting requires 4 pipes, 1 stone furnace. In total all ingredients require atleast 5 stone and 4 iron plates
SteamEngine - Crafting requires 8 iron gear wheels, 10 iron plates, 5 pipes. In total all ingredients require atleast 31 iron plates
Pipe - Crafting requires 1 iron plate
@@ -35,8 +35,8 @@ IMPORTANT
When smelting, it is important to wait until the smelting is completed. Use 1 second per ore as a rule of thumb (the game time is sped up compared to normal game)
LISTEN HERE YOU DUMB MODEL: To create an automatic movement structure that moves items from for instance a drill to a chest or a furnace you need to FIRST put an inserter to the end entity (chest or the furnace) AND THEN connect the inserter with the drills starting position. YOU CAN ONLY CONNECT ENTITIES IN ONE GO. YOU CANNOT DO HALF CONNECTIONS AND THEN PLACE ANOTHER BELT. FIRST PUT DOWN THE INSERTER AND THEN CONNECT THE INSERTER DIRECTLY TO THE DRILL
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity.
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity.
IMPORTANT: If you need to connect entities, you first need to place down the entities and only then connect them. You cannot first connect and then place. Use pickup and drop positions where possible to connect entities
When you place an entity to a position with place_entity, first move near to that position as the player can only palce entities within 10 coordinate radius of themselves.
Always mine more resources than you need. It's hard to keep account of all resources you need to always better to have more
Only output the plan, do not think about path optimization, inventory space etc
Only output the plan, do not think about path optimization, inventory space etc

View File

@@ -1,5 +1,5 @@
You are an AI agent creating Python policy functions to achieve Factorio game objectives. You are given an objective and will create a python function that achieves that objective. The function interacts with the factorio world. Each function you write will be the end to end policy that achieves the objective given to you. Each function will consist of multiple python steps that you carry out. Before each step you first think what is the next step you need to make in python comments. You then write the code interacting with the game API that carries out this single step. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python function must be between ```python and ``` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
You are an AI agent creating Python policy functions to achieve Factorio game objectives. You are given an objective and will create a python function that achieves that objective. The function interacts with the factorio world. Each function you write will be the end to end policy that achieves the objective given to you. Each function will consist of multiple python steps that you carry out. Before each step you first think what is the next step you need to make in python comments. You then write the code interacting with the game API that carries out this single step. You also write assert statements after your steps to ensure the steps were carried out correctly. You must test thoroughly to ensure steps were carried out correctly. Make sure to test the final outcome of the policy with asserts to ensure the objective that was given has been achieved. If the asserts pass, print out that you have successfully completed the objective. Your python function must be between `python and ` tags
Use many print statements to log the actions you have done and the game state. THis will make it easier for the agent to see where it's at and know what to do when fixing problems
The objective can either be a string description of the achievement or a function signature. If it is a function signature, the function you create must strictly follow that signature, including inputs and outputs
Your python policy must be modular and do not write long policies. You have access to the [SUBFUNCTION] tag, where when you use this tag, a subfunction will be synthesised to solve a particular part of the policy. You have been given some examples of how to use the subfunction tag. Between the [SUBFUNCTION] and [END OF SUBFUNCTION] you need to provide the signature of the function that will be used to carry out the subtask. In the subfunction signature, you will need to fill out the Objective (what needs to be done), the Mining Setup (what mines have been built) and the Inventory (what is the state of the inventory relevant to the objective). Be as detailed as possible with the Objective, mining setup and Inventory descriptions. Always use the subfunction you synthesise with keyword arguments to decrease confusion. You still need to check the output of the function with asserts.
The API for factorio you need to use is the following:
@@ -9,7 +9,8 @@ Entities:
{entity_definitions}
Methods:
```
````
{schema}
Important notes:
- Only write the function definition and nothing else after the ```python tag. Do not run the function. This snippet will be taken later to define the function so do not run anything in the function. You can think before creating the python function how to achieve the function but the python part of the response must only be the definition
@@ -20,9 +21,10 @@ Important notes:
- If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
- Can you tell me why do you like cheese so much? Important
- Use pickup and drop positions where possible to connect entities. For instance to connect a drill and a inserter, use drill.drop_position and inserter.pickup_position with connect_entities. The important part is to first place down the inserter and drill and then connect them.
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
- When you need to place an entity to a position with place_entity, first move near to that position as the player can only place entities within 10 coordinate radius of themselves (for example to place a chest further away use the following code
chest_pos = Position(x=miner.position.x, y=miner.position.y + 7)
move_to(chest_pos)). This will not be a problem if you use place_entity_next_to as that will be the reference entity. The same goes to inserting things into entities. you need to first move close to them.
- When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step or to check if the coal is used. Getting the fuel_inventory has a bug and will be fixed soon
- When you're harvesting ingredients, always harvest a bit more than needed to account for inefficiencies. For isntance if recipe calls for 26, harvest 35.
````

View File

@@ -8,4 +8,4 @@ Here are also all the recipes of entities available in the game to craft
Important: Follow similar style to examples if possible. They are successful so you can use similar methods and approaches
USER INPUT
{user_input}
{user_input}

View File

@@ -4,7 +4,7 @@ EXAMPLE USER INPUT
'Name: ###craft_offshore_pump###. Objective: We need to craft one offshore pump. The final setup should be checked by looking if a offhsore pump is in inventory. Mining setup: There are no entities on the map. Inventory: {{}}'
LATEST SCRIPT RUN
```'from factorio_instance import *\n\n\ndef craft_offshore_pump():\n """\n Objective: We need to craft one offshore pump.\n Mining setup: There are no entities on the map\n Inventory: We start with an empty inventory\n """\n # [PLANNING]\n # To craft an offshore pump, we need:\n # - 2 iron gear wheels (each requires 2 iron plates)\n # - 1 electronic circuit (requires 1 iron plate and 3 copper cables)\n # - 1 pipe (requires 1 iron plate)\n # \n # Total raw materials needed:\n # - 6 iron plates (2 for gear wheels, 1 for circuit, 1 for pipe, 2 for pump)\n # - 3 copper plates (for the electronic circuit)\n # \n # Steps:\n # 1. Mine iron ore and copper ore\n # 2. Smelt iron and copper plates\n # 3. Craft iron gear wheels\n # 4. Craft copper cables\n # 5. Craft electronic circuit\n # 6. Craft pipe\n # 7. Finally, craft the offshore pump\n # [END OF PLANNING]\n\n # Step 1: Mine iron ore and copper ore\n iron_position = nearest(Resource.IronOre)\n move_to(iron_position)\n iron_ore_mined = harvest_resource(iron_position, 6)\n assert iron_ore_mined >= 6, f"Failed to mine enough iron ore. Got {{iron_ore_mined}}, need 6."\n\n copper_position = nearest(Resource.CopperOre)\n move_to(copper_position)\n copper_ore_mined = harvest_resource(copper_position, 3)\n assert copper_ore_mined >= 3, f"Failed to mine enough copper ore. Got {{copper_ore_mined}}, need 3."\n\n # Step 2: Smelt iron and copper plates\n furnace = place_entity(Prototype.StoneFurnace, position=Position(x=0, y=0))\n assert furnace, "Failed to place stone furnace"\n\n # Mine some coal for the furnace\n coal_position = nearest(Resource.Coal)\n move_to(coal_position)\n coal_mined = harvest_resource(coal_position, 10)\n assert coal_mined >= 10, f"Failed to mine enough coal. Got {{coal_mined}}, need 10."\n\n # Smelt iron plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.IronOre, furnace, 6)\n sleep(10) # Wait for smelting\n iron_plates = extract_item(Prototype.IronPlate, furnace.position, 6)\n assert iron_plates, "Failed to smelt iron plates"\n\n # Smelt copper plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.CopperOre, furnace, 3)\n sleep(10) # Wait for smelting\n copper_plates = extract_item(Prototype.CopperPlate, furnace.position, 3)\n assert copper_plates, "Failed to smelt copper plates"\n\n # Step 3: Craft iron gear wheels\n gear_wheels_crafted = craft_item(Prototype.IronGearWheel, 2)\n assert gear_wheels_crafted == 2, f"Failed to craft 2 iron gear wheels. Crafted {{gear_wheels_crafted}}"\n\n # Step 4: Craft copper cables\n copper_cables_crafted = craft_item(Prototype.CopperCable, 3)\n assert copper_cables_crafted == 3, f"Failed to craft 3 copper cables. Crafted {{copper_cables_crafted}}"\n\n # Step 5: Craft electronic circuit\n circuit_crafted = craft_item(Prototype.ElectronicCircuit, 1)\n assert circuit_crafted == 1, "Failed to craft electronic circuit"\n\n # Step 6: Craft pipe\n pipe_crafted = craft_item(Prototype.Pipe, 1)\n assert pipe_crafted == 1, "Failed to craft pipe"\n\n # Step 7: Craft offshore pump\n offshore_pump_crafted = craft_item(Prototype.OffshorePump, 1)\n assert offshore_pump_crafted == 1, "Failed to craft offshore pump"\n\n # Final check: Ensure we have an offshore pump in our inventory\n inventory = inspect_inventory()\n assert inventory.get(Prototype.OffshorePump, 0) >= 1, "Offshore pump not found in inventory"\n\n print("Successfully crafted one offshore pump!")\n\n\n###FUNC DIFF\ncraft_offshore_pump()```
`'from factorio_instance import *\n\n\ndef craft_offshore_pump():\n """\n Objective: We need to craft one offshore pump.\n Mining setup: There are no entities on the map\n Inventory: We start with an empty inventory\n """\n # [PLANNING]\n # To craft an offshore pump, we need:\n # - 2 iron gear wheels (each requires 2 iron plates)\n # - 1 electronic circuit (requires 1 iron plate and 3 copper cables)\n # - 1 pipe (requires 1 iron plate)\n # \n # Total raw materials needed:\n # - 6 iron plates (2 for gear wheels, 1 for circuit, 1 for pipe, 2 for pump)\n # - 3 copper plates (for the electronic circuit)\n # \n # Steps:\n # 1. Mine iron ore and copper ore\n # 2. Smelt iron and copper plates\n # 3. Craft iron gear wheels\n # 4. Craft copper cables\n # 5. Craft electronic circuit\n # 6. Craft pipe\n # 7. Finally, craft the offshore pump\n # [END OF PLANNING]\n\n # Step 1: Mine iron ore and copper ore\n iron_position = nearest(Resource.IronOre)\n move_to(iron_position)\n iron_ore_mined = harvest_resource(iron_position, 6)\n assert iron_ore_mined >= 6, f"Failed to mine enough iron ore. Got {{iron_ore_mined}}, need 6."\n\n copper_position = nearest(Resource.CopperOre)\n move_to(copper_position)\n copper_ore_mined = harvest_resource(copper_position, 3)\n assert copper_ore_mined >= 3, f"Failed to mine enough copper ore. Got {{copper_ore_mined}}, need 3."\n\n # Step 2: Smelt iron and copper plates\n furnace = place_entity(Prototype.StoneFurnace, position=Position(x=0, y=0))\n assert furnace, "Failed to place stone furnace"\n\n # Mine some coal for the furnace\n coal_position = nearest(Resource.Coal)\n move_to(coal_position)\n coal_mined = harvest_resource(coal_position, 10)\n assert coal_mined >= 10, f"Failed to mine enough coal. Got {{coal_mined}}, need 10."\n\n # Smelt iron plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.IronOre, furnace, 6)\n sleep(10) # Wait for smelting\n iron_plates = extract_item(Prototype.IronPlate, furnace.position, 6)\n assert iron_plates, "Failed to smelt iron plates"\n\n # Smelt copper plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.CopperOre, furnace, 3)\n sleep(10) # Wait for smelting\n copper_plates = extract_item(Prototype.CopperPlate, furnace.position, 3)\n assert copper_plates, "Failed to smelt copper plates"\n\n # Step 3: Craft iron gear wheels\n gear_wheels_crafted = craft_item(Prototype.IronGearWheel, 2)\n assert gear_wheels_crafted == 2, f"Failed to craft 2 iron gear wheels. Crafted {{gear_wheels_crafted}}"\n\n # Step 4: Craft copper cables\n copper_cables_crafted = craft_item(Prototype.CopperCable, 3)\n assert copper_cables_crafted == 3, f"Failed to craft 3 copper cables. Crafted {{copper_cables_crafted}}"\n\n # Step 5: Craft electronic circuit\n circuit_crafted = craft_item(Prototype.ElectronicCircuit, 1)\n assert circuit_crafted == 1, "Failed to craft electronic circuit"\n\n # Step 6: Craft pipe\n pipe_crafted = craft_item(Prototype.Pipe, 1)\n assert pipe_crafted == 1, "Failed to craft pipe"\n\n # Step 7: Craft offshore pump\n offshore_pump_crafted = craft_item(Prototype.OffshorePump, 1)\n assert offshore_pump_crafted == 1, "Failed to craft offshore pump"\n\n # Final check: Ensure we have an offshore pump in our inventory\n inventory = inspect_inventory()\n assert inventory.get(Prototype.OffshorePump, 0) >= 1, "Offshore pump not found in inventory"\n\n print("Successfully crafted one offshore pump!")\n\n\n###FUNC DIFF\ncraft_offshore_pump()`
ERROR MESSAGE
'2: Error at lines 93-93: (\'Could not place stone-furnace at (0.0, 0.0)\', \'[string "global.actions.place_entity = function(player..."]:21: The target position is too far away to place the entity. The player position is 20.5, 18.5 and the target position is 0, 0. The distance is 27.613402542968 and the max distance is 10. Move closer.\')'
@@ -13,7 +13,7 @@ EXAMPLE OUTPUT
ERROR ANALYSIS
Analysing the functions and the error message it seems that the user is trying to place the furnace too far away from them. We thus need to move closer to the furnace position if we want to place it there
ERROR CORRECTION
```'from factorio_instance import *\n\n\ndef craft_offshore_pump():\n """\n Objective: We need to craft one offshore pump.\n Mining setup: There are no entities on the map\n Inventory: We start with an empty inventory\n """\n # [PLANNING]\n # To craft an offshore pump, we need:\n # - 2 iron gear wheels (each requires 2 iron plates)\n # - 1 electronic circuit (requires 1 iron plate and 3 copper cables)\n # - 1 pipe (requires 1 iron plate)\n # \n # Total raw materials needed:\n # - 6 iron plates (2 for gear wheels, 1 for circuit, 1 for pipe, 2 for pump)\n # - 3 copper plates (for the electronic circuit)\n # \n # Steps:\n # 1. Mine iron ore and copper ore\n # 2. Smelt iron and copper plates\n # 3. Craft iron gear wheels\n # 4. Craft copper cables\n # 5. Craft electronic circuit\n # 6. Craft pipe\n # 7. Finally, craft the offshore pump\n # [END OF PLANNING]\n\n # Step 1: Mine iron ore and copper ore\n iron_position = nearest(Resource.IronOre)\n move_to(iron_position)\n iron_ore_mined = harvest_resource(iron_position, 6)\n assert iron_ore_mined >= 6, f"Failed to mine enough iron ore. Got {{iron_ore_mined}}, need 6."\n\n copper_position = nearest(Resource.CopperOre)\n move_to(copper_position)\n copper_ore_mined = harvest_resource(copper_position, 3)\n assert copper_ore_mined >= 3, f"Failed to mine enough copper ore. Got {{copper_ore_mined}}, need 3."\n\n # Step 2: Smelt iron and copper plates\n furnace_pos = Position(x=0, y=0)\n move_to(furnace_pos)\n furnace = place_entity(Prototype.StoneFurnace, position=furnace_pos)\n assert furnace, "Failed to place stone furnace"\n\n # Mine some coal for the furnace\n coal_position = nearest(Resource.Coal)\n move_to(coal_position)\n coal_mined = harvest_resource(coal_position, 10)\n assert coal_mined >= 10, f"Failed to mine enough coal. Got {{coal_mined}}, need 10."\n\n # Smelt iron plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.IronOre, furnace, 6)\n sleep(10) # Wait for smelting\n iron_plates = extract_item(Prototype.IronPlate, furnace.position, 6)\n assert iron_plates, "Failed to smelt iron plates"\n\n # Smelt copper plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.CopperOre, furnace, 3)\n sleep(10) # Wait for smelting\n copper_plates = extract_item(Prototype.CopperPlate, furnace.position, 3)\n assert copper_plates, "Failed to smelt copper plates"\n\n # Step 3: Craft iron gear wheels\n gear_wheels_crafted = craft_item(Prototype.IronGearWheel, 2)\n assert gear_wheels_crafted == 2, f"Failed to craft 2 iron gear wheels. Crafted {{gear_wheels_crafted}}"\n\n # Step 4: Craft copper cables\n copper_cables_crafted = craft_item(Prototype.CopperCable, 3)\n assert copper_cables_crafted == 3, f"Failed to craft 3 copper cables. Crafted {{copper_cables_crafted}}"\n\n # Step 5: Craft electronic circuit\n circuit_crafted = craft_item(Prototype.ElectronicCircuit, 1)\n assert circuit_crafted == 1, "Failed to craft electronic circuit"\n\n # Step 6: Craft pipe\n pipe_crafted = craft_item(Prototype.Pipe, 1)\n assert pipe_crafted == 1, "Failed to craft pipe"\n\n # Step 7: Craft offshore pump\n offshore_pump_crafted = craft_item(Prototype.OffshorePump, 1)\n assert offshore_pump_crafted == 1, "Failed to craft offshore pump"\n\n # Final check: Ensure we have an offshore pump in our inventory\n inventory = inspect_inventory()\n assert inventory.get(Prototype.OffshorePump, 0) >= 1, "Offshore pump not found in inventory"\n\n print("Successfully crafted one offshore pump!")\n\n\n###FUNC DIFF\ncraft_offshore_pump()```
`'from factorio_instance import *\n\n\ndef craft_offshore_pump():\n """\n Objective: We need to craft one offshore pump.\n Mining setup: There are no entities on the map\n Inventory: We start with an empty inventory\n """\n # [PLANNING]\n # To craft an offshore pump, we need:\n # - 2 iron gear wheels (each requires 2 iron plates)\n # - 1 electronic circuit (requires 1 iron plate and 3 copper cables)\n # - 1 pipe (requires 1 iron plate)\n # \n # Total raw materials needed:\n # - 6 iron plates (2 for gear wheels, 1 for circuit, 1 for pipe, 2 for pump)\n # - 3 copper plates (for the electronic circuit)\n # \n # Steps:\n # 1. Mine iron ore and copper ore\n # 2. Smelt iron and copper plates\n # 3. Craft iron gear wheels\n # 4. Craft copper cables\n # 5. Craft electronic circuit\n # 6. Craft pipe\n # 7. Finally, craft the offshore pump\n # [END OF PLANNING]\n\n # Step 1: Mine iron ore and copper ore\n iron_position = nearest(Resource.IronOre)\n move_to(iron_position)\n iron_ore_mined = harvest_resource(iron_position, 6)\n assert iron_ore_mined >= 6, f"Failed to mine enough iron ore. Got {{iron_ore_mined}}, need 6."\n\n copper_position = nearest(Resource.CopperOre)\n move_to(copper_position)\n copper_ore_mined = harvest_resource(copper_position, 3)\n assert copper_ore_mined >= 3, f"Failed to mine enough copper ore. Got {{copper_ore_mined}}, need 3."\n\n # Step 2: Smelt iron and copper plates\n furnace_pos = Position(x=0, y=0)\n move_to(furnace_pos)\n furnace = place_entity(Prototype.StoneFurnace, position=furnace_pos)\n assert furnace, "Failed to place stone furnace"\n\n # Mine some coal for the furnace\n coal_position = nearest(Resource.Coal)\n move_to(coal_position)\n coal_mined = harvest_resource(coal_position, 10)\n assert coal_mined >= 10, f"Failed to mine enough coal. Got {{coal_mined}}, need 10."\n\n # Smelt iron plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.IronOre, furnace, 6)\n sleep(10) # Wait for smelting\n iron_plates = extract_item(Prototype.IronPlate, furnace.position, 6)\n assert iron_plates, "Failed to smelt iron plates"\n\n # Smelt copper plates\n insert_item(Prototype.Coal, furnace, 5)\n insert_item(Prototype.CopperOre, furnace, 3)\n sleep(10) # Wait for smelting\n copper_plates = extract_item(Prototype.CopperPlate, furnace.position, 3)\n assert copper_plates, "Failed to smelt copper plates"\n\n # Step 3: Craft iron gear wheels\n gear_wheels_crafted = craft_item(Prototype.IronGearWheel, 2)\n assert gear_wheels_crafted == 2, f"Failed to craft 2 iron gear wheels. Crafted {{gear_wheels_crafted}}"\n\n # Step 4: Craft copper cables\n copper_cables_crafted = craft_item(Prototype.CopperCable, 3)\n assert copper_cables_crafted == 3, f"Failed to craft 3 copper cables. Crafted {{copper_cables_crafted}}"\n\n # Step 5: Craft electronic circuit\n circuit_crafted = craft_item(Prototype.ElectronicCircuit, 1)\n assert circuit_crafted == 1, "Failed to craft electronic circuit"\n\n # Step 6: Craft pipe\n pipe_crafted = craft_item(Prototype.Pipe, 1)\n assert pipe_crafted == 1, "Failed to craft pipe"\n\n # Step 7: Craft offshore pump\n offshore_pump_crafted = craft_item(Prototype.OffshorePump, 1)\n assert offshore_pump_crafted == 1, "Failed to craft offshore pump"\n\n # Final check: Ensure we have an offshore pump in our inventory\n inventory = inspect_inventory()\n assert inventory.get(Prototype.OffshorePump, 0) >= 1, "Offshore pump not found in inventory"\n\n print("Successfully crafted one offshore pump!")\n\n\n###FUNC DIFF\ncraft_offshore_pump()`
USER INPUT
{objective}
@@ -30,4 +30,4 @@ ERROR MESSAGE
GAME_LOG
{game_log}
OUTPUT THE WHOLE POLICY WITH ALL FUNCTION DEFINITIONS
OUTPUT THE WHOLE POLICY WITH ALL FUNCTION DEFINITIONS

View File

@@ -4,4 +4,4 @@ EXAMPLE INPUTS AND PLANS
{examples}
USER INPUT
{user_input}
{user_input}

View File

@@ -5,19 +5,20 @@ The second step is ERROR CORRECTION. In error correction you need to create a wo
SPECS
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
Only write in python in ```blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
Do not use try-catch as it will hide the error message.
Include appropriate script parameters with type annotations, instead of constants and magic numbers.
Import: `from factorio_instance import *`
Import:`from factorio_instance import \*`
IMPORTANT
Make sure it is a script and not a function. it must be a script that can be directly run and not a function definition
Also add assert tests during the script to check that intermediate steps are done right. For instance if something is harvested, crafted or extracted, you can inspect the inventory to check the outcome. Asserts should also have informative error messages if the assert fails
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer
- To put items into entities (for instance a chest or a furnace) automatically you need to add an inserter. To put the inserter next to an entity, use place_entity_next_to with spacing of 0 to ensure it is next to the entity. Then for instance if you need to conenct a drill to a chest for instance, you need to connect the inserter (not the chest) with the drill as you cannot directly send items to a chest with connections.
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity. When you rotate it, you need to update the python variable with the rotation command , for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
When you place an entity to a position with place_entity, first move near to that position as the player can only palce entities within 10 coordinate radius of themselves. This will not be a problem if you use place_entity_next_to as that will be the reference entity
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective
Remember you need to rotate the inserter to put items into an entity as by default it takes from the entity. When you rotate it, you need to update the python variable with the rotation command , for example inserter = rotate_entity(inserter, Direction.UP). You don't need to assert and check the rotation success as that will always work using the game api
If you do need to check any directions of entities, you need to use entity.direction.value, for instance inserter_chest.direction.value == Direction.DOWN
Use pickup and drop positions where possible to connect entities
When you insert coal into entities to fuel them, assume that this step was done correctly and do not write a assert test for this step. Getting the fuel_inventory has a bug and will be fixed soon
When you place an entity to a position with place_entity, first move near to that position as the player can only palce entities within 10 coordinate radius of themselves. This will not be a problem if you use place_entity_next_to as that will be the reference entity
Connecting entities when they are far works and is not a problem. If the objective asks to connect entities that are far away, do not move them closer to each other as that is against the obective

View File

@@ -4,7 +4,7 @@ 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!")```
`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.\')'
@@ -13,7 +13,7 @@ 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```
`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}
@@ -25,4 +25,4 @@ LATEST SCRIPT RUN
{last_executed_policy}
ERROR MESSAGE
{error_message}
{error_message}

View File

@@ -5,12 +5,12 @@ The second step is ERROR CORRECTION. In error correction you need to create a wo
SPECS
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
Only write in python in ```blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
Do not use try-catch as it will hide the error message.
Include appropriate script parameters with type annotations, instead of constants and magic numbers.
Import: `from factorio_instance import *`
Import:`from factorio_instance import \*`
IMPORTANT
Make sure it is a script and not a function. it must be a script that can be directly run and not a function definition
Also add assert tests during the script to check that intermediate steps are done right. For instance if something is harvested, crafted or extracted, you can inspect the inventory to check the outcome. Asserts should also have informative error messages if the assert fails
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer

View File

@@ -7,15 +7,15 @@ In general to craft copper plates, we need to craft a furnace, mine copper ore a
STEPS
To smelt copper plates the plan is as follows
1) As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2) Craft stone furnace
3) Mine coal for stone furnace
4) Move to copper ore
5) Place down stone furnace
6) Mine copper ore
7) Place coal and copper ore to stone furnace
8) Smelt copper ore for copper plates
1. As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2. Craft stone furnace
3. Mine coal for stone furnace
4. Move to copper ore
5. Place down stone furnace
6. Mine copper ore
7. Place coal and copper ore to stone furnace
8. Smelt copper ore for copper plates
EXAMPLE OUTPUT
@@ -79,7 +79,7 @@ if number_of_copper_plates < 5:
extract_item(Prototype.CopperPlate, stone_furnace, 5)
# make final test whether we have 5 copper plates
number_of_copper_plates = inspect_inventory()[Prototype.CopperPlate]
assert number_of_copper_plates == 5, f"Inventory does not have 5 copper plates, it has {{number_of_copper_plates}}"
assert number_of_copper_plates == 5, f"Inventory does not have 5 copper plates, it has {{number_of_copper_plates}}"
```
@@ -91,4 +91,4 @@ Here are the scripts that have been run and have resulted in errors
Here is the latest script that was run and created a error message
{last_executed_policy}
Here is the error message that it produced
{error_message}
{error_message}

View File

@@ -7,12 +7,12 @@ You also have access to inventory. If possible, use materials from inventory to
SPECS
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
Only write in python in ```blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
Do not use try-catch as it will hide the error message.
Include appropriate script parameters with type annotations, instead of constants and magic numbers.
Import: `from factorio_instance import *`
Import:`from factorio_instance import \*`
IMPORTANT
Make sure it is a script and not a function. it must be a script that can be directly run and not a function definition
Also add assert tests during the script to check that intermediate steps are done right. For instance if something is harvested, crafted or extracted, you can inspect the inventory to check the outcome. Asserts should also have informative error messages if the assert fails
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer

View File

@@ -7,15 +7,15 @@ In general to craft copper plates, we need to craft a furnace, mine copper ore a
STEPS
To smelt copper plates the plan is as follows
1) As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2) Craft stone furnace
3) Mine coal for stone furnace
4) Move to copper ore
5) Place down stone furnace
6) Mine copper ore
7) Place coal and copper ore to stone furnace
8) Smelt copper ore for copper plates
1. As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2. Craft stone furnace
3. Mine coal for stone furnace
4. Move to copper ore
5. Place down stone furnace
6. Mine copper ore
7. Place coal and copper ore to stone furnace
8. Smelt copper ore for copper plates
EXAMPLE OUTPUT
@@ -85,7 +85,7 @@ if number_of_copper_plates < 5:
break
# make final test whether we have 5 copper plates
number_of_copper_plates = inspect_inventory()[Prototype.CopperPlate]
assert number_of_copper_plates >= 5, f"Inventory has less than 5 copper plates, it has {{number_of_copper_plates}}"
assert number_of_copper_plates >= 5, f"Inventory has less than 5 copper plates, it has {{number_of_copper_plates}}"
```
@@ -108,4 +108,4 @@ Here is the latest script that was run and created a error message
###LATEST ERROR MESSAGE
Here is the error message that it produced
{error_message}
{error_message}

View File

@@ -1,21 +1,24 @@
# Check if we have enough copper plates in the inventory
inventory = inspect_inventory()
copper_plates = inventory.get(Prototype.CopperPlate, 0)
# Calculate the number of copper plates needed (2 cables per plate)
plates_needed = quantity // 2 + (1 if quantity % 2 != 0 else 0)
if copper_plates < plates_needed:
print(f"Not enough copper plates. Have {copper_plates}, need {plates_needed}")
return False
print(f"Not enough copper plates. Have {copper_plates}, need {plates_needed}")
return False
# Craft the copper cables
cables_crafted = 0
while cables_crafted < quantity:
craft_success = craft_item(Prototype.CopperCable, 2)
if not craft_success:
print(f"Failed to craft copper cables. Crafted {cables_crafted} out of {quantity}")
raise RuntimeError(f"Failed to craft copper cables. Crafted {cables_crafted} out of {quantity}")
cables_crafted += 2
print(f"Successfully crafted {cables_crafted} copper cables")
craft_success = craft_item(Prototype.CopperCable, 2)
if not craft_success:
print(f"Failed to craft copper cables. Crafted {cables_crafted} out of {quantity}")
raise RuntimeError(f"Failed to craft copper cables. Crafted {cables_crafted} out of {quantity}")
cables_crafted += 2
print(f"Successfully crafted {cables_crafted} copper cables")

View File

@@ -1,8 +1,8 @@
You are an AI agent creating Python policy functions to achieve Factorio game objectives.
The function should be named '{function_name}'.
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
Only write in python in ```blocks.
Ensure the function raises an uncaught exception if something goes wrong at runtime.
Do not use try-catch as it will hide the error message.
Include appropriate function parameters with type annotations, instead of constants and magic numbers.
Import: `from factorio_instance import *`
Import:`from factorio_instance import \*`

View File

@@ -1,2 +1,2 @@
Use the API to write a Python policy function to achieve the objective: '{objective}'. Here are the steps to achieve the objective:
{steps}
{steps}

View File

@@ -1,14 +1,14 @@
You are an AI agent creating Python policy scripts to achieve Factorio game objectives.
You have the following api schema available to you {api_schema}
Only write in python in ``` blocks.
Only write in python in ```blocks.
Ensure the script raises an uncaught exception if something goes wrong at runtime.
Do not use try-catch as it will hide the error message.
Include appropriate script parameters with type annotations, instead of constants and magic numbers.
Import: `from factorio_instance import *`
You are given the objective and a plan how to carry out the objective. The plan has a SUMMARY part, which is a general summary of the steps and a STEPS part, which outlines the exact steps needed to be taken. Use the plan and the api to write the python script.
Import:`from factorio_instance import \*`
You are given the objective and a plan how to carry out the objective. The plan has a SUMMARY part, which is a general summary of the steps and a STEPS part, which outlines the exact steps needed to be taken. Use the plan and the api to write the python script.
IMPORTANT
Make sure it is a script and not a function. it must be a script that can be directly run and not a function definition
Also add assert tests during the script to check that intermediate steps are done right. For instance if something is harvested, crafted or extracted, you can inspect the inventory to check the outcome. Asserts should also have informative error messages if the assert fails
When smelting, it is important to wait until the smelting is completed. Use extracts and asserts to check when the smelting is completed. If you extract less than you put in, you need to wait for longer
When placing objects, place them close to the player or nearby resources as placing them too far is not allowed and will error out the game
You also have access to inventory. If possible, use materials from inventory to achieve the goals
You also have access to inventory. If possible, use materials from inventory to achieve the goals

View File

@@ -7,15 +7,15 @@ In general to craft copper plates, we need to craft a furnace, mine copper ore a
STEPS
To smelt copper plates the plan is as follows
1) As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2) Craft stone furnace
3) Mine coal for stone furnace
4) Move to copper ore
5) Place down stone furnace
6) Mine copper ore
7) Place coal and copper ore to stone furnace
8) Smelt copper ore for copper plates
1. As the copper plate requires stone furnace to smelt, first we need to mine 5 stone and
2. Craft stone furnace
3. Mine coal for stone furnace
4. Move to copper ore
5. Place down stone furnace
6. Mine copper ore
7. Place coal and copper ore to stone furnace
8. Smelt copper ore for copper plates
EXAMPLE OUTPUT
@@ -85,10 +85,10 @@ if number_of_copper_plates < 5:
break
# make final test whether we have 5 copper plates
number_of_copper_plates = inspect_inventory()[Prototype.CopperPlate]
assert number_of_copper_plates >= 5, f"Inventory has less than 5 copper plates, it has {{number_of_copper_plates}}"
assert number_of_copper_plates >= 5, f"Inventory has less than 5 copper plates, it has {{number_of_copper_plates}}"
```
USER INPUT
Create the script to '{objective}' with inventory {inventory}. Here is the plan to achieve the objective:
{steps}
{steps}

View File

@@ -33,16 +33,16 @@ To submit new model results to the leaderboard:
## Fields Explanation
| Field | Description |
|-------|-------------|
| `name` | Name of the model
| `productionScore` | Total production score achieved
| `milestones` | Number of milestones reached
| `automationMilestones` | Number of automation milestones reached
| `labTasksSuccessRate` | Percentage of lab tasks successfully completed
| `mostComplexItem` | Most complex item produced
| `submittedBy` | Your name or identifier
| `submissionDate` | Date of submission (YYYY-MM-DD)
| Field | Description |
| ---------------------- | ---------------------------------------------- |
| `name` | Name of the model |
| `productionScore` | Total production score achieved |
| `milestones` | Number of milestones reached |
| `automationMilestones` | Number of automation milestones reached |
| `labTasksSuccessRate` | Percentage of lab tasks successfully completed |
| `mostComplexItem` | Most complex item produced |
| `submittedBy` | Your name or identifier |
| `submissionDate` | Date of submission (YYYY-MM-DD) |
## How It Works

Some files were not shown because too many files have changed in this diff Show More