Why You Should Avoid Processes
Author |
Message |
[Gandalf]
|
Posted: Fri Mar 04, 2005 7:34 pm Post subject: (No subject) |
|
|
Quote: Delays are another bad thing...I'll get into that later though.
Why are delays bad? Why don't you get on that some time soon, they only pause the code - whats bad about that? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ssr
|
Posted: Fri Mar 04, 2005 8:34 pm Post subject: (No subject) |
|
|
I donno but I think that I've heard
delays are not really accurate
use Time.Elapse
8) |
|
|
|
|
|
person
|
Posted: Fri Mar 04, 2005 9:30 pm Post subject: (No subject) |
|
|
u can actually read about how bad delays are in F10 but frankly it doesnt matter much for me |
|
|
|
|
|
Martin
|
Posted: Fri Mar 04, 2005 9:52 pm Post subject: (No subject) |
|
|
I'll write up a bit about delays later. Basically, they're bad because you've got your program structured like so:
code: | loop
<some unfixed amount of time passes processing stuff>
<a fixed time is delayed>
end loop |
What this means is that the speed of the game is directly dependant upon the speed of the client computer. |
|
|
|
|
|
person
|
Posted: Fri Mar 04, 2005 9:54 pm Post subject: (No subject) |
|
|
isnt it always dependant on the clients computer (processing speeds and etc.) ?? |
|
|
|
|
|
Tony
|
Posted: Fri Mar 04, 2005 11:18 pm Post subject: (No subject) |
|
|
The idea is to control frame-rate, and pause for less on slower machines and during calculation heavy moments.
In practice, you don't want a Counter-Strike player to shoot twice as fast as the next guy just because one has liquid cooling installed. |
|
|
|
|
|
Martin
|
Posted: Sat Mar 05, 2005 10:01 am Post subject: (No subject) |
|
|
person wrote: isnt it always dependant on the clients computer (processing speeds and etc.) ??
No. Yes, on a faster computer, the animation will be smoother, but a player shouldn't be put at a disadvantage because they have a slower processor. Similarly, people with faster computers shouldn't be able to shoot 5 times faster than everyone else.
Let's say that you want each frame of animation to take 20 milliseconds.
Suppose on your computer it takes 10 ms to do all of the crunching, so you delay(10) at the end. Works exactly how you wanted it to on your computer.
You bring it over to your buddy's computer, who has a slower processor, so it takes 15 seconds to do the number crunching, but you still are delaying 10 at the end of each frame. So the game runs slower on his computer.
Now, the quick solution to this is to:
1. Determine the total time, GoalTime, you want the frame to last (in the above example, the total time was 20).
2. In each iteration of the loop, determine how long the number crunching took with Time.Elapsed.
3. Delay for the GoalTime - Time.Elapsed.
Now, what happens if the number crunching is longer than GoalTime? This is where time based movement comes into play, which I'll explain later. |
|
|
|
|
|
Bacchus
|
Posted: Sat Mar 05, 2005 7:19 pm Post subject: (No subject) |
|
|
1 simple thing that is fixed in 4.0.5 Time.DelaySinceLast() |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Martin
|
Posted: Thu Mar 10, 2005 10:34 am Post subject: (No subject) |
|
|
Nobody has taken me up on this 1000 bit challenge. So I'm raising the stakes. 2000 bits.
I still don't think it can be done. |
|
|
|
|
|
StarGateSG-1
|
Posted: Thu Mar 10, 2005 12:26 pm Post subject: (No subject) |
|
|
This program comes form the top!
code: |
monitor controller
export observe, report
var counter : int := 0
procedure observe
counter := counter + 1
end observe
procedure report (var n : int )
n := counter
counter := 0
end report
end controller
process observer
loop
% "¦ observe one event "¦
controller . observe
end loop
end observer
process reporter
var n : int
loop
controller.report ( n )
% "¦ report n events "¦
end loop
end reporter
fork observer % Activate the observer
fork reporter % Activate the reporter
|
This is form deep in the Documentation of turing and I even contacted Tom West to make sure. |
|
|
|
|
|
Martin
|
Posted: Thu Mar 10, 2005 1:10 pm Post subject: (No subject) |
|
|
And umm...what is that supposed to be doing? |
|
|
|
|
|
Tony
|
Posted: Thu Mar 10, 2005 1:44 pm Post subject: (No subject) |
|
|
StarGateSG-1 wrote: This program comes form the top!
...
This is form deep in the Documentation of turing and I even contacted Tom West to make sure.
And we all know that the said top thinks at a highschool level.
Martin : Your turn |
|
|
|
|
|
StarGateSG-1
|
Posted: Fri Mar 11, 2005 7:14 am Post subject: (No subject) |
|
|
The program runs 2 processes at the same time.
Quote:
And we all know that the said top thinks at a highschool level.
What do you mean by this |
|
|
|
|
|
Martin
|
Posted: Fri Mar 11, 2005 8:05 am Post subject: (No subject) |
|
|
StarGateSG-1 wrote: The program runs 2 processes at the same time.
Quote:
And we all know that the said top thinks at a highschool level.
What do you mean by this
Umm, that's easy enough to do without processes, although the above code seems somewhat abstract for me to provide a solid counter arguement.
And Tony, it's on. I'll have the processless code posted by the end of the weekend hopefully. |
|
|
|
|
|
StarGateSG-1
|
Posted: Fri Mar 11, 2005 8:29 am Post subject: (No subject) |
|
|
Quote:
Umm, that's easy enough to do without processes, although the above code seems somewhat abstract for me to provide a solid counter arguement.
Well if it is so easy do it.
If works exaclty the same as anyone other way.
The coed is not abstract, it is right out of the help file. |
|
|
|
|
|
|
|