Page 1 of 1

Wood

Posted: Sat Jan 02, 2016 6:52 am
by Morlow
Hi guys, I just started playing Bob's mods and I was wondering about the long-term viability of hand-chopping all the wood my factory needs. Is there a tech later that allows you to create wood or farm it or something? I haven't found anything yet and I think my factory will definitely use wood faster than I can chop it down the road.

Re: Wood

Posted: Sat Jan 02, 2016 8:23 am
by Supercheese
You can make synthetic wood from heavy oil once you get to oil processing techs.

Re: Wood

Posted: Sun Jan 03, 2016 4:01 am
by bobingabout
I'm out of tune with my own mod, it's been so long >.<

Anyway, yes, you can make synthetic wood from heavy oil. I think it comes under Plastics research.

Re: Wood

Posted: Sun Jan 03, 2016 5:11 am
by Buggi
I updated Treefarm Lite to work with 12.20.

You can find it here:
https://forums.factorio.com/forum/viewtop ... 20&t=18870

Re: Wood

Posted: Sat Jan 16, 2016 11:26 pm
by SpeedDaemon
I also wrote a very simple greenhouse mod to produce wood.

It's not as pretty as Tree Farm, but far less laggy if you're going big.

Re: Wood

Posted: Mon Jan 18, 2016 2:58 pm
by bobingabout
SpeedDaemon wrote:I also wrote a very simple greenhouse mod to produce wood.

It's not as pretty as Tree Farm, but far less laggy if you're going big.
I think I was going to take a similar approach for wood manufacture in my mod. well, actually I had a couple of options, for example crafting seedlings from wood, then wood from seedlings with a net gain, but the end result is wood from nothing.

Re: Wood

Posted: Mon Jan 18, 2016 3:37 pm
by roy7
Buggi is researching ways to speed Treefarm up, note if you make lots of them it will lag your game. Greenhouse works like a normal factory and so has no major performance concerns.

Re: Wood

Posted: Thu Jan 21, 2016 6:06 am
by Buggi
Yeah, I really dug through the treefarm code and there is very little that can be done to optimize the backend.

The fact it has to scan the farm to check for trees that need to grow, plant seeds, or harvest is kind of intensive.

Currently it has a 60 tick delay on any sort of processing it does. The number of treefarms your game can support before experiencing lag is solely dependent on your computer. I could increase the delay.

The last game I played had 35 treefarms and was doing pretty well, but I have 32 gigs of ram and a beefy processor.

Also keep in mind the trees from treefarm once harvested give 5 wood instead of the vanilla 4 and they grow pretty fast.

Re: Wood

Posted: Thu Jan 21, 2016 6:27 am
by Koub
Hi,

I know absolutely nothing to LUA, mods, and stuff, but I might have an idea for a lighter aglorithm CPU-wise.

Every time something happens to a farm (tree growth, seed plant, dunno ...) the farm could calculate when will be next event for that particular item that had an event in a sorted table of all future events. Like that, every tick, you wouldn't have to cycle through all the farms and all the farm items, but just check "I'm at that tick into the game, what are the events my treefarm mod has to process this tick" ? Then every time each is processed, it can calculate easily when will be the next event for that ressource, and add it to the aforementionned sorted table.

No more scanning, should avoid a lot of work. Would this help ?

Re: Wood

Posted: Sat Jan 23, 2016 8:12 pm
by SpeedDaemon
bobingabout wrote:
SpeedDaemon wrote:I also wrote a very simple greenhouse mod to produce wood.

It's not as pretty as Tree Farm, but far less laggy if you're going big.
I think I was going to take a similar approach for wood manufacture in my mod. well, actually I had a couple of options, for example crafting seedlings from wood, then wood from seedlings with a net gain, but the end result is wood from nothing.
Well, not exactly nothing. The greenhouses don't take modules, and they run at 100kW 100% of the time. On my current map, they are tied for #1 power hog with roboports. :)

To add to Koub's idea for Tree Farm, perhaps it would be possible to trade increased memory usage for increased performance. If each plot (where an individual tree would grow), added its next scheduled/timestamped action to the end of a queue, you would only ever have to check the head of the queue, process those items that are past due, and add another item to the back of the queue. That would avoid any iteration whatsoever. At worst, if each farm had its own queue, you'd only have to look once at each farm.

Re: Wood

Posted: Mon Jan 25, 2016 12:36 pm
by Buggi
The queue idea I've thought of. Unfortunately some things take much less time than others, so adding to the bottom of a queue wouldn't really work.

Take harvesting for example. Once the tree growth event is triggered on the tree to the max level, that tree can be immediately harvested. Even though there might be 48 other trees with tick delays. So adding to the bottom would delay the harvest. Then once harvested, a new seed could be planted right away (maybe, depending on collision).

At best you'd have to check the entire queue for any past-due events. Worse would be a resort method every time the queue is modified.

I'll look into it some more.

Re: Wood

Posted: Sun Mar 06, 2016 9:55 pm
by jonathanpaulson
Buggi: You can use a priority queue for this, which can find the next (i.e. lowest-time event for you). I don't know Lua, but it should be easy to find an implementation online (or in the Lua libraries), for example https://rosettacode.org/wiki/Priority_queue#Lua

Then your main loop can look something like:

Code: Select all

Q = PriorityQueue()
on_tick():
  while not Q.empty():
    (time, event) = Q.pop()
    if time < now(): # in the past
      # do event
      # push new events at their appropriate times
    else:
      Q.insert((time, event)) # oops, this isn't ready yet
      break
This should be fast because you only need to look at the events that are actually ready.