RandomFapinator
Member
- Sep 21, 2019
- 238
- 201
- 85
Oh no lol, I thought of the problem quickly and it popped up in my head, not the other way around. Right, it could also be location based and not timed based. But... aren't FIFO queues of small pre-determined size already implemented/interpreted as arrays with extra index information in optimized libraries? Or this isn't the case in the Python binaries? Genuinely curious.Not really. You're kind of thinking of it backwards. You're trying to match the problem to the data structure instead of the data structure to the problem. No matter what happens, that game has to know what to run at a certain point. That might be timeslot, but that might also be location (entering the classroom, for example). But also consider that some events should take priority over others to prevent continuity errors or skip events altogether. So FIFO queues can work, but really, all you need is an array (they call that a list in python, right?). Most modern and/or interpreted languages should have the capability to push, pop, shift and unshift to an array. So you push an object to the array. The object can be like:
charname: "Laura",
priority: 5,
check: "Love>900"
And since it's an array, you can sort the array by priority at the time of pushing it into the array. So when the queue is read from, it can automatically find the first event to run which has the highest priority. There are other ways of doing this, but that is just an example off the top of my head.
I would completely agree with your approach on low-level languages. But even then, you might miss out on potential compiler optimization or hardware intrinsics unless you plan to use them.
We agree here: trying to make your own data structure in high-level languages (Python) usually results in slower performance than using native libraries unless we are dealing with large scale problems (which I assume is not the case here). I am just afraid that if you want to efficiently implement your own data structure and the operations within it, you would have to resort to things likeAnd yes, when using a language, you should lean on the parts of the language that it has optimized. But remember, if you're using something just to use it, often times any benefits from the language optimization is lost. Basically, if I can give you any programming advice to you, it's that you (try to) make the solution to the problem, not change the problem to match your solution.
You must be registered to see the links
and try to do better than <stdlib.h> in C and that may be overkill for a game of this size.I am not a Python specialist, so I will assume you know betterNo, not really. This is my job (or rather, has been my job. Looking for a new job atm). I just happen to like my job. This is like asking your professional chef friend what he thought of your pasta sauce and he suddenly starts hand-making ravioli to pair with your sauce. For you, that's a big deal. For him, it's Tuesday.