Abandoned graphics / directed network graphs (image heavy)

Place to share your custom game graphics.
User avatar
Deadlock989
Filter Inserter
Filter Inserter
Posts: 558
Joined: Fri Nov 06, 2015 7:41 pm

Re: WIP: Deadlock's Industrial Revolution (image heavy)

Post by Deadlock989 » Thu May 24, 2018 9:47 am

nemofication wrote:I'm interested, I found this topic by googling "Gephi Factorio" :D

I wouldn't mind a step-by-step guide, this software confuses me a lot! I've been wanting to make some more sense of AngelBob and perhaps even go for a bus design if I could just visualize the requirements first!
It's not very straightforward, I can give some help/advice but it would take much too long to write out a full step by step guide for total beginners. You need to know something about Factorio modding and Lua because you'll need to adapt this to your situation.

To make a directed network graph, Gephi needs two lists: a node list and an edge list. These can be CSV files (among other things). The nodes are the blobs, the edges are the lines connecting them. For our purposes, the nodes are the Factorio research technologies and the edges represent connections between techs and the prerequisite techs you need to have researched to get there. Fortunately, in Factorio's data structure, every technology contains a list of its own prerequisites so we don't need to search for them. Also fortunately, every node must have a unique identifier, which Factorio also provides (the technology ID). So we first want to output a list of all the technologies, one line per technology. The ID comes first, then a human-readable label, and then any data that you might want to visually differentiate the nodes (colour or size of the blob). You actually only the need the ID, the other things are optional, but the tech IDs are usually quite a long string so I used a truncated version of it as the readable label and then I was able to use a number pulled from the data about science pack ingredients to say what "tier" the tech was, this only worked because my overhaul mod had also previously completely reworked all science costs, you'd have to work out something different for other mods. It's possible in Factorio to dump output to a dedicated log file but I never bothered with that, I just put it in the main Factorio log and then cut and paste it into its own .csv file afterwards.

My code for that part looked like this, you'll have to adapt it. I ignored any tech that was disabled and if it was a repeating research thing (e.g. artillery range, mining productivity) I ignored it after the 7th tier.

Code: Select all

    local output = "\n\n"..title.."\n\nNODES:\n\n"
    output = output .."id,label,tier\n"
    for _,t in pairs(data.raw.technology) do
        local lastchar = string.sub(t.name,-1,-1)
        local inrange = not tonumber(lastchar) or tonumber(lastchar) <= 7
        local label = ""
        if t.enabled ~= false and inrange then
            for i in string.gmatch(t.name, "%w+") do label = label .. string.upper(string.sub(i,1,1)) end
            output = output..t.name..","..label..","..string.sub(t.unit.ingredients[1][1],-1,-1).."\n"
        end
    end
The output ends up looking like this:

Code: Select all

id,label,tier
military,M,science-2
military-2,M2,science-4
military-3,M3,science-4
military-4,M4,science-4
uranium-ammo,UA,science-5
atomic-bomb,AB,science-5
grenade-damage-1,GD1,science-4
...
The edge list has to be a single line per edge, giving the two node IDs that are being connected. The first ID is the source (the node the connecting arrow is coming from), the second is the target (the node it's going to). You just loop through every technology and if it has any prereqs, output a line for each. Edges do have their own ID as well but you don't need to worry about that, Gephi will auto assign one.

Code: Select all

output = output .."\nEDGES:\n\nsource,target\n"
    for _,t in pairs(data.raw.technology) do
        local lastchar = string.sub(t.name,-1,-1)
        local inrange = not tonumber(lastchar) or tonumber(lastchar) <= 7
        if t.prerequisites and t.enabled ~= false and inrange then
            for _,p in pairs(t.prerequisites) do
                output = output..p..","..t.name.."\n"
            end
        end
    end
    output = output .. "\n\n"
The output from that ends up looking like this:

Code: Select all

source,target
automation-2,military
grinding,military
automation-4,military-2
military,military-2
military-2,military-3
explosives,military-4
military-3,military-4
nuclear-power,uranium-ammo
military-2,uranium-ammo
tanks,uranium-ammo
...
You've then got this big data dump stored in the variable "output", I just dumped it to the main Factorio log with log() and cut and paste each section out into their own file, nodes.csv and edges.csv. It's important that you do all of this after any of the running mods have made any changes to research or created new techs. The best way to guarantee that is to do all of this dumping as late as possible (i.e. in data-final-fixes.lua) and also make sure your mini-mod that's doing the dumping lists your main mods (e.g. Angel's) as dependencies so that they load and run first.

You can then import your .csv files into a new Gephi project. Go to File > Import spreadsheet, select your files, and work through the wizard, once for each file. This part is quite easy. If you named the files nodes.csv and edges.csv it'll auto-detect which kind of data they are, if they're named something else you'll have to manually tell it what the data is. You should then have your basic data and can play around with how it's displayed (size/colour/weight of the nodes and edges etc.) and use the magical Layout algorithms to space them nicely, this part is quite involved and there must be Gephi tutorials out there that can help with that, I can see a fair few on Youtube.

Good luck ...

exxocraft
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri May 25, 2018 5:53 pm

Re: Abandoned graphics / directed network graphs (image heavy)

Post by exxocraft » Fri May 25, 2018 5:55 pm

how do i crop them? i want to use an alloy furnace but it looks all messed up, like theres no side or anything, sorry, I'm new to this
Thanks

Cyphas_cain
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Jan 24, 2018 12:34 am

Re: Abandoned graphics / directed network graphs (image heavy)

Post by Cyphas_cain » Mon Nov 19, 2018 2:36 am

Deadlock, i am interested in taking over/continuing the mod (believe it was called Industrial Revolution) that these graphics came from.

If you are willing, hit me up on any of the following and we can talk more:

Steam: https://steamcommunity.com/id/CyphasCayne/
Discord: Cyphas_Cayne#8236

User avatar
Deadlock989
Filter Inserter
Filter Inserter
Posts: 558
Joined: Fri Nov 06, 2015 7:41 pm

Re: Abandoned graphics / directed network graphs (image heavy)

Post by Deadlock989 » Tue Nov 20, 2018 1:40 pm

Cyphas_cain wrote:
Mon Nov 19, 2018 2:36 am
Deadlock, i am interested in taking over/continuing the mod (believe it was called Industrial Revolution) that these graphics came from.

If you are willing, hit me up on any of the following and we can talk more:

Steam: https://steamcommunity.com/id/CyphasCayne/
Discord: Cyphas_Cayne#8236
Much is changing in 0.17-0.18 - some of them are things I put in the mod already, like reorganising the research tree to require science packs properly, having dedicated science pack research etc. There's 5 different kinds of pickaxe and they're removing pickaxes, etc. Belts are getting a total graphical rework, making everything I did with layered belts incompatible. TBH the mod is in such an unplayable state and so much will be made obsolete/broken by upcoming changes to the main game, you'd probably be better off starting fresh, with or without the graphics.

Post Reply

Return to “Texture Packs”