nicholas-ochoa / OpenSC2K

OpenSC2K - An Open Source remake of Sim City 2000 by Maxis
GNU General Public License v3.0
4.97k stars 86 forks source link

How do we plan on implementing simulation? #6

Closed cursorial closed 4 years ago

cursorial commented 6 years ago

Are we going to write approximate simulations where we observe the behaviour of the original game and attempt to emulate that, or are we going to try to use the same algorithms - if so, where are we going to get these from? Am I barking up the wrong tree completely?

kyr0 commented 6 years ago

Well, here is the "original" source code, SimCity classic, including the Simulation code in simulate.cpp.

https://github.com/SimHacker/micropolis/blob/master/MicropolisCore/src/MicropolisEngine/src/simulate.cpp

kyr0 commented 6 years ago

This might also be of some interest:

https://github.com/SimHacker/micropolis/blob/wiki/InsideTheSimulator.md

SimHacker commented 6 years ago

You'll find some excellent analysis of the SimCity ("Classic") code and algorithms in Chaim Gingold's PhD Thesis on Play Design:

Abstract: https://pqdtopen.proquest.com/doc/1806122688.html?FMT=ABS

PDF viewer: https://pqdtopen.proquest.com/doc/1806122688.html?FMT=AI

(To download the 148 MB PDF file, point at the page in the pdf viewer and a toolbar will appear at the top with a download icon.)

Excerpt about open sourcing SimCity: https://tinyurl.com/DonHopkinsSimCity

cursorial commented 6 years ago

Nice, thanks for those resources, they'll definitely be helpful, could be worth creating some documentation that contains a collection of resources that help with implementation.

SimHacker commented 6 years ago

The section titled "The Simulation Assemblage" starting on page 310 is probably where you want to start reading, since it has all the diagrams and analysis of how the SimCity algorithm works. But check out the rest of the paper -- there's some amazing stuff in there, including lots of background, theory, interviews and history!

nicholas-ochoa commented 6 years ago

Looks like someone ported Micropolis to JS which should help things quite a bit.

cursorial commented 6 years ago

Yep, got some good stuff to get us going here.

On Mar 1, 2018 2:45 PM, "Nicholas Ochoa" notifications@github.com wrote:

Looks like someone ported Micropolis https://github.com/graememcc/micropolisJS to JS which should help things quite a bit.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rage8885/OpenSC2K/issues/6#issuecomment-369613977, or mute the thread https://github.com/notifications/unsubscribe-auth/ACKQrrKrA96y7sylxzdB_ch8acuTkE0qks5taAmcgaJpZM4R52N7 .

dfloer commented 6 years ago

Hi, I'm the Dale Floer mentioned in the readme. I've been slowly working on reverse engineering the simulation, mostly from a "playing the game and seeing what happens" perspective. Right now my notes are pretty unorganized, but I'd love to put them together somewhere nice and public.

SC2k appears to behave significantly differently from Simcity (Classic) in most of the simulation, being an almost complete rewrite.

brylie commented 6 years ago

Does SC2K still rely on cellular automata for things like power, etc.?

dfloer commented 5 years ago

Power seems to be based off a simple connectivity check. A power plant is a source and each tile sinks a certain amount of power.

It could be that it's using cellular automata, just with a simple rule of if you have any neighbours that are "alive" (powered) you are as well, at least until the number of powered tiles equals the number of tiles a power plant can put it.

One thing I did learn while investigating things is that the MW rating that a power plant has isn't the same as how much power it actually puts out.

no-identd commented 5 years ago

Note:

@chaimgingold has Github.

Also, @dfloer I think one thing you'll want to take a look at more closely consists of how industry tax works, see especially pages 38 to 39 of the manual (PDF pages 42 to 43) and page 93 (PDF page 97):

https://classicreload.com/sites/default/files/sim-city-2000-manual.pdf

In my experience, the per-sub-industry tax setting feature is something even the vast majority of game FAQ writers and professional game reviewers covering SC2K overlooked (albeit it's mentioned in the manual!) back in the day.

You might also want to check some of the books @patcoston mentions here, albeit I have no idea how much detail on the simulation behavior it contains, but at least :

http://patcoston.com/co/books.aspx

The oivaizmir cheat for opening the debug window should also help.

dfloer commented 5 years ago

@no-identd: I haven't looked too closely at large parts of the simulation, including how industry tax rates effect the simulation, though I do plan on fully reverse engineering the simulation parts of the game. Primarily my focus has been on reverse engineering the various file specs, as there aren't any complete and public specs. One thing I have noticed is that the manual and PPP (Power, Politics & Planning) are not always correct about the internal simulation of the game.

I'll explain on what this looks like: A power plant has a rating in MW, but this doesn't directly relate to how much power it actually provides, even when the manuals say that it does. It gives a general idea, but the power plants actually power a certain number of tiles, and each tile uses the exact same amount of power (including power plants, which both produce and use power).

Another detail I haven't really seen mention of is that the simulation (for most building, the special buildings don't seem to behave this way) is that the building use the leftmost tile for the simulation. This is why when you rotate the map the land-value, crime, etc. changes and why buildings can even become abandoned because that corner can become >3 tiles away from transportation.

So while the manuals are a good starting place for the game, they don't necessarily reflect the actual state of the released game and it requires a lot of tedious reverse engineering. PPP does a good job at trying to understand how the simulation works, but details are light in many places.

I've pushed my barebones start at a simulation spec to my documentation repo: https://github.com/dfloer/SC2k-docs/blob/master/simulation%20spec.md

priscilla is the cheat you're looking for to get to the debug menu on the game in the Win95 Special Edition version.

chaimgingold commented 5 years ago

@dfloer excited about this project.

Yeah, that's one of the things I found in my close reading of the original SC simulation code, is that there are a lot of shortcuts/bugs—and what's a bug?—where things don't quite work as you would expect. Even Will Wright didn't realize that some of the sim code in the original SC doesn't quite do what it seems to do, like with transit connectivity, when I talked with him about it. So there's an interesting philosophical question here about how to approach things like that. Are you trying to simulate the original simulation, or remake it?

dfloer commented 5 years ago

@chaimgingold: I can't say what @rage8885's intention is, but when I started the reverse engineering project, I started with the intention to make an Open Source re-implementation of the Win95SE version of the game. I was planning on a "compatability" mode that was as good a recreation as the original as possible (though I hadn't intended on making the UI look exactly the same, it doesn't work well on a high-res/high-dpi screen, for example). Additionally, I want an "extended" mode that fixes some of the more annoying bugs and oversights and adds extra features, such as much larger city maps,

nicholas-ochoa commented 5 years ago

@chaimgingold Long term I'd like to do something along the lines of what @dfloer is proposing. Reimplement the original simulation as closely as possible. But I'd also like to support larger map sizes and other features that don't exist in the original game. It's a few years away from either goal, but that's the intention at least.