Skip to content

fix(research): name every Factorio 2.0 technology, accept names, list closest on unknown - #430

Open
hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/technology-enum-factorio-2
Open

hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/technology-enum-factorio-2

Conversation

@hashbender

Copy link
Copy Markdown

Problem

Technology covers 60 of the 196 technologies in Factorio 2.0 (base game). For the other 136, agents can't write Technology.X:

set_research(Technology.ResearchSpeed2)       # AttributeError
set_research(Technology.Military3)            # AttributeError
set_research(Technology.ElectricMiningDrill)  # AttributeError

Examples of the missing ones: electric-mining-drill, radar, lamp, gun-turret, military-3, research-speed-2..-6, inserter-capacity-bonus-3..-7, modules, speed-module, efficiency-module, construction-robotics, logistic-robotics and advanced-combinators.

The tools already accept a technology name string (set_research("radar") works), because the clients use technology.value only when it's there. The docs only mention the enum, though, so agents that don't find a member assume the technology can't be researched. Agents have also been seen trying set_research("research-speed") or "stack-inserter" (Factorio 1.1 names). The only reply is Technology research-speed does not exist, with nothing to say what the 2.0 name is.

Fix

  • game_types.Technology: add a member for each of the 136 missing technologies. Each one is named after its prototype name: electric-mining-drill -> ElectricMiningDrill, research-speed-2 -> ResearchSpeed2. Existing members and aliases are unchanged, and none of the new names collide with them.
  • game_types.closest_technology_names(name): returns the technology names closest to name. It lists the same name written as a member ("BulkInserter" -> bulk-inserter) first, then the levels of a leveled technology ("research-speed" -> research-speed-1..-6), then the difflib matches.
  • set_research / get_research_progress: when the game says the technology does not exist, the error now ends with . Closest technology names: .... Every other message is unchanged.
  • Docs:
    • Both agent.md files say a name string is accepted.
    • The type hints are now Union[Technology, str].
    • The get_research_progress example checked "Technology doesn't exist" in str(e), which never matches the real message (Technology <name> doesn't exist). It now checks "doesn't exist" in str(e).

Testing

  • New tests/unit/test_technology_names.py (server-free, 7 tests):
    • The set of Technology values is exactly the 196 names from game.forces.player.technologies on a Factorio 2.0.73 headless server (base mod only).
    • Naming checks.
    • closest_technology_names cases.
    • Both clients' unknown-name errors, with execute stubbed.
  • tests/unit passes (11 tests).
  • New in tests/actions/test_set_research.py: test_set_research_by_name and test_set_research_unknown_name_lists_closest_names. They need a server and are left to the factorio-test workflow; I haven't run them on this branch.
  • Live check on a 2.0.73 server with an equivalent change (run on a different FLE version):
    • set_research("radar"), set_research(Technology.ElectricMiningDrill), get_research_progress(Technology.Lamp) and get_research_progress("stone-wall") returned the game's ingredients.
    • set_research("stack-inserter") raised Technology stack-inserter does not exist. Closest technology names: fast-inserter, bulk-inserter.
  • ruff 0.11.13 format/check clean. prettier is clean on both agent.md files.

Notes

  • The system prompt includes game_types.py, so the Technology listing in it grows by 136 lines.
  • The members are a fixed list, as before. A mod or a later game version with other technologies still works through name strings.

🤖 Generated with Claude Code

… closest on unknown

- Technology: add the 136 base-game Factorio 2.0 technologies that had no member
  (bulk-inserter, research-speed-1..6, military-3, electric-mining-drill, ...),
  named after the prototype name (bulk-inserter -> BulkInserter).
- set_research / get_research_progress: document that a technology name string
  is accepted (it already was), and append the closest technology names to the
  "does not exist" / "doesn't exist" error.
- Add closest_technology_names() to game_types.
- Tests: server-free check of the enum against the 196 technologies of a 2.0.73
  server, plus set_research by name and with an unknown name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant