Why is Bukkit/Minecraft server 20 ticks per second?

Discussion in 'Plugin Development' started by IamHD, Apr 8, 2014.

Thread Status:
Not open for further replies.
  1. I also assume they would use as much code as possible/reasonable for adding SMP, so changing the tick rate would be a lot of work - 20 ticks also simply seems to work out for the Minecraft type of game.

    Why would one use less ticks? Probably one would not, simply.

    Why use more ticks? Probably to decrease latency further, but what would 40 ticks lead to... you would have much stuff executing not every tick, but probably process some events more often (could do the same with twice per tick checking), less chunks processed per tick... Also there are other side conditions, like how many packets per second should the player send? 40 Moving packets per player would be harder to keep up to considering the networking processing, so 20 could even be the optimum for it all. Redstone updates how often...

    It's an eco-system built around the somehow working 20 TPS, probably there is no simple answer (other than it was so from the start and it worked out).
     
  2. Offline

    breezeyboy

    By the time Mojang took over they'd have to rewrite thousands and thousands lines of code to change the TPS from 20 to 30 for example.
     
  3. Offline

    amhokies

    Why not just rewrite the server in assembly?
     
    Chinwe, Bone008 and LucasEmanuel like this.
  4. Offline

    breezeyboy

    Because Mojang have time to rewrite the server
     
  5. Offline

    LucasEmanuel


    [​IMG]
     
    NathanWolf likes this.
  6. Offline

    IamHD

    I don't think a high frame rate will damage the human eye..... Because think of all the home lights and street lights we use XD. It's all blinking!


    Yes we all know that the client does interpolation, which is why we have all the hacks and glitches XD. So that's another reason why we should have a high Tick rate so we don't need as much interpolation from the client which leaves space for little glitches and hacks.

    Yes! we could and should be able to have a dynamic tick rate that doesn't affect the game engine! The game engine's stuff should be independent of the TPS! instead using time! like Techy4198 said!
    But I would imagine that would really make servers and plugins super hard to develop.

    So concluding what everyone said
    • It's 20 ticks because Minecraft Server is poorly programmed, and it can't go any faster
    • It's 20 ticks because that's how the Minecraft game engine was programmed(The minecraft game engine is based on ticks not delta time)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  7. Offline

    Not2EXceL

    "In game time is based on ticks not system time" - umm did you just brainfart? How do you think the ticks are calculated to be kept constant as best as possible? Also then we wouldn't be able to do our own TPS checks using System.nanotime() if it was as you say, based on ticks not system time
     
  8. Offline

    hamzaxx

    http://minetest.net/
     
    kittyPL likes this.
  9. Offline

    IamHD

    Ummm did you brain fart? Your argument is very hard to comprehend logically and grammatically, but I'll try my best to respond.
    Did you even think through how things work in Minecraft servers? When you create a countdown plugin what do you use? System time or Ticks? Tell me :) ticks? I thought so, what do you think Minecraft uses to calculate water flowing? System or Ticks? Woops, turns out it's TPS
     
  10. Offline

    Not2EXceL

    Do you even know how ticks are calculated? System.nanoTime(); #facepalm
     
    kittyPL likes this.
  11. Offline

    IamHD

    Your argument is so ignorant that I'll leave it to you to figure it out. I updated my original response to make it more clear.
     
  12. Offline

    Not2EXceL

    My argument is ignorant? I've been attempting to respond to your stupidity without flaming, but it seriously has become difficult.

    Ticks in minecraft are equivalent to 50ms (at least that is the goal, 20 tps). In order to keep the ticks at the constant goal of 20 tps, it requires System.nanoTime(); to calculate each tick to be the equivalent of 50ms. Now if your system is lagging and you don't get the goal 20 tps and say 10 tps, it doesnt matter whether the server is as you say "based on system time" and not ticks. It will still be just as laggy.

    Clearly you don't understand the concept of Ticks PER Second. And yet you have the audacity to call me ignorant.
     
  13. Offline

    IamHD

    Here's a hint, making a game using system time means no matter what the tick is, the game stays consistent(Water will flow where you'd expect it), despite the potential choppy animations. If game is based on ticks, once the ticks slow down, everything will slow down (Water will flow slower), and be choppy at the same time.
     
  14. Offline

    Not2EXceL

    Except if you wish things to be consistent, you cant base it off of purely the system's time. Then everything will be based upon the machine that runs the said program. Have you not been reading any of the posts previous? Why do you think Counter Strike runs at 128 tps, oh wait its still using ticks but according to you that must be so bad. You clearly dont have an understanding of how game programming works.
     
  15. Offline

    IamHD

    It's very difficult to argue with you when you clearly have not developed a game that calculates delta time and has consistent update rates.
    When you have a physics engine that is based on ticks, it means
    psuedo: for every tick ball moves velocity (That's why the water flows slower when you have lower TPS!)
    When you have a physics engine that is based on delta time you do
    psuedo: for every tick ball moves velocity multiplied by delta time between ticks
     
  16. Offline

    coasterman10

    This is becoming a flame war, instead of trying to insult each other you should try to come to a consensus on what a tick is.
     
  17. Offline

    Not2EXceL

    If this is what you were trying to say the entire time, use the right wording. Its delta time vs ticks. Not system time. System time implies that its based upon the system's timing, which delta time AND ticks are based upon. And its not dynamic update rates, its simply consistent updates rates despite the current system lag.
     
  18. Offline

    IamHD

    I didn't want to argue with him, he was just so compelled to prove him self.

    Thank you for your corrections. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  19. Offline

    Not2EXceL

    No I was simply arguing what your statement said. You said this:
    What should have been said and could have averted this entire argument:
    Im glad the argument is over. The miscommunication due to the wording is what I was arguing, but instead you were trying to say something else. The argument could have been averted with simply the correct wording.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  20. Offline

    RawCode

    looks like everyone in this thread unable to read.
    i posted link to article about ticks, that article of mine provide you with code, and explains how it flows.
    but you still post random absurd thoughts about "how server works" what wrong with you?

    minecraft server uses delta time, client also uses delta time, it clearly stated in article and visible in code, i specially extracted single method to show this.

    TPS != FPS , looks like you very very "unsmart" to understand difference, i will explain it:

    Lets imagine, server run at 1 TPS - it iterate all objects single time per second and perform all actions required on them at once, process consume 100 ms, 900 ms left server is sleeping.

    Server report to client - Entity A move from Location B to Location C, this done single time per second (TPS 1);

    Client now knows that server already moved object from location B to location C, it may teleport it instantly (FPS 1) or render smooth transition and play nice walking animation (FPS 999).

    Answer is TPS and FPS unrelated to each other.

    I just can't see any logic behind asking to increase tick rate.
     
    AdamQpzm likes this.
  21. Offline

    IamHD

    I'm too tired for an argument. It just looks like you can't read Mr better then everyone else guy.

    I know the difference between TPS and FPS very well, if you couldn't tell from my replies. I'll use a different wording so the words can get into your head which refuses to read what others write: The low frequency game environment updates causes the client to see teleportation like movements, despite it's attempt to interpolate(adding fluency to the movements)!
    The typical example: "Players turning their head look like their head is instantly teleporting from one direction to the other"
    This example does not mean that the client has a low framerate, but it's just the animation is choppy.

    I know you want to show off your understanding of the server and programming, but please don't do that by insulting and telling people stuff they know.

    Yes I have read your damn article many times RawCode! Minecraft servers does not use delta time to update the game environment, rather it the updates are based on each tick! It seems like you have a very low understanding of what it means by updating by delta time. Running doTick() 20 times a second does not mean the game engine based on delta time! My example of the balls are perfect for your understanding (Look at the bottom of the reply).

    Proof that Minecraft servers is based on ticks not deltatime:
    Show Spoiler

    Source code of WorldServer: link
    Code:
    public void doTick() {
    (omitted other codes that also updates)
          this.worldData.setTime(this.worldData.getTime() + 1L);
    (omitted other codes that also updates)
    } (from net.minecraft.server.WorldServer, the doTick method is running under a while loop that loops every 500 milliseconds)
    IF Minecraft servers was running based on deltatime, this code would be
    Code:
    public void doTick() {
    (omitted other codes that also updates)
          this.worldData.setTime(this.worldData.getTime() + (deltaTime*20);
    (omitted other codes that also updates)
    } (from net.minecraft.server.WorldServer, the doTick method is running under a while loop that loops every 500 milliseconds)


    Ball Physics example
    Show Spoiler
    When you have a physics engine that is based on ticks, it means
    Code:
    psuedo:
    while(isRunning){
    ball += velocity*1/20;
    thread.sleep(1/20);
    }
    (That's why the water flows slower when you have lower TPS! Because the game assumes it's always 1/20 delta time)
    When you have a physics engine that is based on delta time you do
    Code:
    psuedo:
    while(isRunning) {
    deltatime = os.time() - finishtime;
    ball += velocity*deltatime;
    finishtime = os.time();
    }
    (this one how ever considers delta time)
    
     
  22. Offline

    RawCode

    still unable to read?
    protip, as long as you not reading answers of other people, you will look stupid, every time:

    Code:
                            while (j > 50L) {
                                MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
                                j -= 50L;
                                this.t();
    
    }
     
  23. Offline

    lycano

    "Why 20 ticks per second?"

    1) open your browser
    2) navigate to google.de
    3) type in "ticks per second minecraft"
    4) Visit the english version on gamepedia about Ticks http://minecraft.gamepedia.com/Tick
    5) Read and understand

    yeesh .. that wasnt hard wasn't it?

    If you still ask "why 20" even after reading this article then ask yourself some other more interesting questions than such a simple decision someone made while designing the game mechanics.

    Why is PAL running with 25 (full) frames per second?
    Why is NTSC running with 30 or more precise 29.97 (full) frames per second?

    Why is NTSC called "Never the same color"?

    Can a human eye benefit from a game that can run faster than 30 fps even if the refresh rate of your monitor (most likely a TFT) is fixed to 60 Hz?

    Just think about it. Please dont answer to it since i do not want to get more offtopic here since a) this thread is in the wrong category and b) i do not challenge you its just a comparison.
     
    kittyPL, Bone008 and RawCode like this.
  24. Offline

    IamHD

    I'm just going to assume you're a troll and you just like saying "are you unable to read?"

    Your answer does not fit my question at all. Yes the wiki explained HOW, but not WHY we need it to be 20 TPS. Yes those examples are true, but they all HAVE A REASON. Minecraft's mysterious 20 TPS doesn't have a reason
     
  25. Offline

    RawCode

    IamHD

    I already answered all your questions, but you ignoring my posts and calling me troll, wtf?
     
    xTrollxDudex, kittyPL and lycano like this.
  26. Offline

    lycano

    Taken from: http://minecraft.gamepedia.com/Tick
    "Just as every gear in a clock is synchronized with the pendulum, every task involved in advancing a game simulation is synchronized with the game loop."

    If you read the next passage that is describing "Game ticks" you may stumble over "Minecraft's game loop normally runs at a fixed rate of 20 cycles per second, so one tick happens every 1/20th of a second. An in-game day lasts exactly 24000 ticks, or 20 minutes."

    Hmm ... 20 ticks is a 1/20 th of a second ... one day is 24000 ticks or 20 minutes ... this would be a third of an hour in real time ....

    What does that mean? you will see the sun and the moon going up and down at least two times. So you can actually see an ingame cycle of a day.

    It would be very boring if ingame time would be real time for a game like minecraft since you want to do stuff .. you want survival right? Survive a day in real time? Ho much time do you have?

    Do you want to plant seed? Have fun seeing it grow if the tps would be a higher number. If im not getting confused here increasing the TPS would mean that the server would process more actions per second like a monster would walk faster or a seed would be instantly spawn (no time to grow since more actions will be processed).

    Anyways i hope you see that this is a decision someone made while creating game mechanics. Those games need a constant factor otherwise it cant be in sync.

    Increasing it would also mean that the client would have to keep up with it. Since they wanted that it can be played on almost anything this could be a factor.

    What happens when you lower the TPS?
    well ... you see what happens when a plugin wants to do as many actions per tick as possible. This leads to lags since there are other plugins who want to do the same. In this case a programmer can optimize and decide to run stuff in the next tick to avoid that his plugin will flood the queue.

    Why did i asked stuff like "Why is PAL running at ..."? Well to encourage you to think about it.

    Sorry, but i think i failed :/
     
    RawCode likes this.
  27. Offline

    IamHD

    RawCode, you've shown clear misconception and I can't argue with you any further, you're on your own, maybe one day you'll get it, maybe you won't. I have spent a lot of my time replying to you and It's not worth it.
    Clearly you haven't built game engines ground up your self having this huge misconception. This is the last reply I will do regarding to your ignorant ranting of either "not reading your post" or your misconception of consistent updates based on time change(via delta time) . Because
    #1 because you make insults when you're trying to make an argument
    #2 You don't understand what game engines running on delta time means (at all).
    what do you think will happen if we changed the?
    Code:
    while (j > 50L) { MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
    j -= 50L;
    this.u();
    }
    
    to
    Code:
    while (j > 50L) { MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
    j -= 25L;
    this.u();
    }
    
    Yes, things in game will be two times fast!(Mobs will move faster, water will flow faster etc.) Because it ticks 2 times every 50 millisecond now(Assuming that the server can keep up).
    You're misconception is HUGE and you are so convinced that you're right! Please read the following words assuming I'm right and maybe that will shine a light into your understanding.

    A game engine where in game changes are independent of tick rates is an game engine based on delta time. (Also known as tick rate independent)

    Which means, even if we were to update the server every 25 milliseconds, the water should have flowed at the SAME SPEED. Which unfortunately it does not, it's faster.
    Which brings to an final and undebatable conclusion. Minecraft server's game engine is not based on delta time.
    If your still convinced that you're right please follow up here :
    Game programming: an explanation of delta time

    I'm sorry but your response is even worse, you don't understand dang thing and I'm tired of explaining
    Yes Minecraft TPS is 20, good. The topic is about why did Mojang choose to update at 20 ticks per second? Why couldn't they make it so that it updates 30 ticks per second(with 36000 tick days) or 60( with 72000 tick days) or 120 (etc)? or better, custom TPS (day length independent of ticks).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  28. Offline

    lycano

    IamHD thats the only thing you can say yes? Wow, why did i spend so much time writing an answer it if you don't even read it? RawCode have fun with this troll im outa here.
     
    kittyPL, L33m4n123 and RawCode like this.
  29. Offline

    RawCode

    IamHD
    Well, since you not reading my posts anyway, i wont respond any future, not going to waste my time on trolls.
     
    kittyPL and lycano like this.
  30. Offline

    IamHD

    All you did in that big chunk of words is explaining things that this post assumes the audience knows! What is your point in that huge chunk of useless words? Does it explain why can't send 30 packets of updating information to the client? or rather is it still explaining how the server updates 20 times?

    Lol, :) this post is better without you two. It's always the follow up late Mr. Know It Alls that causes arguments, this post was very productive when it began and we've gone through a lot.

    Why are you always saying I don't read? I read what you had to say and it's wrong! in many dimensions and ways. You're really getting to my nerves here, what kind of troll are you? Comes in and calls every one "not reading" and then just continues to call me "not reading"
    RawCode:
    Most stubborn idiot that I've seen in a while. Saying that people don't read does not justify your wrong concept

    Your misconception is that the period of something happening has direct relationship the TPS. Yes currently 20 ticks = 1 second, but why isn't it 30 = 1? Are you as stubborn as RawCode? Changing the TPS doesn't mean the day has to be shorter, it means we are also changing the ticks in a whole cycle of the day. Which in the case of 30 TPS is 36000 ticks in a 20 minute day. If you fail to understand this reply no further.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page