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.nemofication wrote:I'm interested, I found this topic by googling "Gephi Factorio"
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!
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
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
...
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"
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 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 ...