Factsim - A Factorio combinator simulator

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Factsim - A Factorio combinator simulator

Post by cid0rz »

Hello guys. I was just wiring too much in Factorio ^^, after doing my train delivery system and testing it under many circumstances i wanted to improve it in some ways. The problem is developing complex systems in Factorio directly has some inconveniences. So as I have some basic skills in python programming I came up (yes, i know) with the crazy idea of doing a simulator where you can test the circuits and debug your systems. So Then I started to work, reading, thinking etc. I came across really nice information. I was able to decode a blueprint string with the old format (I'm struggling with the new one still) and then i found a library for creating flowcharts (pyDrawing) that was old but looked good. Then I came here for the blueprint string code after asking DaveMc. I saw some things I didn't know about, I was not aware of this subforum, I should have checked before ^^.

Now that the intro is done, what do you think about the idea? This would be my first open source project so be patient with me :roll: but I was just watching if it was possible and playing with the idea. I think It won't be easy but it can be fun, I'd like to learn better programming so that's what I was doing this for originally. In the pyDrawing library there is an example editor program that I'm using as base. I changed the left toolbar and customized the created entities (just the text for now) and here you can see an screenshot:
old image
So for now none of the behavior (that has been extended in 0.15) has been implemented. In fact now I was planning to change the connections since the library has some way of connecting entitites and keeping them connected but not enough control to implement green and red wire and signal transfer etc. The idea is to once drawn or imported, the circuit can be run tick by tick, getting the output in certain points. I don't know how far will I be able to go with my poor skills but it would be nice to have something flexible and easy to use. A configuration window for the entitites is needed and maybe also a new entity, called network or circuit to store and propagate the signals.

If you have comments, suggestions, if you want to help or even to lead this project, you are welcomed as long as I can bother you a bit xD. For now as I say alsoo one of may main concerns is not being able to decode the blueprints. I'm trying since the error says incorrect padding for the base64 encoding to pad it but doesn't work.
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by cid0rz »

Hello all, after trying a bit I spent too much time learning stuff about GUI's and at some point I got a bit bored since it was not my main objective for this project. Also using a library that is not mantained or updated is not a good idea. I found some bugs on the library and i didn't finally liked how it all worked. Also I'm quite noob programmer as stated so I decided to star programming the simulator and just make like a command line old style program :shock: My plan is to ddevelop a bit the interface just by pure scripting and printing or with some tool like urwid or a command line suite.

For now I've tested it with simple circuits and there is a lot I have to test with special cases.

first one is a simple clock a constant combinator outputting 1 signal A and a decider looped that will output A<20
blueprint 0.15version

second one is sort of a special switch that stores negative values from a constant combinator but only one tick and untill you turn off the constant combinator the cell will be blocked. I added the upmost decider to make a backwards counter :mrgreen:
images
blueprint 0.15version
You can find the outputs as .txt attached. You'll need notepad++ or similar to be able to see until tick 30. Notepad cuts it at 19 or so.

I'm very happy so far to have something that at least works xD. My idea is to put it on github soon :D
Attachments
outputswitch.txt
(22.72 KiB) Downloaded 368 times
outputclock.txt
(10.05 KiB) Downloaded 339 times
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by cid0rz »

So here is the github link that the factsimguru gave me:

https://github.com/Factsimguru/Factsim
User avatar
provet
Fast Inserter
Fast Inserter
Posts: 133
Joined: Thu Feb 12, 2015 9:49 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by provet »

interesting idea, too bad it hasn't got much attention
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by cid0rz »

Hey I got some interest from another player on PM, would you also be interested in doing/improving this? ^^
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by cid0rz »

Some improvements have been made and now it actaully works :P. I would be glad if somebody can test it and give some feedback.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Factsim - A Factorio combinator simulator

Post by Qon »

I'm considering making some sort of text language that compiles to combinators, and a HDL maybe. Might never happen at this rate, but maybe.
But I appreciate the effort in adjacent areas, even if it's not quite what I'm looking for. Seems like a great and impressive project. I might try it out some time if need arises, but anyways hope you get good use of it and continue to share further developments on the tool!
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Aquilo
Burner Inserter
Burner Inserter
Posts: 9
Joined: Wed Nov 14, 2018 9:15 am
Contact:

Re: Factsim - A Factorio combinator simulator

Post by Aquilo »

What am I doing wrong?

python-3.8.0-embed-win32\python.exe FactSim.py

Code: Select all

Traceback (most recent call last):
  File "factsim.py", line 30, in <module>
    import tkinter as tk
ModuleNotFoundError: No module named 'tkinter'
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 538
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by Silari »

You don't have the tkinter module installed in your python environment. It was included by default on Windows but that may have changed, and can depend on how you installed python. Look up how to install python modules for your setup and install the tkinter module.
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by spacedestructor »

I may have done some errors on my end since i dont have any previous python experience but i did install python to test this out and its always either giving out errors or just not doing anything at all.
So im simply just posting the error thats related to the project it self and not python. dont know if im missing any dependencies and if yes how i would get those.
The Error is as follows:

Code: Select all

opening: L:/Tools/Factorio/Factsim/Factsim-master/FactSim.py from filedialog
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\base64.py", line 37, in _bytes_from_decode_data
    return s.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\u2265' in position 9615: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "L:\Tools\Factorio\Factsim\Factsim-master\FactSim.py", line 1046, in <module>
    f = Factsimcmd()
  File "L:\Tools\Factorio\Factsim\Factsim-master\FactSim.py", line 665, in __init__
    self.blueprint = open_blueprint(filename=filename)
  File "L:\Tools\Factorio\Factsim\Factsim-master\FactSim.py", line 74, in open_blueprint
    jsonstringdata = base64.b64decode(jsonstring64)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\base64.py", line 80, in b64decode
    s = _bytes_from_decode_data(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\base64.py", line 39, in _bytes_from_decode_data
    raise ValueError('string argument should contain only ASCII characters')
ValueError: string argument should contain only ASCII characters
PostmodernPrometheus
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Jul 20, 2023 4:03 am
Contact:

Re: Factsim - A Factorio combinator simulator

Post by PostmodernPrometheus »

It looks like you're trying to import a blueprint with a non-ascii character in it, it's complaining that the 9615'th character is not a valid ascii character ('\u2265' is apparently a non-ascii greater-than-equals character - ref).

Factorio blueprints are all base64 encoded. Base64 encodes everything to ascii-only characters, so you shouldn't be getting non-ascii characters.

I'd guess you saved the blueprint in a Microsoft product that does autocorrect (like Outlook or Word) and it automatically changed two ascii characters ">=" into a single unicode character "≥".

If you can, just copy-paste directly from Factorio into python. Or if you need to save a blueprint to a file you can use something like Notepad++ that will treat ascii text as plain-old text.
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: Factsim - A Factorio combinator simulator

Post by spacedestructor »

PostmodernPrometheus wrote: Fri Sep 29, 2023 6:21 pm It looks like you're trying to import a blueprint with a non-ascii character in it, it's complaining that the 9615'th character is not a valid ascii character ('\u2265' is apparently a non-ascii greater-than-equals character - ref).

Factorio blueprints are all base64 encoded. Base64 encodes everything to ascii-only characters, so you shouldn't be getting non-ascii characters.

I'd guess you saved the blueprint in a Microsoft product that does autocorrect (like Outlook or Word) and it automatically changed two ascii characters ">=" into a single unicode character "≥".

If you can, just copy-paste directly from Factorio into python. Or if you need to save a blueprint to a file you can use something like Notepad++ that will treat ascii text as plain-old text.
What i did was saving it to a text file using visual studio code since thats my default text editor and i know it doesnt auto correct anything. so im confused how a non modified factorio string straight from the game can generate an error.
PostmodernPrometheus
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Jul 20, 2023 4:03 am
Contact:

Re: Factsim - A Factorio combinator simulator

Post by PostmodernPrometheus »

spacedestructor wrote: Fri Sep 29, 2023 10:00 pm [What i did was saving it to a text file using visual studio code since thats my default text editor and i know it doesnt auto correct anything. so im confused how a non modified factorio string straight from the game can generate an error.
Yeah that's weird, I can't explain that. I f don't know if you've seen/used this web encoder/decoder but it might give you a second opinion: https://factorio.tmin10.ru/
Post Reply

Return to “Tools”