ID:152498
 
As you may know, there are MANY MANY MANY games in BYOND that are cool, but lag when 5 or 6 ppl are playing.

You might think it's ONLY BECAUSE of the hosts connection, but it is NOT. Many games that can be multioplayer offlines (NPCs), such as Plan of Attack
, can be played offline with bots.

Today I was playing some solo games and they were incredibly laggy. I just didnt get it, but today I was looking at some of my old codes, and I looked how newbie I coded. These games were massively laggy.

But, there are many games that like, 9 or 10 people play, and it runs smoothly ( D4RK3 54B3R 's games runs so smooth... :') ).

That might be a result of Trash Code?

But, what is Trash Code??
mob/verb/Say(T as text)
if(src.client)
if(T)
world << "[src] says: [html_encode(T)]"

OR
//blah blah....
if(Health == 0)
world << "blah blah. Whatever."
if(Health < 0)
world << "blah blah. Whatever."

Yes. Noobish if's and unnecessary lines.
Most lag is produced by HUDs. ( It has been BYONDly proved by me! (I took all HUD away from a game, and cpu lag decreased by 15 while playing))

On the 2nd example, it has 2 unnecessary lines. these lines could be 'fixed' by using || stuff.

I think that many games lag on multiplayer because of this. D4RK3 54B3R should give a class to newbie people, explaining to them how to decrease lag.

ANYWAYS
BE part of the Anti-Trash Code program! Post in the games forums which games should be re-coded!! FIGHT AGAINST LAG!

#Gooseheaded#
A || operator in the health snippet is completely unnessecary and it can also be done on one line. It can be done like so...

if(Health<=0){world<<"Blah blah"}


-Exophus
Hud doesn't nessisarly create lag, it's how well you program them, and what it does.
Gooseheaded wrote:
( D4RK3 54B3R 's games runs so smoothly... :') ).


I don't know about you, but after the huge initial download period of Faction Wars, the game tends to lag. No game is lag-free.
In response to Sniper Joe
Sniper Joe wrote:
Hud doesn't nessisarly create lag, it's how well you program them, and what it does.

HUDs do tend to create lag when there are many objects on the screen because of they way they are implemented on BYOND. Refer to Lummox JR's post: [link]

~~> Unknown Person
In response to Unknown Person
The way you refresh your HUD should play a role in lag, as well.

-Exophus
Oh please, I barely even try to make my code run faster or anything. Hell, I even used icon.Turn() in an Action Game. Then I took it out because Crashed kept complaining.

My games just seem less laggy because:

1. I have a generally "high-end" system compared to most people on BYOND.

3. I have ~48kbps upload speed (Cable Internet)

2. I'm usually the only one hosting my games

Unknown Person wrote:
HUDs do tend to create lag when there are many objects on the screen because of they way they are implemented on BYOND.

I'll keep that in mind. Thanks for the info. =D

