[HN Gopher] Building an economy simulator from scratch ___________________________________________________________________ Building an economy simulator from scratch Author : Ruddle Score : 136 points Date : 2023-09-15 19:06 UTC (3 hours ago) (HTM) web link (thomassimon.dev) (TXT) w3m dump (thomassimon.dev) | SpaceManNabs wrote: | This website is really cool (not just the post). Thomas must have | put a decent amount of work. How to find the secrets? | orangepurple wrote: | Great start! Some things to consider for future versions: more | sophisticated tax code, financial regulations, monopsonies, | monopolies, collusion, corruption, oligarchies, demand | elasticity, cascading effects from supply chain disruptions, | central bank quantitative easing. | econorew wrote: | All of this is emergent behaviour. Agents need to be smarter | and the networks need to be larger and information needs to | have a cost. | nylonstrung wrote: | A lot of this is Macroeconomics- Microeconomics (what this | focused on) is effectively a different discipline. You can't | really model both of them within the same framework | | Source: econ major | econperplexed wrote: | OT: I see economists of various ideological tilts constantly | arguing about how macroeconomic variables will respond to | specific government policies. You know: "this new tax will | increase inflation; no it will not, it will increase | unemployment". | | What I don't get is why there are no readily available online | macroeconomic simulators with real world data that make these | sort of predictions. For a lot of countries, up-to-date | macroeconomic and demographic is readily available. | | Surely, economists of every ideological tilt have their own | standard model of macroeconomics [1] which they use to make rough | predictions? If not, how complicated is it really? | | [1] Much like the standard model of particle physics or of | cosmology. Fairly dirty and complicated models with lots of | tunable parameters. | sdfghswe wrote: | > What I don't get is why there are no readily available online | macroeconomic simulators with real world data that make these | sort of predictions. | | Are you high or what? | | The problem is so complex that people don't even agree how to | _take a measurement_ , let alone how to simulate the system. If | nowadays people disagree when looking at the same numbers, | imagine if each one could point to the numbers in his own | simulator. | redandblack wrote: | but but ... you cannot have data get in the way of good theory. | [deleted] | jl6 wrote: | An "economy" is composed of people, so maybe we can do this | once we've cracked simulating people. | amelius wrote: | Because a good model would be like a self-defeating prophecy. | ttymck wrote: | Why do you think economics is as deterministic as particle | physics? Why should a simulation be any more informative than | an economist's assumptions? | KRAKRISMOTT wrote: | Particle physics isn't that deterministic either. It uses a | lot of statistical tricks and hard engineering to reach its | results. That's why there are so many physicists working as | quants. | logicchains wrote: | >[1] Much like the standard model of particle physics or of | cosmology. Fairly dirty and complicated models with lots of | tunable parameters. | | Anyone capable of making models that can predict the future | with a reasonable degree of accuracy is probably in finance, | making 5-10x what they could in economics. The economy is an | incredibly complex system, subject to emergent behaviour and | chaotic effects, much more so than in physics. You'll see | papers from the large hadron collider where they prove stuff to | within p=0.000001; it's impossible to prove anything to that | degree of confidence in economics. Especially because it's not | possible to create true controlled experiments: you can't have | two otherwise identical societies that differ by just one | factor, rather there will always be other ways in which they | differ to, and how these are accounted for can have a big | effect on the output of models. | econperplexed wrote: | Any model has some precision associated with it. I am not | asking for 5 sigma level of precision. But if the economists | are fighting about what will happen to a particular | macroeconomic variable, they are making a prediction even if | it is a log_2(3) bit prediction [1]. There must be some math | that is backing that. I want to see it explicitly put into a | computational model that runs on live data. Otherwise is | there any real content to the arguments that economists are | having? | | > Especially because it's not possible to create true | controlled experiments | | Cosmology has zero-experiments. It is a completely | observational science [2]. And in fact, has very bad data. | Basically a time-frozen snapshot of the universe from a | particular point in space. They can't even make predictions | about the future, only about what some new dataset of that | same time-frozen universe will say. Economics on the other | hand has the benefit of lots data about interventions and | their consequences. There is so much opportunity to develop | models by making predictions and checking what happens. | | [1] variable goes up or down or stays the same. | | [2] The fact that the roots of _modern_ science lie in a | purely observational no-experiment discipline of astronomy is | lost on many. | logicchains wrote: | > But if the economists are fighting about what will happen | to a particular macroeconomic variable, they are making a | prediction even if it is a log_2(3) bit prediction [1]. | There must be some math that is backing that. I want to see | it explicitly put into a computational model that runs on | live data | | This is what (some) people in finance do: make models to | predict things, because if something about the future can | be predicted to a sufficient degree of accuracy, it's | generally possible to make money from it. In economics, the | incentives are slightly different; in academia, the | incentives are to publish interesting/novel/topical papers, | like with other social sciences, not necessarily to make | repeatable predictions. In social science nobody gets | punished for making an interesting model that hasn't been | rigorously proven to make repeatable predictions, while in | finance on average better models make more money and get | rewarded more. But sharing an effective model means other | people can use the predictions too, meaning you capture | less value from the predictions yourself, so people with an | effective model have an incentive not to share it | ch4s3 wrote: | > What I don't get is why there are no readily available online | macroeconomic simulators with real world data that make these | sort of predictions. | | You aren't the first person to have this thought. It just turns | out to be incredibly difficult. | lainga wrote: | Consider examining different utility functions and substitutable | goods | jampekka wrote: | No banks, no capital, no capitalists living off the workers' | labour. This is not even close how the economy works. | [deleted] | random3 wrote: | You know banks exist outside of capitalism, no? | NoMoreNicksLeft wrote: | This is interesting, in that I've tried to come up with simple | simulations like this for strategy games before. But I was a | little "eww" when he kicked the number of government workers up | to 40% of the workforce. Looks like it goes all the way up to | 50%. | | On simulation #13, where tax is fixed at 10%, the government | workers all eventually starve. Surprisingly, the libertarians are | correct because at this point the quality of life index abruptly | rockets up to twice what it used to be. But there's some sort of | robotic overlord AI going on, it still collects the tax. | | But then in simulation #18, things become a little insane. I call | this one the Massachusetts simulation... only 3 workers, but 9 | government employees. For a 3:1 ratio. The simulation suggests | that some sort of economic meltdown occurs and they all starve, | but I suspect that things were a little more violent than that. | | After, the developer then introduces ration tickets. This is | simulation #20, and I'm pretty sure it's Zimbabwe. But it's not | the real world Zimbabwe, it somehow works. That is, if you're ok | printing trillion dollar bills. | | Simulation #21 takes a new direction entirely. FDR has been | elected, and tries to stamp out competition... but he is too | late, evil capitalist farmers have grown too many apples, which | perversely leads to starvation. Careful apple quotas are needed. | The government has disappeared though, probably because late | stage capitalism destroyed it. Only the corporations survive. | | Surprisingly, no farm subsidies yet. I predict the introduction | of a new private sector worker, the ConAgra lobbyist. We'll see | if he shows up in a later simulation. That is, assuming another | government is elected. | | In simulation #25, one of the warlords has settled down and | become a government again. But this is the last of the | simulations. No lobbyists, though the central bank has returned. | This might be because Andrew Jackson has died. I did not like the | man, he will not be missed. But quite clearly the inflation is | through the roof again, and 30% taxes are here to stay. | | What I've learned from these is that history is a lie. Rhodesia | probably never existed, and Zimbabwe happened before the US civil | war. | dclowd9901 wrote: | > After, the developer then introduces ration tickets. This is | simulation #20, and I'm pretty sure it's Zimbabwe. But it's not | the real world Zimbabwe, it somehow works. That is, if you're | ok printing trillion dollar bills. | | In a cashless society, I suspect the zimbabwe method would | actually probably work. The only hangup was "Now I need to | crate around boatloads of money". In a cashless society, we can | just move the decimal point every so often. | marcosdumay wrote: | > at this point the quality of life index abruptly rockets up | | That's because on this simulation the government isn't doing | any useful work. | | The ration tickets work because the people were programed to | actually follow the law. It fails every time on the real world | because real people aren't. | | And the simulation #20 works because the simplistic model | actually works. At a first approximation, inflation isn't a | problem at all. Things only start to fail after you have | competition, corruption, very limited resources, etc. | | Simulation #21 is a great visualization of why people must be | able to set prices with enough freedom, and why forced price- | fixing bankrupts countries. | NoMoreNicksLeft wrote: | > the people were programed to actually follow the law. It | fails every time on the real world because real people | aren't. | | Is anyone working on the problem of programming people? Or | are we just hoping for a solution to that to fall into our | laps? | | > and why forced price-fixing bankrupts countries. | | Ah ha! On this one I paid very close attention. No secret | libertarians hiding in woodpiles, and sneaking out at night | (or any other time) and stealing from the people. The only | rational conclusion is that the simulation was set up to fail | as some sort of propaganda. | | Besides, only a few people died anyway, which for any | socialist country is miraculously impressive success. So | maybe not propaganda. | | I'm beginning to think these simulations don't offer any | insight into the real world at all. | dclowd9901 wrote: | The "useful work" was implied. That is, the assumption was | the government was perfectly valuable to society with | relation to the cost it incurred. It might've been | interesting to see the government throw money at the farmers | every year or so, though. | nologic01 wrote: | Beautifully made and illustrative of a currently non-existing | branch of economic education, if not economic theory itself. | | While people get to be force-fed all sorts of complex subjects at | school, economics does not feature prominently. | | The result of this widespread economic illiteracy is easily seen | at the quality of political discourse. | amelius wrote: | Sounds like something an LLM could help with. You could write | rules in natural language, and the system would automatically | convert it into simple code. | [deleted] | bagpuss wrote: | The MONIAC built in the 1950s by Bill Phillips (of Phillips curve | fame) attempted to model economic processes with coloured water | (fluidic logic) | | https://en.m.wikipedia.org/wiki/MONIAC | 0xADADA wrote: | dont' mistake a beautiful map for the territory, you'll find | yourself lost amongst lines that aren't a real place. | dclowd9901 wrote: | It sounds like you take issue with this simulation? It applies | heavily academic and simplistic rules around behavior. I like | build up of it all to illustrate _simulating things_, but I | think almost any traditional economics theory outside | behavioral economics ought to be shelved for good. | cgio wrote: | I would agree up until recently. I am starting to think, | though, that behavioral is only relevant in an economy of | choice. With choice I keep it simple to having the option to | spend or not wealth (including consuming/selling some of your | stock). The less choice in the market, the more the classical | models will be reasonable and efficient approximations as | they can accommodate one sided choices. Complex dynamics are | not what we experience now. There is a market direction, the | power to impose it and its application at clear sight. | [deleted] | sunday_serif wrote: | On Exactitude in Science By Jorge Luis Borges | | ...In that Empire, the Art of Cartography attained such | Perfection that the map of a single Province occupied the | entirety of a City, and the map of the Empire, the entirety of | a Province. In time, those Unconscionable Maps no longer | satisfied, and the Cartographers Guilds struck a Map of the | Empire whose size was that of the Empire, and which coincided | point for point with it. The following Generations, who were | not so fond of the Study of Cartography as their Forebears had | been, saw that that vast Map was Useless, and not without some | Pitilessness was it, that they delivered it up to the | Inclemencies of Sun and Winters. In the Deserts of the West, | still today, there are Tattered Ruins of that Map, inhabited by | Animals and Beggars; in all the Land there is no other Relic of | the Disciplines of Geography. | | source: https://kwarc.info/teaching/TDM/Borges.pdf | The_Blade wrote: | nice, you beat me to this gem (with a side of Lewis Carroll | and Baudrillard) because I was finishing work | | the lesson is, never try | | edit OH and the other part is that it was staged literary | forgery by "Suarez Miranda, Viajes de varones prudentes, | Libro IV, Cap. XLV, Lerida, 1658." Borges overclocked the | meta | zwieback wrote: | This is so cute, love the animation and idea behind it. | | Just yesterday I listened to Planet Money talk about how Bill | Phillips got a position at the London School of Economics on the | strength of his hydraulic computer simulating the economy: | https://en.wikipedia.org/wiki/MONIAC | Terr_ wrote: | MONIAC was also featured/satirized in the Terry Pratchett book | "Making Money": | | __________________ | | > "Mr. Hubert believes that this... _device_ is a sort of | crystal ball for showing the future, " said Bent, and rolled | his eyes. | | > " _Possible_ futures. Would Mr Lipstick like to see it in | operation? " said Hubert, vibrating with enthusiasm and | eagerness. Only a man with a heart of stone would have said no, | so Moist made a wonderful attempt at indicating that all his | dreams were coming true. | | > "I'd love to," he said, "but what does it actually do?" | | > Too late, he saw the signs. Hubert grasped the lapels of his | jacket, as if addressing a meeting, and swelled with the urge | to communicate, or at least talk at length in the belief that | it was the same thing. | | > "The Glooper, as it is affectionately known, is what I call a | quote analogy machine unquote. It solves problems not by | considering them as a numerical exercise but by actually | duplicating them in a form we can manipulate: in this case, the | flow of money and its effects within our society become water | flowing through a glass matrix--the Glooper. The geometrical | shape of certain vessels, the operation of valves and, although | I say so myself, ingenious tipping buckets and flow-rate | propellers enable the Glooper to simulate quite complex | transactions. We can change the starting conditions, too, to | learn the rules inherent in the system. For example, we can | find out what happens if you halve the labour force in the city | by the adjustment of a few valves, rather than by going out | into the streets and killing people." | | > "A big improvement! Bravo!" said Moist desperately, and | started to clap. | Workaccount2 wrote: | I've long had the fantasy of an economics simulator given dwarf | fortress levels of dedication and attention to detail. This might | not be it, but it does warm my soul a bit. | dragontamer wrote: | Tropico series is simple but fun. | | The bulk of it is obvious Capitalism vs Communism political | jokes though, so I wouldn't consider it a very serious economic | simulator. But its better than most IMO. | michael_j_x wrote: | star citizen with its quantum economic simulator is close | enough: https://www.boredgamer.co.uk/2020/04/24/star-citizens- | quantu... | ilyt wrote: | I had hopes for Victoria 3 but it didn't exactly stick the | landing | andrewmutz wrote: | It's not perfect, but they are investing a lot of time on | improvements. Paradox games tend to get better over time. 1.5 | introduces province-level prices, which make supply chains | more interesting. | Supply5411 wrote: | Simulation 16 is hilarious. By the state dynamically scaling how | much they print money in order to support government workers, | government workers accumulate more wealth than the producers of | goods. | epicureanideal wrote: | Sounds like state workers in California | vanrysss wrote: | See LA lifeguards making $300k/yr https://lamag.com/news/the- | highest-paid-lifeguard-in-l-a-mak... | mapmap wrote: | How does this happen? | lotsofpulp wrote: | Every single government employee and their family/friends | vote in local elections, and other people do not. You | will not win an election without their votes, and you can | use opaque compensation like DB pensions and whatnot to | hide and punt forward the costs of the compensation. | | You will never find a non taxpayer funded entity promise | something like this: | | >After 30 years of service, LA lifeguards can retire as | young as 55 on 79-percent of their pay. | | Go ask an insurance company how much an annuity for even | $80k would cost starting at age 55 until death. It would | be $1M+. | | Social Security averages out your earnings for your whole | lifetime to calculate the benefit, and that is with the | power of the federal government. City and state | governments regularly promise employees final average 1, | 3, 5, and at best 10 pay formulas. So you see | cops/firefighters/lifeguards/etc spiking their overtime | and working 80 hours per week for the last few years, | doubling and tripling their DB pension benefit. | | And you simply will not see this outside of taxpayer | funded entities. | willsmith72 wrote: | so you mean the solution to that would be mandatory | voting? | lotsofpulp wrote: | No, I think it is still too complicated of an issue to | burden voters with understanding. The better solution | would be restricting all employer employee compensation | arrangements to cash only. | | That would solve politicians being able to pay with | unaccounted for benefits that become a burden decades | later, and increase labor price transparency and result | in better functioning markets once employers are out of | the health/vision/dental/public transport/retirement | benefit business. | | And a third bird it kills is reducing the advantage big | businesses have over small businesses. | idontpost wrote: | [dead] | ta1243 wrote: | Those that actually produce goods are very far down the wealth | pecking order | dclowd9901 wrote: | And the social pecking order, it would seem. | [deleted] | Nezteb wrote: | Is the source code for this simulator available anywhere? The | post's code itself is minimized/obfuscated: | https://thomassimon.dev/assets/cashloss.1fca21f6.js | | I couldn't find anything on the author's GitHub. I'm mostly just | curious how it's built. | Ruddle wrote: | Author here, if there is enough interest I can clean the code | up and put it on GitHub. It is basically a state machine. | Nezteb wrote: | I'd appreciate it. :D | jll29 wrote: | Would be nice to see a post written about the high-level | design and then about the implementation. | _false wrote: | Just to add to others; I'd be interested to take a look at | the source, particularly for animations. | coderintherye wrote: | I'd love to see it, even in unpolished state. | | It'd go well as comparison vs. this code I've been playing | around with from Phillip Rosedale (Founder of Second Life) | where he's simulating economy for purposes of determining | wealth distribution scenarios: | https://editor.p5js.org/PhilipRosedale/sketches/odl5elMWy | xwdv wrote: | State machine? Why not entity component system? | keskival wrote: | The simulation only has workers/producers and it has a free | market - it is missing capitalism. To make it realistic you need | a subset of people owning the labor output of others, taking out | all the surplus, using it to buy stakes of more economic | activity, diverting profits to themselves, thus creating the loop | of concentration of wealth which removes the surplus wealth from | the producers and assigns it to ever decreasing number of ever | wealthier individuals. | Supply5411 wrote: | Where are the bad actors who exploit the system to steal from | everyone? No economic simulator is complete without this. | | Edit>> It appears to be the state. | [deleted] ___________________________________________________________________ (page generated 2023-09-15 23:00 UTC)