i coded soem roguelike game loop which gave me
a lot of logical trouble
imagine game has micro turns, thise micro turns are
noted by
int game_time = 0; //styart with microturn 0
if you press a key on keyboard you update variable
of chuman character: character[HUM}.action_end = game_time+300
then the not human bits should execute in thise microturns
until you reacg turn 300 then you need to read keyboard again
what work is terribly weird, maybe becouse i started
with while loop and while loops from my experience
im not sure but imo tent do be logically heavy problematic
form tiem to time..what work is
void ProcessMicroturnsUntilHuman()
{
if( game_time < character[HUM].action_end)
{
while(game_time < character[HUM].action_end)
{
DispatchActions();
game_time++;
}
if(game_time == character[HUM].action_end) //**
DispatchActions();
}
}
is there some more proper form of this loop?
(the line nioted by ** i know is not needed but
overally this loop is weird imo
[*] A friend of mine just recently implemented the code frame for a
roguelike and followed the suggestion of an event based object-oriented implementation; it worked well, he told me.
On Wed, 20 Nov 2024 17:34:34 +0100, Janis Papanagnou wrote:
[*] A friend of mine just recently implemented the code frame for a
roguelike and followed the suggestion of an event based object-oriented
implementation; it worked well, he told me.
The next step would be to use coroutines so the logic of a longer-running task, which has to wait for other events at multiple points, can be
written in a single linear stream without having to be fragmented into multiple callbacks.
there is a question qhat would be more logical (prone, suitable) here
for example it is a movement and say takes 200 mikroturns then logicall
would be to not do this as Setup() in turn 0 and finalize(0 in turn 200
but add 1/200 of distance in each turn.. but the rogualike is in
discrete space on tiles so i think setup() and finalize() is probably
better
more yet in things like fight ..say one character was Setuping() a hit
which takes like 90 microturns to finalize and the defender could be
able to setup() a shield blocking or something or decide to setup a
hit too
i dont tested it yet but my [previous approach without the actions that
spans in time was much simpler and you only eventually check what last
action of given bot waas bot not which next or current is
some would say tehe simpel would suffice but in fact if soeme want model
more nice system you need that spaning action time imo...sadly the
division of myriads of this actions on setup() and finalize() is worse
to code
well im somewhat experienced in writing roguelike (never make some
finished but i wrote them i dont know in sum maybe about 3-4 months day
bay dey
previously i used thsi simpler approach and the conclusion from
experiecne was i need something that stores the action..
bothering bots i dont see as a problem but it is just needed to eb able
to bother them - not for being unable for bother them... i just need a
lot of cases when i could combine warious states for good efects
spells in turn if casted just live on their own loop so they not block
a caster if are casted
Actually, if you know Simula, coroutines are inherent part of that
language, and they based their yet more advanced process-oriented model
on these. I find it amazing what Simula provided (in 1967!) to support
such things. Object orientation[*], coroutines, etc., all fit together, powerful, and in a neat syntactical form.
On Thu, 21 Nov 2024 07:06:43 +0100, Janis Papanagnou wrote:
Actually, if you know Simula, coroutines are inherent part of that
language, and they based their yet more advanced process-oriented model
on these. I find it amazing what Simula provided (in 1967!) to support
such things. Object orientation[*], coroutines, etc., all fit together,
powerful, and in a neat syntactical form.
Wirth did include coroutines in Modula-2. And a kind of object orientation
in Oberon, I think it was.
But these are (nowadays) called “stackful” coroutines -- because a control
transfer to another coroutine can happen at any routine call, each
coroutine context needs a full-sized stack, just like a thread.
There is this newer concept of “stackless” coroutines -- not that they have no stack, but they need less of it, since a control transfer to
another coroutine context can only happen at the point of an “await” construct, and these are only allowed in coroutine functions, which are declared “async”. I think Microsoft pioneered this in C♯, but it has since
been copied into JavaScript, Python and other languages.
Yes, Simula pioneered OO. But the concept has gone in different directions since then. For example, multiple inheritance, metaclasses and classes as objects -- all things that Python supports.
On Thu, 21 Nov 2024 07:06:43 +0100, Janis Papanagnou wrote:
Actually, if you know Simula, coroutines are inherent part of that language, and they based their yet more advanced process-oriented
model on these. I find it amazing what Simula provided (in 1967!)
to support such things. Object orientation[*], coroutines, etc.,
all fit together, powerful, and in a neat syntactical form.
Wirth did include coroutines in Modula-2. And a kind of object
orientation in Oberon, I think it was.
But these are (nowadays) called “stackful” coroutines -- because a control transfer to another coroutine can happen at any routine call,
each coroutine context needs a full-sized stack, just like a thread.
There is this newer concept of “stackless” coroutines -- not that
they have no stack, but they need less of it, since a control
transfer to another coroutine context can only happen at the point of
an “await” construct, and these are only allowed in coroutine
functions, which are declared “async”. I think Microsoft pioneered
this in C♯, but it has since been copied into JavaScript, Python and
other languages.
Yes, Simula pioneered OO. But the concept has gone in different
directions since then. For example, multiple inheritance, metaclasses
and classes as objects -- all things that Python supports.
On 21.11.2024 00:53, Lawrence D'Oliveiro wrote:
On Wed, 20 Nov 2024 17:34:34 +0100, Janis Papanagnou wrote:
[*] A friend of mine just recently implemented the code frame for a
roguelike and followed the suggestion of an event based object-oriented
implementation; it worked well, he told me.
The next step would be to use coroutines so the logic of a longer-running
task, which has to wait for other events at multiple points, can be
written in a single linear stream without having to be fragmented into
multiple callbacks.
Yes, indeed.
Actually, if you know Simula, coroutines are inherent part of that
language, and they based their yet more advanced process-oriented
model on these. I find it amazing what Simula provided (in 1967!)
to support such things. Object orientation[*], coroutines, etc.,
all fit together, powerful, and in a neat syntactical form. - But
"no one" is using Simula, and my friend was using C++; don't know
what C++ supports in that respect today. I know that he implemented
the "simulation" parts (queuing, time-model, etc.) in C++ himself.
[*] It was the language who invented Object Orientation [...]
On Fri, 22 Nov 2024 00:04:32 -0000 (UTC)
Lawrence D'Oliveiro <[email protected]d> wrote:
Yes, Simula pioneered OO. But the concept has gone in different
directions since then. For example, multiple inheritance, metaclasses
and classes as objects -- all things that Python supports.
What I read seems to suggest that Smalltalk had bigger influence on
modern twists of OOP. But then, may be Simula influenced Smalltalk?
Anyway, I don't like OOP very much, esp. so the version of it that was
pushed down our throats in late 80s and early 90s.
Janis Papanagnou <[email protected]> writes:
Actually, if you know Simula, coroutines are inherent part of that
language, and they based their yet more advanced process-oriented
model on these. I find it amazing what Simula provided (in 1967!)
to support such things. Object orientation[*], coroutines, etc.,
all fit together, powerful, and in a neat syntactical form. - But
"no one" is using Simula, and my friend was using C++; don't know
what C++ supports in that respect today. I know that he implemented
the "simulation" parts (queuing, time-model, etc.) in C++ himself.
[*] It was the language who invented Object Orientation [...]
No, it wasn't. First, programming in a language with classes and
objects does not imply object-oriented programming.
Second, the
underlying ideas of object-oriented programming pre-date Simula 67
by five years or more.
That history has been pointed out by
Alan Kay, who is the originator of the term and is responsible
for pioneering the concept.
Almost everyone who took Simula and C++ as the archetype for OOP
never understood it.
On 05.12.2024 04:53, Tim Rentsch wrote:
Almost everyone who took Simula and C++ as the archetype for OOP
never understood it.
LOL.
(Funny [dogmatic] statement, without any substance again.)
On 05.12.2024 04:53, Tim Rentsch wrote:
Almost everyone who took Simula and C++ as the archetype for OOP
never understood it.
If you take the position that Alan Key, as the person who is credited
with inventing the term "object oriented programming", gets to make the definition of what OOP is, then Tim's statement is accurate. Originally
OOP meant something very different from how it is interpreted in C++. (I don't know Simula except by reputation, so I can't comment on that.)
The original idea of OOP was to have self-contained "objects" that communicated only by passing messages. If object A wanted object B to
do "foo", it would not call "B.foo()" in its own context, as is done in
C++. Instead, it would pass a message "foo" to B. What B does with it,
and when, is up to B. If a return value is expected, then B will send a message with the answer back to A.
This is, I think, akin to the modern "actor" programming paradigm, [...]
Of course, all this has significant overheads - it is not suitable for a low-level high efficiency language. The rather different idea of OOP represented by languages like C++ can be very much more efficient, which
is why it caught on.
Perhaps the language that is most true to the original idea is Erlang,
with its "write once, run forever" motto.
On 05.12.2024 02:07, Tim Rentsch wrote:
Janis Papanagnou <[email protected]> writes:
Actually, if you know Simula, coroutines are inherent part of that
language, and they based their yet more advanced process-oriented
model on these. I find it amazing what Simula provided (in 1967!)
to support such things. Object orientation[*], coroutines, etc.,
all fit together, powerful, and in a neat syntactical form. - But
"no one" is using Simula, and my friend was using C++; don't know
what C++ supports in that respect today. I know that he implemented
the "simulation" parts (queuing, time-model, etc.) in C++ himself.
[*] It was the language who invented Object Orientation [...]
No, it wasn't. First, programming in a language with classes and
objects does not imply object-oriented programming.
It does not necessarily imply it. But if you'd know some more about
it you might understand that it's the natural way of thinking when
simulating systems' objects, and modeling object structures. Simula
in a natural way provided the platform to program object oriented.
(As said, without coining the term or speaking about "OO".)
Second, the
underlying ideas of object-oriented programming pre-date Simula 67
by five years or more.
Of course the ideas were there before Simula was released in 1967;
the inventors (also publicly) presented their ideas five years ago.
That history has been pointed out by
Alan Kay, who is the originator of the term and is responsible
for pioneering the concept.
Yes, the Simula "OO" pioneers didn't invent the *term* "OO", but they
were (amongst) the first who spread the ideas and the first inventing
a language to model OO and work with the OO concepts that are still
used and implemented in many other OO languages nowadays.
(All the rest is [IMO] no more than dogmatic or marketing.)
If you have some substance on the topic I'm always interested to hear.
Tim Rentsch <[email protected]> writes:
[...]
People who think programming in C++
or Simula encourages object-oriented programming don't understand
the term.
Or they use the term differently than you do. Language is not static.
Tim Rentsch <[email protected]> writes:
[...]
People who think programming in C++
or Simula encourages object-oriented programming don't understand
the term.
Or they use the term differently than you do. Language is not static.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 153:58:58 |
| Calls: | 12,091 |
| Calls today: | 4 |
| Files: | 15,000 |
| Messages: | 6,517,674 |