Open LuRsT opened 4 years ago
Been thinking about how this is going to work, but I think I was just procastinating on making this project a reality, so I started building some models:
I feel like a god:
World
and Time
, I'm unsure if this is going to turn out in a good design, I want to have the classes communicating between them, but I wonder if this is the best way to do this...sandbox.py
to explore this idea :thinking: My big question now is, who will be moving time forward? Should I wait until everyone has completed their tasks? Should I get a clock that waits for 1s and keeps sending that event forward? This is quick enough that I can get a loop of events that will keep the time going forward...
I actually dealt with a similar problem in the past (for a MUD instead of fiction, but the concept's close enough).
The only things that any script could do were update some data, schedule an event, cancel an event it had scheduled, and register a handler for a type of event. The events were added to a collection (a minheap in this case) ordered by the time at which the event should trigger. In my case, since it was a real-time interactive program, I would pop events off the queue until no more were scheduled for before the current tick. But with a non-interactive program, I'd just keep popping events off until some predetermined stopping point.
Thanks for the tip @dhasenan, I think that';s what I'll do, I'll have a main loop that will keep on running until there are no messages left, and then it adds a new one for time passing by :+1:
Not much time today to code, so I wrote a little draft of how survivors will do actions, they will send an event stating their intent, and the world will reply with what happens next. Seems like a good thing :thinking: at least for now...
Again not a lot of time, so I wrote a test for the world providing a survivor with a resource (wood). This is roughly how it will look like, but I'm thinking about how to handle which survivor to provide the resource to, will that be in the message name, or in the data of the message? I'll just keep adding more handlers until I can use the tests to triangulate the code enough to refactor it into something beautiful :sparkles:
Big change today, now survivors have ids and the world can provide wood to a specific survivor, this was needed, but I didn't enforce that in the test last time I wrote it. I had to do a few changes to the messages and handles for this.
I'm worried that I haven't even started with the actual logic for the simulation, and I may end up with a framework but no book :/
It's official, I'm pivoting from the event driven way into a procedural way, I was taking too long building a whole framework instead of thinking how to actually write the simulation/book. So now I'm focusing on doing it a simpler way, no tests. Did about 100 lines of code in the procedural way and survivors can already acquire wood and craft stuff. I think this could become a cool thing.
Added a luck skill to the survivors, since they will be randomly generated, some may have more luck than others. Also, the events in the island will happen more often to unlucky survivors. It's wierd calling them survivors since they will mostly die in the island :thinking: .
Axes now affect how survivors chop wood, so they chop quicker. I need to add some sort of durability to it now.
First day