I noticed this (the original code, and your implementation) seems to only describe the "state of feelings" for a simulant and how they generally only get worse over time. I'm now keen to see the code that then provides direction and action for the sim based on this state; e.g. "I'm feeling hungry, I should eat, what should I eat?" and the process that determines what it should eat - and how to go about it. I know The Sims employed more than just A*-towards-nearest-unoccupied-food-source, but what makes a Sim choose hamburgers from the outdoor grill over making dinner in the kitchen?
Something about this program reminds me of the text-mode BASIC games that used to be published in books and magazines in the 1980s.
I remember typing the programs and simultaneously trying to imagine how the simple logic I was entering might build up to something awesome that could be lurking there, just out of my sight between the numbered lines. Most of the time it was a disappointment, but a few of those games did manage to elevate themselves to some kind of unexpected, exciting life that I couldn't have known from just reading the program.
(Of course my standard for excitement was very low.)
You have a point. In a certain light, The Sims is a more complex version of Conway's Game of Life, with its simple life-or-death rules for the cells in the game.
I had a revelation while playing the Sims, and this code lays it bare. I found I was spending more time managing these values for my Sim than I was for myself. I have not enjoyed most single player games since.
It enables the coder to engage in some late binding without engaging in a lot of casts or more elaborate metaprogramming: the enum index used for assignment is itself an assignable value and therefore can be passed around and manipulated if the algorithm needs it. It's a very intentional tradeoff of structure and long-term clarity for a faster turnaround to make design changes.
I haven't even checked to see if the final program uses it. It's the kind of thing, though, that you might go in thinking, "maybe I will need that", and it doesn't add too much overhead to your prototype.
You can have functions iterate through the array. You may want have special functions for each indexed item, but if there is something you want to do for all of them -- say save or load, you can iterate through the list.
It gives a consistent layout in memory, meaning you can save/load very simply. Using a struct puts you at the mercy of the compiler's struct packing and alignment settings.
The other stuff is more stylistic but I'd guess he writes a lot of assembly code, and the enum style translates easily to asm.
I would agree with you. Stuff like `changeMotive` could just take a pointer rather then an index and then you wouldn't need it to be an array. More-over, if you still want to be able to do that loop to check for underflow/overflow at the end, you could just `union` it with an array - use the regular member variables throughout the code, and then use array at the end.
But it was written in 97 so personally I'd give him a break. It might be a style he picked-up from coding on some earlier projects where it made sense (Say, for speed, or because the compiler was garbage).
Is there a bug in the line computing Motive[mHappyWeek]? It seems like it should have Motive[mHappyDay] instead of Motive[mHappyNow] on the right hand side.
That code is just a prototype, the seed around which the rest of the game nucleated. There is a big thick layer of behavior trees, hierarchal state machines and lots of whatever layered on top, including a visual behavior tree programming language called "SimAntics" and an editing tool called "Edith", which is described and demonstrated here (starting at 11:20):
Here's another demo of some tools for making and managing user created content for The Sims, and SimSlices's amazing version of SimCity embedded in The Sims!
Could be one of the few lines of source code survived, as an small office fire in 2001 caused troubles.
Basically the predecessor of The Sims was SimTown (also by Maxis). It was a smaller scale SimCity meets The Sims gameplay. https://en.wikipedia.org/wiki/SimTown
Later SimsVille was meant to evolve the gameplay in the same direction again, though it go canceled (source code lost due office fire). https://en.wikipedia.org/wiki/SimsVille
Almost all the [Maxis] games development data was lost during a small office server room fire [in 2001], that resulted in most of the game being developed again from scratch, according to this source: https://www.unseen64.net/tag/maxis/
This code was not made for bug fixing though, it’s just a prototype - the expression of an idea. The accompanying text even says as much - of course the final game couldn’t possibly have a single sim’s mood in a global variable.
[+] [-] blixt|8 years ago|reply
https://codepen.io/blixt/pen/ayyjpZ
[+] [-] DaiPlusPlus|8 years ago|reply
[+] [-] DonHopkins|8 years ago|reply
http://donhopkins.com/home/TheSims
http://donhopkins.com/home/TheSimsDesignDocuments
[+] [-] pavlov|8 years ago|reply
I remember typing the programs and simultaneously trying to imagine how the simple logic I was entering might build up to something awesome that could be lurking there, just out of my sight between the numbered lines. Most of the time it was a disappointment, but a few of those games did manage to elevate themselves to some kind of unexpected, exciting life that I couldn't have known from just reading the program.
(Of course my standard for excitement was very low.)
[+] [-] yawaramin|8 years ago|reply
[+] [-] asciimo|8 years ago|reply
[+] [-] seanp2k2|8 years ago|reply
[+] [-] wolco|8 years ago|reply
[+] [-] pavel_lishin|8 years ago|reply
What does that mean?
[+] [-] fastball|8 years ago|reply
[+] [-] ENTP|8 years ago|reply
[+] [-] trynewideas|8 years ago|reply
[+] [-] bluejekyll|8 years ago|reply
I can't think of a reason. Having to index by enum seems like it could be error prone.
Also, in the init(), instead of looping over all indexes of the array and setting 0, couldn't a memset be used?
[+] [-] buzzybee|8 years ago|reply
I haven't even checked to see if the final program uses it. It's the kind of thing, though, that you might go in thinking, "maybe I will need that", and it doesn't add too much overhead to your prototype.
[+] [-] georgeecollins|8 years ago|reply
You can have functions iterate through the array. You may want have special functions for each indexed item, but if there is something you want to do for all of them -- say save or load, you can iterate through the list.
[+] [-] taneq|8 years ago|reply
The other stuff is more stylistic but I'd guess he writes a lot of assembly code, and the enum style translates easily to asm.
[+] [-] DSMan195276|8 years ago|reply
But it was written in 97 so personally I'd give him a break. It might be a style he picked-up from coding on some earlier projects where it made sense (Say, for speed, or because the compiler was garbage).
[+] [-] abecedarius|8 years ago|reply
[+] [-] mjbellantoni|8 years ago|reply
[+] [-] Dowwie|8 years ago|reply
[+] [-] DonHopkins|8 years ago|reply
https://www.youtube.com/watch?v=-exdu4ETscs
Here's another demo of some tools for making and managing user created content for The Sims, and SimSlices's amazing version of SimCity embedded in The Sims!
https://www.youtube.com/watch?v=Imu1v3GecB8
[+] [-] rburhum|8 years ago|reply
[+] [-] frik|8 years ago|reply
Basically the predecessor of The Sims was SimTown (also by Maxis). It was a smaller scale SimCity meets The Sims gameplay. https://en.wikipedia.org/wiki/SimTown
Later SimsVille was meant to evolve the gameplay in the same direction again, though it go canceled (source code lost due office fire). https://en.wikipedia.org/wiki/SimsVille
Almost all the [Maxis] games development data was lost during a small office server room fire [in 2001], that resulted in most of the game being developed again from scratch, according to this source: https://www.unseen64.net/tag/maxis/
[+] [-] frik|8 years ago|reply
[+] [-] brian-armstrong|8 years ago|reply
[+] [-] blixt|8 years ago|reply