URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Zerg Hex Forum
  HTML https://zerghex.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Builds & Guides
       *****************************************************
       #Post#: 2260--------------------------------------------------
       Zerg Economy Simulator
       By: guguizg Date: September 28, 2021, 2:27 pm
       ---------------------------------------------------------
       So while i think of a way to improve the terran simulator, I'm
       also working on the zerg simulator. This version i present is
       already functional, but it's lacking a lot of features. I'll
       keep updating it and posting the new versions with also somme
       conclusions i get from it. The first one i posted on the other
       channel "hex science" proving that the zerg eco isn't actually
       exponential. It's not user friendly, but if any of you want to
       use it on this stage i can explain personally how it works, just
       message me. Also, feedback can be very valuable if any of you
       feel like trying it. I kind of gave up on Excel's VBA and I
       started coding on Python, which probably makes more sense.
       #Post#: 2264--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: October 8, 2021, 11:45 am
       ---------------------------------------------------------
       Hey guys, I've been working on the simulator, and after doing
       some thinking and talking to Turbo - thank you turbo :>; I
       decided to remake my code and improve on it. The problem I'm
       facing is that following the ratio will not necessarely give you
       the best income. Let me explain why. A perfect ratio build does
       not consider that spawner costs way more than extractors (30
       supply of extractors costs 440, while 30 supply of spawners
       costs 525) and take longer to build, so even tough a perfect
       ratio build would acomplish the best combination of spawner to
       extractor reguardless of time, when you factor time, it might be
       "too slow" and take longer to complete a full supply - which
       negatively affects eco. I admit that the difference is very
       small, but I have to be sure of it.
       The way I think I can fix it is by simulating every single
       option and then pick the best one, because figuring it out
       mathematically doesn't seem viable, as there are too many
       endogenous variables (i was struggling with 3 imagine 4 or 5
       lol). A new problem comes up then, because which one is the best
       option? If i pick the fastest one in a given time, I wouldn't
       factor how much supply left there is and how far away the player
       is from buying the next supply, and if I pick the biggest income
       when they all finish the supply, I don't factor which one
       finishes first - which is important. I might need to go into
       neural networks or something like that. I'll keep u guys updated
       on progress.
       Meanwhile let me share something really cool I stumbled uppon:
  HTML https://imgur.com/7pgittk
       This is a heatmap for the income given your use of the starting
       54 supply. The lighter the color is, more income u get. The x
       axis is the number of extractors you build and the y axis is the
       number of slowling spawners. The reason why the bottom right
       corner is empty is that it surpasses the 54 supply limit.
  HTML https://imgur.com/MtMRuGP
       This one is the same thing, but for strikelings.
       It's beautiful. Bye :>
       #Post#: 2265--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: October 8, 2021, 9:41 pm
       ---------------------------------------------------------
       I think i might know how to fix it. I'll document my thoughs as
       I do it.
       So what I'm thinking, is to simulate getting 0, 1, 2 and 3
       extractors and fill the rest with spawners on each supply. So
       the first supply - not considering the initial 54 - will be:
       ([0,11],[1,7],[2,3],[3,0])
       , the first number being the number of extractors and the second
       the number of spawners. The resulted income will be:
       (780,793,798,810)
       That means that the 3 extractor increases the income more than
       the others. This doesn't mean it is necessarely the best, as
       adressed on the last post because I'm not considering time.
       Then, I'll repeat the same process for the next supply,
       considering the supply "leftovers". But this time the number of
       spawners and extractors are not going to be 24 and 12, it will
       be [12,24] + [extractors on last supply, spawners on last
       supply] for each combination. This means that the number of
       simulations is 4^number of supply, beacuse I have to simulate
       every path possible. This is quite similar to a neural network.
       After running all the simulations, I will analyse the results
       and come back to you.
       To be continued (08/october)
       #Post#: 2275--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: October 30, 2021, 4:33 pm
       ---------------------------------------------------------
       Simulator Update - a new perspective
       I had an idea. Instead of doing it the trial and error method
       (which is the one I was talking about on the last post), what if
       I tried to teach my simulator some economy? Well, probably it
       would be better if I myself knew more economy, but I've
       applied some economy concepts on the simulator and it actually
       performed better in some circunstances. Problem is, its not
       better in any situation.
       These are the concepts i included in my code:
       1. Marginal increase
       Marginal increase is how much the eco will increase if you added
       1 more of something. So the marginal increase for a spawner is
       basically
       (spawners +1) * extractors - spawners * extractors
       This is important when comparing the impact of making a new eco
       structure, as it analyses the change of that unique structure
       you built.
       2. Cost of Oportunity
       Cost of oportunity is a pretty cool economy concept. The cost of
       oportunity for any action is the second best action. So
       basically, the cost of oportunity of making a spawner is making
       a extractor. If the spawner has a different building time
       compared to the extractor, when you build the spawner, it's
       cost of oportunity would be the time that the extractor would be
       up and running and generating minerals while the spawner is
       still building.
       3. True cost
       A slowling spawner costs 50 minerals. But that isn't
       actually it's true cost, as it also consumes other
       resources, like supply, drones and oportunity. The equation i
       did for the true cost for both the spawners and extractors was
       the following:
       Spawner True Cost = Spawner Mineral Cost + Drone Cost + (
       Spawner Supply Cost / 45) * Cost of the 45 supply+ Spawner Cost
       of Oportunity
       4. Return of investment
       The return of investment is basically what a investment gives
       divided by what it costs. In our case, we have those variables,
       which are the marginal increase / true cost.
       Conclusion:
       After implementing those, performance really improved, specially
       on the early and midgame. It's also very good at adapting to
       other spawners like the strikelings. The problem is that it is
       really terrible at the lategame and I still don't really
       know why. From what i've observed it seem to be building way
       more spawners than it should and it's not following "the
       ratio". That problem might be because all the concepts i
       introduced are linear aproximations, and on the lategame that
       doesn't work. Let me explain.
       Linear aproximation:
       When you have a function that is not linear (in this case the
       income funcion) you can aproximate the future values with a
       line. In the short term it works, because the values are very
       close, but the longer it goes, the worse the aproximation gets:
  HTML https://imgur.com/dB0t0TK
       In my program, when i calculate the cost of oportunity, I
       consider that nothing else will change, which is a linear
       aproximation for my income function and on the lategame eco can
       change a lot from one second to the other. For the late game I
       might have to make the cost of oportunity calculations more
       complex.
       Next steps:
       I'll try to fix the lategame issue and run tests comparing
       my algorithm to human made builds by the hex pros to figure out
       if it can come out with the best eco possible or experienced
       players know a even better build order.
       I'll attatch the new verson of the python script. This time
       in a .txt format because some of you cof cof Turbo complained
       that .rar is aparently "too old". Also if you are a noob in
       python, so am I lol. I use very simple and organized commands
       and explained the entire code basically after I tried to talk
       with Turbo about my code and it was too confusing to be
       understood by anyone else and even for me to understand 1 month
       after i did it lol
       #Post#: 2278--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: November 4, 2021, 9:00 am
       ---------------------------------------------------------
       Let's speak numbers.
       Last post i said the new algorithm performs better in some
       situations. Let me show you graphics for income per time so you
       can see the difference yourselfs.
       Slowlings on early game old (orange) vs new(green)
  HTML https://imgur.com/Ykf48rY
       Strikelings on early game old(orange) vs new(green)
  HTML https://imgur.com/g0CMSVn
       Tanklings on early game old(orange) vs new(green)
  HTML https://imgur.com/rTt9aWG
       Roaches on ealy game old(orange) vs new(green)
  HTML https://imgur.com/GxRKspI
       Results show that the new method seems to have the upper hand in
       some of the spawners on the early game, specially the
       strikeling.
       Slowlings on end game old (orange) vs new(green)
  HTML https://imgur.com/hFVNJ2M
       Strikelings on end game old(orange) vs new(green)
  HTML https://imgur.com/8ARAG17
       Tanklings on end game old(orange) vs new(green)
  HTML https://imgur.com/ANTWrel
       Roaches on end game old(orange) vs new(green)
  HTML https://imgur.com/GxRKspI
       End game is really terrible on the new algorithm, as discussed
       in the last post, but aparently for roaches and tanklings it
       isn't that bad. Probably because as those spawners are "slower"
       to eco up with, so the difference takes longer to show up. I'm
       still working on it, I'll keep updating.
       #Post#: 2279--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: November 4, 2021, 10:35 am
       ---------------------------------------------------------
       Income time adjustment
       How fast does the zerg economy grow? This is a important
       question, because spending 100 minerals at the start of the game
       is worth way more than spending 100 minerals in the end of the
       game. A simple formula to know how fast the economy grows is:
       (Income today - Income yesterday)/ Income Yesterday
       That will give us in % how much it has grown.
       So in my code i did that, but instead of yesterday's income, i
       used the income growth for a spawner buiding time. That's
       because spawners have different building time compared to
       extractors, meaning that in theory spawners should be more
       expensive, as it takes longer for them to start yielding. So
       this is the graphic result:
  HTML https://imgur.com/vQXzCcg
       Turns out that the economy grows a lot in a building time of 1
       spawner. The results show that in 25 seconds (the building time
       of a slowling) the economy can grow 14%!
       Then i repeated the process for the building time of a extractor
       and also added a moving average to make visualization easier:
  HTML https://imgur.com/fX4c5jd
       The red line represents the moving average for eco growth of 1
       extractor building time (20 seconds) and the green is for a
       slowling (25 seconds)
  HTML https://imgur.com/Whh3G1s
       Now this is from a roach spawner instead of a zergling. As you
       can see, the difference grows because it takes 40 seconds for a
       roach spawner to build.
       I'm not sure what happens for the curve to start decreasing,
       I'll investigate in the near future.
       Then I multiplied the spawner true cost by 1 + growth, meaning
       that the spawners will start costing more than extractors and
       depending on the spawner, the difference should be huge, right?
       Well, that's what i expected. Turns out nothing changed.
       I really dont understand what happened, I expected some kind of
       difference, but practically no effect was caused:
  HTML https://imgur.com/vwFY7YF
       (yes these are 2 different lines)
  HTML https://imgur.com/bTLgJZa
       (zoomed version)
       I'm extremely confused at this point. I'll need to revisit some
       concepts. If anyone has any idea of what happened feel free to
       contact me. I guess that's it for today... Cya
       #Post#: 2326--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: June 16, 2022, 9:42 am
       ---------------------------------------------------------
       I'm back.
       I think i know why the simulator's eco growth just plummets
       after a few minutes, leading to way slower eco groth. My
       suspicion is that it's because of the tickspeed of the
       simulation: 1 update/second. I assume as time goes on, a lot of
       things can happen in between a second and the next, meaning that
       it has to update more than once every second.
       I started working on a new and improved version of the
       simulator, using more advanced techniques i've learned in the
       last few monts. I'll keep you updated :D
       #Post#: 2327--------------------------------------------------
       Re: Zerg Economy Simulator
       By: guguizg Date: June 24, 2022, 11:38 am
       ---------------------------------------------------------
       The new code is done. It seems to be working perfectly and came
       up with a similar enough build to Turbo's with reasonable
       results if tested in game. If any of you want to use it by
       yourselfs, it's in python and it's commented so I assume it's
       not that hard to operate if you know python.
       As it already is, it can be used to test different eco settings,
       such as what happens to the economy if you change the supply
       cost. I will improve on it and make it do smarter choices (i
       hope), as it currently is Heuristic.
       Future goals:
       - implement duo zerg economy (so we can finally determine how
       much sharing eco matters)
       - calculate a few statistics to extract a few insights, such as
       moving average growth
       - use previous statistics to come up with a better choosing
       algorithm
       -alternatively use a solver algorithm that tests every
       single possibility and gives out the best one
       - automate or simplify the graph making
       - enable a build input and analyser
       - start considering army expenses and not only pure economy
       If you want to try it and have any questions, feel free to msg
       me.
       *****************************************************