PS: Gooseheaded, you should stop idolizing me.
If we didn't have lag, we would be dead at birth.
I'm not sure what you're driving at here, because the idea that inefficient code can cause game lag is kinda ludicrous if you have any knowledge at all of the subject. Granted it's not good to be inefficient, but lag is pretty much exclusively a function of the network. Obviously the host and the number of players are a factor, and if you're having problems in solo games then it's your computer that's to blame. (In fact you're not even using the right word, since you can't have lag if there's no network connection.)

And this, by the way, is also bad code:
<dm.world << "[src] says: [html_encode(T)]"</dm>
You should always use [name] there, not [src], or lowercase keys get screwed up. And usually it's more presentable without the "says" part.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
And usually it's more presentable without the "says" part.

Depends on if it's "in-character" or not -- and whether there's a distinction between in-character and out-of-character (99.99% of BYOND games have no such distinction...). But then, it would best be presented as an actual sentence in that case, with proper punctuation et al.

Yes, I'm picking nits. =)
In response to Lummox JR
Lummox JR wrote:
And this, by the way, is also bad code:
<dm.world << "[src] says: [html_encode(T)]"</dm>
You should always use [name] there, not [src], or lowercase keys get screwed up. And usually it's more presentable without the "says" part.

Lummox JR

How about just adding \improper there? :P
In response to DivineO'peanut
DivineO'peanut wrote:
Lummox JR wrote:
And this, by the way, is also bad code:
<dm.world << "[src] says: [html_encode(T)]"</dm>
You should always use [name] there, not [src], or lowercase keys get screwed up. And usually it's more presentable without the "says" part.

Lummox JR

How about just adding \improper there? :P

Then it would always be wrong. \proper is what you'd want.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
I'm not sure what you're driving at here, because the idea that inefficient code can cause game lag is kinda ludicrous if you have any knowledge at all of the subject. Granted it's not good to be inefficient, but lag is pretty much exclusively a function of the network. Obviously the host and the number of players are a factor, and if you're having problems in solo games then it's your computer that's to blame. (In fact you're not even using the right word, since you can't have lag if there's no network connection.)

I'm not trying to pick bones here, but according to The Blue Book:
# lag is any unintentional delay in input/output. It can be caused by an overloaded network or server machine--referred to, respectively, as network lag and server lag.

I had always thought that inefficient code did cause lag; it was just CPU/Server lag.

Please correct me if I'm wrong.
In response to Airjoe
Airjoe wrote:
Lummox JR wrote:
I'm not sure what you're driving at here, because the idea that inefficient code can cause game lag is kinda ludicrous if you have any knowledge at all of the subject. Granted it's not good to be inefficient, but lag is pretty much exclusively a function of the network. Obviously the host and the number of players are a factor, and if you're having problems in solo games then it's your computer that's to blame. (In fact you're not even using the right word, since you can't have lag if there's no network connection.)

I'm not trying to pick bones here, but according to The Blue Book:
# lag is any unintentional delay in input/output. It can be caused by an overloaded network or server machine--referred to, respectively, as network lag and server lag.

I had always thought that inefficient code did cause lag; it was just CPU/Server lag.

"Server lag" is mostly just poor terminology, but it comes from the tendency of all online gamers to refer to slowdowns as "lag". Consider it Dantom's nod to the gaming community. True lag is really only a communications issue.

Lummox JR
In response to Airjoe
Aye, network or server lag, meaning that the slowdown is coming from the server machine's side, or your part of the connection.

Lummox is right, Lag is merely a latency issue. Having a slow processor doesn't make your computer laggy, it makes it slow. Having low memory doesn't make it laggy, again, slow. While lag makes a program run slow, it doesn't affect the program, it affects the connection, and generally the flow of anything using data from the network connection.

So, I stand by Lummox's correction there.

Though, a lot can be said for having efficient and tidy systems. a spare if() can't slow you down a lot, but having large loops that are processor intensive can really mess you up bad.
In response to Lummox JR
KK, thx for the ~name~ detail.
But the stuff I wrote there was totally random... I had 3 mins left in the Cafe and I... whatever.
In response to Airjoe
Now I'm confused. I proved it myself with my nooby game (Defensive Rampage(I GOT THE SOURCE CODE BACK, WOOHOO)) and I like, took out 5 diff death procs (:P) and it ran faster. I proved it with a world.CPU statpanel.

o_O
In response to Lummox JR
Lummox JR wrote:
the idea that inefficient code can cause game lag is kinda ludicrous if you have any knowledge at all of the subject. Granted it's not good to be inefficient, but lag is pretty much exclusively a function of the network.

I may be totally wrong, but I think this may be off..

If a game function is too processor intensive on the server, couldn't it hinder the server's ability to maintain its regular, steady network? I mean, yeah, lag is not equal to the amount of time it takes the server to processor to handle an operation, but if the operation requires too much from the server wouldn't that contribute to the lag as well?

Hiead