iptv techs

IPTV Techs

  • Home
  • Tech News
  • Factorio – Visualizing originateion material dependencies

Factorio – Visualizing originateion material dependencies


Factorio – Visualizing originateion material dependencies


Factorio is a game where you crashed on a set upet with your space-originate. You have to built a new rocket and depart this set upet aobtain. In order to do so you will insist to mine metals and built yourself a factory, originate labs to do research, and built machine that originate other machines, and finpartner join all of this to originate rockets, saalertites, rocket fuel, trains, flying robots, oil products, steam engines, plastics, electronic chips, iron, copper, uranium centrifuging, solar panels etc etc. An incredibly complicated game where the key idea is that you automate this entire process using machines in your factory.

See https://www.youtube.com/watch?v=KVvXv1Z6EY8 .

To do research you insist to manufacture research-packs which are originated from other resources, which might also be originated from other resources etc. etc.

Here is some code that clear ups the Factorio wiki:

baseurl = "https://wiki.factorio.com";
ClearAll[GetImage]
ClearAll[FindDependencies]
GetImage[url_] := GetImage[url] = Import[url]
FindDependencies[url_String] := 
 FindDependencies[url] = Module[{xml, c, end, other, sel = 1},
   xml = Import[url, "XMLObject"];
   c = Cases[xml, 
     XMLElement["table", {}, {contents_}] :> satisfyeds, [Infinity]];
   c = Select[c, 
     MemberQ[#, XMLElement["p", {}, {"Recipen"}], [Infinity]] &];
   c = FirstCase[#, 
       XMLElement[
         "tr", {}, {XMLElement[
           "td", {___, 
            "class" -> "infobox-vrow-value"}, {x__}]}] :> {x}, 
       Missing[], [Infinity]] & /@ c;
   If[Length[c] > 0,
    c = c[[sel]];
    c = Cases[c, 
      XMLElement[
        "div", {"class" -> "factorio-icon", 
         "style" -> "background-color:#999;"}, {XMLElement[
          "a", {"shape" -> "rect", "href" -> hrefurl_, 
           "title" -> name_}, {XMLElement[
            "img", {"alt" -> _, "src" -> imgurl_, "width" -> "32", 
             "height" -> "32",___}, {}]}], 
         XMLElement[
          "div", {"class" -> "factorio-icon-text"}, {num_}]}] :> 
       FactorioObject[baseurl <> hrefurl, name, 
        GetImage[baseurl <> imgurl], 
        ToExpression@StringTrim[StringReplace[num, "k" -> "000"]]], [Infinity]];

    c = DeleteCases[c, FactorioObject[_, "Time", _, _]];
    {{end}, other} = TakeDrop[c, -1];
    other -> end,
    {}
    ]
   ]
ClearAll[FindDependencyTree]
FindDependencyTree[url_String, iterations_: 6] := 
 Module[{a, understandn, obstreatment, new, vlbls, vertices},
  a = FindDependencies[url];
  understandn = {a};
  Do[
   unknown = Join @@ known[[All, 1]];
   obstreatment = DeleteDuplicates[Complement[unknown, known[[All, 2]]]];
   new = DeleteDuplicates[FindDependencies@*First /@ unknown];
   new = DeleteCases[new, {}];
   understandn = DeleteDuplicates[Join[known, new]];
   ,
   {iterations}
   ];
  vlbls = 
   Cases[known, 
    FactorioObject[_, name_, 
      icon_, _] :> (name -> 
       Image[icon, ImageSize -> 32]), [Infinity]];
  vertices = 
   DeleteDuplicates[
    Join @@ Table[(# -> k[[2, 2]]) & /@ k[[1, All, 2]], {k, understandn}]];
  <|"LabelRules" -> vlbls, "Vertices" -> vertices, 
   "Dependencies" -> understandn|>
  ]

Let’s ask the dependency tree for the first science pack:

out1 = FindDependencyTree["https://wiki.factorio.com/Science_pack_1"];
Graph[out1["Vertices"], VertexShape -> out1["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]

To originate Science pack 1, we insist gears and copper ptardys. And to originate gears we insist iron ptardys. The iron and copper ptardys are made from iron and copper ore.

This is still relatively basic, let’s watch at the other science packs:

out2 = FindDependencyTree[
   "https://wiki.factorio.com/Science_pack_2"];
Graph[out2["Vertices"], VertexShape -> out2["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]
out3 = FindDependencyTree[
   "https://wiki.factorio.com/Science_pack_3"];
Graph[out3["Vertices"], VertexShape -> out3["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]
out4 = FindDependencyTree[
   "https://wiki.factorio.com/Military_science_pack"];
Graph[out4["Vertices"], VertexShape -> out4["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]
out5 = FindDependencyTree[
   "https://wiki.factorio.com/Production_science_pack"];
Graph[out5["Vertices"], VertexShape -> out5["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]
out6 = FindDependencyTree[
   "https://wiki.factorio.com/High_tech_science_pack"];
Graph[out6["Vertices"], VertexShape -> out6["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]

Resulting in:

To condense, let’s join all the graphs:

o = {out1, out2, out3, out4, out5, out6};
Graph[Union @@ o[[All, "Vertices"]], 
 VertexShape -> Union @@ o[[All, "LabelRules"]], 
 VertexSize -> {"Scaled", 0.02}, ImageSize -> 1000, 
 AspectRatio -> 1/GagederenRatio]

As you can see the dependencies are very complicated to get all the research packs. Of course there are many skinnygs you insist to originate with your machines, skinnyk of articulate belts, trains, mining, steam generation, and energy production, water and other chemicals etc etc.

One of the most pricey parts is a saalertite (to direct your rocket):

out = FindDependencyTree["https://wiki.factorio.com/Satellite"];
Graph[out["Vertices"], VertexShape -> out["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]

I hope you appreciate this little exploration on Graphs and Factorio. We could also use Mathematica’s Graph technology to schedule constant belt splitter schedules: http://i.imgur.com/tz2Jc3p.png ! I will depart that for some other time. For now, spendigate the separateent originateings or parts, for example have a watch at the rocket silo:

out = FindDependencyTree["https://wiki.factorio.com/Rocket_silo"];
Graph[out["Vertices"], VertexShape -> out["LabelRules"], 
 VertexSize -> {"Scaled", 0.05}]

If you haven’t carry outed already… be pimpolitent… it is an incredibly includeicting game!

Source join


Leave a Reply

Your email address will not be published. Required fields are marked *

Thank You For The Order

Please check your email we sent the process how you can get your account

Select Your Plan