Skip to content

[Discussion] YAFC 2.0 #542

@SWeini

Description

@SWeini

Make new YAFC from scratch. Same as now, only better, and easier to maintain.

Motivation

It became quite difficult to add new features and many of the core systems need a rework. It might be easier to rewrite from scratch than to refactor all core systems one after another.

Changes

External Program vs. Mod

I'm assuming here that YAFC stays an external program. However, Helmod and Factory Planner provide a good alternative and currently the main selling points for YAFC are:

  • Best solver (simplex method using OR-tools)
  • Cost analysis (even if it has some problems)
  • Used on separate monitor (preferred by some, others prefer an in-game solution)

Therefore we should think really hard about going the mod route before rewriting from scratch.

Lua Runtime vs. JSON Export

It is quite difficult to duplicate factorio's Lua runtime 100% accurately. In the past there have been plenty of mods that failed to load or needed adjustments in that area. There is an easier way: Factorio supports a bunch of command line parameters to export most relevant data:

  • --dump-data can replace the whole Lua runtime with a simple json parser
  • --dump-icon-sprites generates easy-to-use icons for each item/fluid/recipe/entity. Right now not all icons are shown 100% accurately. Could fix all those bugs and remove a bunch of code at the same time.
  • --dump-prototype-locale generates easy-to-use translations for each item/fluid/recipe/entity. Same here, currently not everything has correct locales, could remove a bunch of code.

In general, this would remove a quite large part of the codebase and replace it with something simpler. As long as factorio can load a specific set of mods it is guaranteed that YAFC can also use it, and that the data/icons/locales do match perfectly.

All the data should be zipped and saved as a modpack file. YAFC project files would specify such a modpack and loading a project file simply needs to load the data, resulting in significant performance improvements during load.

With all data being easily available it will be possible to show a diff of two modpack files (e.g. after updating mods). I used Foreman in the past, just to see what changed after updating mods, because they provide modpack files (via its own exporter mod).

This change needs a different way for mods to specify scripted mechanics. The current way does kind of work, but it's also very limited because it doesn't support anything that can't be expressed in normal factorio prototypes. Not fitting into factorio prototypes is the main reason to add scripted mechanics.

We would also lose the ability to exclude mods completely. This is currently a great feature for mods that only provide item compression (deadlock stacking) or transportation (transport drones). However, you will always have the possibility to create a modpack file with those mods disabled.

There is a machine-readable API declaration, I already tried using this to generate a full data-stage json parser, but it needs too much manual adjustment and the API changes almost every factorio version which complicates things further, even though most API changes are backwards compatible.

GUI

Many contributors have expressed concerns in the current way of doing GUI things. I don't want to pinpoint specific problems here, but there is plenty of room for improvement. The main goal of rewriting the whole GUI layer is a strict separation of the GUI layer, making it possible to write tests for the rest of the codebase.

Maybe even think about changing the GUI framework.

Recipe

Currently everything is converted to fake recipes which works OK-ish for some things (e.g. boilers) and less so for others (e.g. spoilage). The goal is to replace recipes with something more abstract and flexible. Recipes are just one specialization of it.

Unspecified Inputs

Allow fluid inputs to not define a specific temperature (and use whatever is available). Allow fluid fuel and item fuel to not define specific fluids/items (and work with an abstract fuel).

This makes it possible to not care about the specific fuel at all or change the fuel for a whole sheet at once. But it is also important for the next point.

Cost Analysis

Currently gives a good estimation for most recipes, but is totally wrong on others. Areas to improve are:

  • prod/speed/efficiency modules
  • fluid/item fuels
  • proper temperature handling
  • proper cost for electricity
  • multi-surface analysis with inter-planetary logistic costs
  • rewrite ore-density detection for 2.0
  • configurable cost function
  • configurable optimization target.

Serialization and Undo/Redo System

I didn't look into this topic too closely yet, but I've heard complaints about code quality and ease of understanding in this area. Might be worth looking into ways to drastically change this, hopefully to the better.

Summary Sheets

There have been discussions about the value of the legacy summary sheets and the new summary sheets. Do a proper requirements analysis in this area.

Sheets and Sheet Solver

This might be the area that can mostly be kept. Putting a sheet into OR-tools has some complicated code, but it is a complicated thing to do.

There are probably a few improvements that can be made. Yes, all of them could probably be done in the current system, but many of the above topics complicate things.

  • multiple beacon types
  • surface-to-surface logistic costs
  • in general more support for multi-surface mods (building restrictions and such)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions