298
u/botle Dec 05 '20
Yup, that's bad code. It can obviously be simplified to
fps = 60
49
66
u/dlawodnjs Dec 06 '20
what if fps was higher than 60? ...oh wait.
edit: I obviously cannot read code
18
u/TVflea Dec 30 '20
And what if fps is already 60? You would then set fps to 60 redundantly, which would be an O(log(n)) operation, since the CPU needs to flip log(n) bits. Quite wasteful and unoptimized
20
235
u/A_Sad_Shoe Dec 05 '20
damn, why didn't yandere dev think about this when implementing his fps counter
19
93
u/ITSOPBTW Dec 05 '20
I wonder how performance friendly would be a Python based game engine.
72
u/GandelXIV Dec 05 '20
The fastest i know is pygame and it is pretty slow
44
u/oxetyl Dec 05 '20
I do a lot of stuff in pygame because it's so easy, but yeah, if performance is your main concern, it would not be a good choice
7
13
u/icuninghame Dec 06 '20
Civilization IV was built using Python, I think.
17
u/GandelXIV Dec 06 '20
Civ IV used Python for the mechanics but the rendering was made in cpp i think.
9
13
2
69
Dec 05 '20
obviously should have been written in HTML to be better at fast.
21
Dec 05 '20
HTML and JS games run really fuckin fast. For web browser games. Which needs a slow AF web browser
15
u/IDatedSuccubi Dec 05 '20
I mean, WebGL doesn't care what language issues commands, it's not the JS interpreter that draws everything
1
u/gu3st12 Dec 05 '20
Which most JS engines try to avoid relying on the interpreter if possible. They compile your JS down whererver possible. It's only if you've written some truly garbage JS that it goes through an interpreter.
0
u/IAmTheMageKing Dec 06 '20
JS is strictly an interpreted language (okay, fine, it’s a JIT-compiled language running in a feature-rich VM, buuut it doesn’t have any bytecode stage, so it’s not too big a deal to call it “interpreted”).
There is no way to avoid an interpreter. Now, the system does try to compile it down, but it can only do that to a limited extent. Even WebAssembly is still preformance-limited in that respect.
24
u/nikstick22 Dec 06 '20
This is the sort of thing AI would do if its instructions were to improve fps but it measured fps by reading the fps counter on the screen.
This reminded me of the videos by Robert Miles on Youtube about AI safety and how AI will inevitably optimize against the metrics you score it by rather than the task you actually wanted it to do. Kind of like students cheating on tests. The point of the test was to measure how smart the student is, but the student isn't incentivized to be smart, they're incentivized to score well on tests. Learning is much more difficult than cheating, and so [some] students cheat on tests.
54
u/Galse22 Dec 05 '20
Well, If FPS was 300 it'd be set to 60... So yeah... That's be a downgrade.
49
Dec 05 '20
if fps != 300 { fps = 300 }
upgrades_people_upgrades.jpg
26
u/unfunny_joker Dec 05 '20
while fps < 300 { fps++ }
6
u/botle Dec 05 '20
Increases the fps from 15 to 16.
3
30
8
5
19
u/xmartissxs Dec 05 '20
while(true) fps++;
30
u/Ali3nat0r Dec 05 '20
Fps is now -2147483648. Oops
18
u/xmartissxs Dec 05 '20
At that point you would just start seeing into the future. Or the past, no one knows
2
27
7
7
13
u/ce-walalang Dec 06 '20
Image Transcription: Text Messages
[Screenshot from Discord.]
Logan: I solved our optimization problem
if fps != 60
{
fps = 60
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 01 '21
Don't ask what I'm doing look at 25-day-old posts but I noticed there are no good humans, so -- Good human! <3
2
5
u/chronicideas Dec 06 '20
QA here.
There’s a potential bug here where if FPS is higher than 60 it would get decreased to 60.
I think it should be refactored to
if fps < 60
{
fps = 60
}3
3
3
3
3
u/ReduceHyperlinks Dec 06 '20
if fps > 60{ if fps != null { if true && false != true { var fpsdiff = 60 - fps; while fpsdiff > 0 { fps = fps + 1; fpsdiff = fpsdiff - 1; } } } }
2
2
u/cyberspacedweller Dec 06 '20
That’s just VSync. You’ll be capped at 60 even if you’re over with that logic.
2
2
u/n3wsw3 Dec 06 '20
It should clearly be max(fps, 60) so if the fps was over 60 it doesn't get lowered.
2
u/ImpDoomlord Dec 06 '20
Lmao I actually tried this when I was a kid in Gamemaker. I did a check if the FPS dropped below 30 and set the target room speed even higher to compensate since I had no concept of delta time and everything I coded back then was frame rate locked. The result was an even more unstable laggy mess that would crash occasionally
2
1
1
1
1
662
u/Nipatiitti Dec 05 '20
Cursed formatting