Energy production

Started by stewbasic, April 28, 2014, 10:26:19 PM

Previous topic - Next topic

stewbasic

I've been assuming that a collector produces more energy when it has enough space, and a reactor produces more when there isn't space. I've been laying my bases out in a nice neat pattern like this:

Spoiler
[close]

It turns out the wiki has this information (http://knucklecracker.com/wiki/doku.php?id=cw3:unit_data_overview), and it's not true at all! Even a collector with full collection field and no overlap is only worth half a reactor. So to get the most energy per area (and ignoring the build cost - which makes sense if you expect the game to last at least ~4 more minutes) it's better to just build reactors only. Or rather as few collectors as possible while still connecting things. Something like this:

Spoiler
[close]

This has 1 collector per 29 reactors, and gives 0.0437 energy/s/cell instead of 0.0413 energy/s/cell for the neat pattern. OK, it's only 6% more, but I think I'm gonna start building my bases differently...

(btw if anyone can get more reactors per collector and still connect everything, please show how).

Asbestos

Yeah, but not having every single space covered with soylent sets off my pseudo-OCD.

12345ieee

#2
I sure do love an optimization problem just before bed :D.

Starting with your pattern I made mine, it's quite similar and still gets 29:1 ratio.
(I also discovered Relays are useless for this, but you surely already knew).

Spoiler
[close]

I also believe that this is the best ratio attainable (with a regular pattern and infinite space):

[math heavy rambling, not in my mother tounge, you have been warned]

Seeing how the problem is stated this is the same problem of tiling the plane with circles, with no overlap and with the highest possible density, with the collectors' connecting area as the circles (in fact if you overlap the connecting areas you lose possible connections with other reactors and if you don't get the maximum density you'll end with wasted space in the middle).
Moreover we here have the added restrictions of using all the space availlable (to get the most energy out -> we will need to overlap the circles) and that the space must be used in subunits 3x3.

The solution to the ideal problem is having the circles arranged in the hexagonal tiling and that should work even with the added restriction, choosing an adequate amount for the circle radius so that every reactor inside it is connected to its collector.
Trial and error says it should be 2.
After some work to make the tiling cover all the space in the map I ended with the layout in the picture.

So, since it is based on the ideal solution I suppose this is the best possible ratio, unless there is a way to use the non puntiform units to connect things a little further, but I doubt this is possible while keeping a regular pattern (I'm surely gonna be disproved in a few minues...)

I'm also very sorry for everyone with a (mild) OCD, but it's impossible to arrange the collectors to make a perfect regular hexagon:
http://en.wikipedia.org/wiki/Pick's_theorem

[/math heavy rambling, not in my mother tounge, I had warned you]

I don't even know why I wrote all this... well, I hope you enjoy the wall of text

EDIT: moving a bit some collectors is even possible to get a nice allineated grid, but at the cost of making the hexagons even uglier:

Spoiler
[close]

stewbasic

Nice, that last layout is much neater. I suspect it's not possible to do better, though I can't see a proof.

12345ieee

#4
After more thinking I found a layout that grants 33:1 (if I'm not mistaken) and is also well aligned, as my second one.
Being this much closer to the upper theoretical limit of 35:1, this time I really think it cannot be improved.

Pics and explaination this evening, since I'm running quite late now.

It's evening, time to waste everyone's time on a wall of text:

meet the "Basic subunit" ("tile" for short):

Spoiler
[close]

Being the green square the collector, these are how many reactors it is possible to connect.
While it's possible to move some rows or coloumns of reactors a subcell up/down or right/left you cannot fit any more reactors in the range of a single collector (plus your layout will look messy, and nobody really want a disorganized reactor farm).

Those things act as the "circles with discretized units" I was talking in the last post, they host 37 units, 1 being a collector, so we get a 36:1 ratio.
Our task now is to tile the plane with such subunits with the least possible overlap.

First of all we get an upper bound to the ratio: it is completely impossible to go over 35:1, because we'll have to overlap at least 2 reactors with 2 other different subunits to be able to connect all our farm together: every 2 overlaps with other subunits we get our ratio reduced by 1, if you are not convinced the pictures below will show why much better than I can explain with words.

Since I think these images are much clearer than CW3 maps at showing tiling patterns I've made some of them to explain better.

Stewbasic's original layout (regularized):

Spoiler
[close]

The red cells are the ones where 2 tiles overlap. In the middle yellow one we can see 6+6+1+1=14 overlapped squares, which reduces the ratio by 14/2=7, so we get 29:1, as Stewbasic stated before.

My first layout:

Spoiler
[close]

Exactly as Stewbasic's this has 6+6+1+1=14 overlaps for every subunit and so gets 29:1 ratio.

Seen all this I went on and tried to make one with less overlap, and got

My second layout:

Spoiler
[close]

It has only 2+2+1+1=6 overlaps per tile, getting it to a 33:1 ratio.
I'm now 99% sure to have got the best possible reactor density.

Now that I drew them I also noticed that all 3 are actually build around the ideal hexagon tiling, differing only in the way in which the tiles are overlapped at the irregular borders, neat thing.

Now it's finally time to see if all this has actually a practical use:
I get a production of 0.0438 energy/s/cell instead of the 0.0437 energy/s/cell the previsious layouts had:
an increment of 6% over the naive layout and a whopping 2‰ over Stewbasics's (TOTALLY worth all this analysis).

And finally, an image of what it looks like in CW3:

Spoiler
[close]

I hope some of you enjoys all this, I really like math and cannot stop myself when I find an intriguing problem.

TL; DR: Look last image. Do that. It is (probably) the best possible.

I was forgetting, the nice site I used to draw the images is http://craftdesignonline.com, never thought I'd find a site for knitting patterns so useful someday...

Wheatmidge

Quote from: 12345ieee on April 30, 2014, 01:45:18 AM
I was forgetting, the nice site I used to draw the images is http://craftdesignonline.com, never thought I'd find a site for knitting patterns so useful someday...

I really appreciate this thread. I love optimization, and I also love practical solutions around things. Using a knitting program site to show the optimization is just great.

Sadly though optimized reactor farms are not useful to build when playing, that can be helpful when creating levels with built bases though.

Asbestos

If you want to have as many reactors as possible with as few collectors as possible, just have a large reactor farm connected by relays. Or maybe even no relays and have tons of reactors just sitting there. It won't really get you much energy, but at least there are none of those vile collectors that are a hair less efficient than our mighty god reactors.

Karsten75

Quote from: Asbestos on May 05, 2014, 07:30:18 PM
If you want to have as many reactors as possible with as few collectors as possible, just have a large reactor farm connected by relays. Or maybe even no relays and have tons of reactors just sitting there. It won't really get you much energy, but at least there are none of those vile collectors that are a hair less efficient than our mighty god reactors.

My signature is response enough.

12345ieee

#8
Quote from: Asbestos on May 05, 2014, 07:30:18 PM
If you want to have as many reactors as possible with as few collectors as possible, just have a large reactor farm connected by relays.

You can easily show that using relays will not improve energy/cell in any way, there are at least 2 different ways to proof this statement...

And now, get ready for another wall of text (and the occasional images).

After studying for the best energy/cell ratio (and seeing that everything I derived is utterly useless for actual gameplay) I moved my attenction to early game, where you are much more concerned with the cost of the unit that produce your energy:

so, I tried to find what to build to get the best energy/spent_packet ratio.

Some numbers from http://knucklecracker.com/wiki/doku.php?id=cw3:unit_data_overview:
Collectors: 0.0018 energy/cell for a max of 109 cells covered -> 0.2 maximum energy -> 0.04 energy/packet
Colectors in standard layout: only 81 squares covered in soylent -> 0.146 energy      -> 0.029 energy/packet
Reactors: 0.4 energy and 10 times the cost of a collector                                      -> 0.008 energy/packet

Of course, like everyone already knew, the best thing to do early game is to build collectors and to get them the more spaced possible to get the most energy out, so, what is the optimal layout to get the best collection?

Assumptions that simplify my life:

1) Regular lattice in an infinite space
2) Every collector must connect strictly more than 2 other collectors (otherwise we'll get a sort of line, which is more efficent in terms of cost, but will be completely useless in real gameplay).
3) We want all the space to be covered in soylent (dropping this also gives interesting results, I'll write them later)

Detalied look into our little friend:

Collector
[close]

This time the little squares represent subcells, from in to out we have:
Collector connecting spot (black)
Collector (yellow+black)
Area covered in soylent (green+yellow+black), that amount to 109 cells
Connecting area (outest "circle"), where the center of another unit must lie to be connected.

Let's start analizing the standard layout (the nice square one, I hope you all understood):

Standard
[close]
Standard
[close]

From the images we see that every collector suffers 7*2*4=56 overlaps, which makes so that every collector harvests from an area of:
109 - (56/2) = 81 cells -> 0.029 energy/packet. We can do better, and we will. After some research I found what I think is the best layout.

Optimized full grid:

Full grid
[close]
Full grid
[close]

Unsurprisingly the best lattice is based on hexagonal tiling, not all collectors are interconnected, but 4 are enough to fully connect every collector in the plane.

The overlap is 8+8+10+10=36, which gets us 109-(36/2)=91 cells -> 0.0328 energy/packet, an increment of over 12%.
Again, everyone already knew that connecting collectors diagonally granted more energy, I just found the exact layout.
Sadly trying to fill the layout with reactors result in really low densities, but this layout may be useful in early game.

If we drop costraint 3, in the case that we don't mind wasting a little space but we need more energy efficiency it's possible to get a little better ratio.
The least possible overlap between two connected collectors is 8 and it's attainable by connecting the two as the central and lower left (or upper right) in the optimized layout.

Connecting collectors exclusively with this kind of link minimizes the overlap and gets better energy/packet, but wastes space in the middle:

4 links optimization:

4 links
[close]
4 links
[close]

The overlap is 8*4=32, which gets us 109-(32/2)=93 cells -> 0.0335 energy/packet, an increment of over 2% over the last layout, but
we leave the orange cells unused: 4*4=16 unused cells -> (16/4)/(109+16/4)=3.5% of the availlable space is wasted (98.5% spatial efficiency over previsious layout).

3 links and 2 links optimizations are exactly the same as the last, achieving:
3 links: 97 cells  -> 0.0349 energy/packet +4%    over 4 links
2 links: 101 cells -> 0.0364 energy/packet +8.6% over 4 links

These last two waste immense amount of space and are not even worth considering for actual gameplay.

Finally, images of how all this looks like in CW3:

Standard
[close]
Full grid
[close]
4 links
[close]

I'm sorry again for the towering wall of text, but if you've made it so far thank you for reading, I hope it have been a good and useful read.
Please let me know if any of this is incorrect or there are better solutions, it's pretty late here and I may had overlooked something.
Further comments/thoughts on all this would be greatly appreciated, I am quite interested in the whole topic.

Goodnight

MagneticDuck

Hm, seems that CW is a great place for math. This hasn't ended here >:D
main=(liftM2(>>)putStr print)"main=(liftM2(>>)putStr print)"

Write the following string, and then write it again in quotes: "Write the following string, and then write it again in quotes:"

arandomhalo

CW is where pure math collides with practical application.  Sometimes when your children give the old "When am I ever going to use this math stuff?", it's tempting to use video games as an example.  Usually I lead them to answer their own question.  "Well, sweety what do you want to be when you grow up?"  The answer will be something along the lines of astronaut, doctor, or whatever daddy does.  "Well, they use math every single day so you'd better learn it.  But hey if you want a job that doesn't use math, you'll qualify for guy who empties the garbage or guy that removes fiberglass insulation" (not that there's anything wrong with those jobs, just that they're never a child's first choice).

Sorry for the topic hijacking.  More on topic, sometimes math is good to learn simply because it's fun.  Looking forward to what you come up with MagneticDuck.

Cavemaniac

Quote from: arandomhalo on September 03, 2014, 01:17:24 PM
CW is where pure math collides with practical application.  Sometimes when your children give the old "When am I ever going to use this math stuff?", it's tempting to use video games as an example.  Usually I lead them to answer their own question.  "Well, sweety what do you want to be when you grow up?"  The answer will be something along the lines of astronaut, doctor, or whatever daddy does.  "Well, they use math every single day so you'd better learn it.  But hey if you want a job that doesn't use math, you'll qualify for guy who empties the garbage or guy that removes fiberglass insulation" (not that there's anything wrong with those jobs, just that they're never a child's first choice).

Sorry for the topic hijacking.  More on topic, sometimes math is good to learn simply because it's fun.  Looking forward to what you come up with MagneticDuck.

Again, sorry about the thread hijack.

I got a computer the year I left school - and promptly discovered that programming was 90% maths!

From an OCCUPATIONAL point of view, I hated maths in school, the only form I enjoyed was geometry.

...and I was interested to note that so far, two of my jobs have involved geometry!

Moving furniture - packing trucks and getting three dimensional objects through doors and around corners.

Rucksack fitting in a camping store - everyone's body geometry is different!

Be yourself. Everyone else is already taken.