# Turn time system algorithm

**URL:** https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955
**Category:** The Bunker
**Created:** [February 21, 2021, 4:36pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955 "2021-02-21T16:36:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![wrathofgomorrah](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wrathofgomorrah/32/10850_2.png) [@wrathofgomorrah](https://discourse.cataclysmdda.org/u/wrathofgomorrah)
#### Post date: [February 21, 2021, 4:36pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/1 "2021-02-21T16:36:15Z")

</div>

**how does the time system work?**

assume it takes 10 seconds for you to fire a gun to a monster 10 tiles away. that monster’s movement speed is 1 tile every 13 seconds. then how many shots can you take before the monster can close in on you?

how does the game deal with uneven actions? do you get “free” turns if you are faster?

---

<div class="post-metadata">

### Author: ![PALU](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@PALU](https://discourse.cataclysmdda.org/u/PALU)
#### Post date: [February 21, 2021, 4:45pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/2 "2021-02-21T16:45:30Z")

</div>

The game uses 1 second ticks, but actions can take longer in which case you spend your action and the enemy spend their action. Once your action has been spent the next turn starts, X ticks later. Enemy attacks can interrupt your action.  
If movement speed isn’t a multiple/divisor of tiles per tick I believe the any extra time left over from the previous action gets used as a bonus to the next tick.

---

<div class="post-metadata">

### Author: ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)
#### Post date: [February 21, 2021, 4:52pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/3 "2021-02-21T16:52:52Z")

</div>

Everything has a speed, and a movement pool specified in movement points. When the movement pool reaches 0 or less than that, their turn ends, and it moves onto the next creature.

Each action takes some amount of movement points, which are then subtracted from the movement pool of a creature. While the creature still has movement points, it can continue to take actions.

At the beginning of each turn, a creature has it’s speed added to it’s movement pool. If it’s movement pool is still negative or 0, it’s turn is skipped.

So, in your scenario, both creatures have a speed of 100, and a movement pool of 100.  
The monster moving 1 tile costs 100 \* 13 movement points, and you firing and aiming the gun costs 100 \* 10 movement points.  
You fire the gun on your first turn, and the monster moves one tile on it’s first turn.  
You then have 9 turns skipped while you recover your movement points, and shoot the monster. The monster monster also skips these nine turns, and you can take another action while the monster is still 3 turns in the hole.

In total, it will take the monster 130 turns to reach you, meaning you can fire your gun 13 times.  
If you are faster you can, in extreme cases, perform multiple actions per turn, and in less extreme ones, perform multiple actions more quickly, because you both go less negative from performing an action, and recover more quickly.

---

<div class="post-metadata">

### Author: ![Valase](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valase/32/6972_2.png) [@Valase](https://discourse.cataclysmdda.org/u/Valase)
#### Post date: [February 21, 2021, 4:54pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/4 "2021-02-21T16:54:05Z")

</div>

> [@wrathofgomorrah](#):
>
> how does the game deal with uneven actions? do you get “free” turns if you are faster?

I’ve described this in detail over in an other topic…:

> [@Have Zombies' speed been increased?](https://discourse.cataclysmdda.org/t/have-zombies-speed-been-increased/25431/5):
>
> > [@Have Zombies' speed been increased?](https://discourse.cataclysmdda.org/t/have-zombies-speed-been-increased/25431/3):
> >
> > By the way, how does the movement system work?
> 
> To my understanding:  
> A “turn”, equal to an ingame second.  
> Moving from one tile to another does cost move points (well, all actions, really).  
> Different terrain have different costs, as seen by the “Move cost” value if you look at a terrain (default keys: `x` or `;`).  
> All beings in the game has something that (for this explanation) we will call a “move point account”… Each turn that passes will set the being’s account to the current speed value and subtract the cost of the action taken.  
> If the player’s character move point account reaches 0 or he “ends” the turn (by pressing `5` or `.`), the next turn will start and - in case that the player’s character made an action that takes up more move points than it had on its account before the turn ended - substracts the remainder of the move cost from the account.  
> The move/action only finishes or gets executed if its remaining cost is zero.
> 
> Since I’ve explaind that very complicated, let’s take an example:
> 
> > **Mathematical example**
> >
> > Disclaimer: It’s possible that I’ve mixed up a few things, like the order or that actions would take place before the turn ends… But nonetheless, it should be accurate in its base…
> > 
> > ```
> > Start of a fresh turn...
> > Acc = Character's move Account: 100
> > Speed = Character's base Speed: 100
> > Cost = Move cost of the ground: 100
> > 
> > Character gets ordered to move one tile...
> > Acc = Acc - Cost = 0
> > Turn ends (character hasn't moved yet).
> > 
> > New turn beginns.
> > Acc = Speed = 100
> > Acc = Acc - (remaining) Cost (which is 0) = 100
> > Action done, character moves 1 tile.
> > 
> > Waiting for the next order.
> > 
> > ```
> > 
> > Now let’s add in a few more things: The `Base Move Cost` as shown in the character sheet (`@`) and also two monsters, a fast one and a slow one.
> > 
> > ```
> > Start of a fresh turn...
> > Cost = Move cost of the ground: 100
> > C_Acc = Character's move Account: 100
> > C_Bmc = Character's Base Move Cost: 106
> > C_Speed = Character's base Speed: 100
> > FZ_Acc = Fast Zombie's move Account: 150
> > FZ_Speed = Fast Zombie's Speedt: 150
> > SZ_Acc = Slow Zombie's move Account: 95
> > SZ_Speed = Slow Zombie's Speed: 95
> > 
> > Character gets ordered to move one tile...
> > Actual move cost = (Cost / 100) * (C_Bmc / 100) * 100 = 106
> > C_Acc = C_Acc - Actual move cost = -6
> > Character's remaining cost = 6
> > Character's account reached 0 and it didn't move.
> > Character did all it could, now monsters move...
> > 
> > Fast Zombie tries to move towards player...
> > FZ_Acc = FZ_Acc - Cost = 150 - 100 = 50
> > Fast Zombie's remaining cost = 0
> > The fast Zombie still has points left in his account and no remaining cost...
> > Fast Zombie moves a tile.
> > Fast Zombie tries to move towards player, again...
> > FZ_Acc = FZ_Acc - Cost = 50 - 100 = -50
> > Fast Zombie's remaining cost = 50
> > 
> > Slow Zombie tries to move towards player...
> > SZ_Acc = FZ_Acc - Cost = -5
> > Slow Zombie's remaining cost = 5
> > Slow Zombie didn't move.
> > 
> > All accounts reached 0, turn ends.
> > Moved tiles: Character: 0, Fast Zombie: 1, Slow Zombie: 0
> > 
> > New turn beginns.
> > C_Acc = C_Speed = 100
> > FZ_Acc = FZ_Speed = 150
> > SZ_Acc = SZ_Speed = 95
> > 
> > C_Acc = C_Acc - Character's remaining cost (which is 6) = 94
> > Action done, character moves 1 tile.
> > Waiting for the next order...
> > 
> > Let us assume it should move another tile...
> > C_Acc = C_Acc - Actual move cost = 94 - 106 = -12
> > Character's remaining move cost = 12
> > 
> > Character's done, let's move the monsters...
> > FZ_Acc = FZ_Acc - Fast Zombie's remaining cost = 150 - 50 = 100
> > Fast Zombie moves one tile...
> > FZ_Acc = FZ_Acc - Cost = 0
> > Fast Zombie (technically) moves another tile...
> > 
> > SZ_Acc = SZ_Acc - Slow Zombie's remaining cost = 95 - 5 = 90
> > Slow Zombie moves one tile...
> > SZ_Acc = SZ_Acc - Cost = 90 - 100 = -10
> > Slow Zombie's remaining cost = 10
> > 
> > Turn end...
> > Total tile's moved: Character: 1, Fast Zombie: 2 (or 3), Slow Zombie: 1
> > 
> > And so on, and so forth...
> > 
> > ```

---

<div class="post-metadata">

### Author: ![wrathofgomorrah](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wrathofgomorrah/32/10850_2.png) [@wrathofgomorrah](https://discourse.cataclysmdda.org/u/wrathofgomorrah)
#### Post date: [February 22, 2021, 3:19pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/5 "2021-02-22T15:19:24Z")

</div>

thanks.

so technically the world freezes until you use up you action points? in your turn you can throw 5 stones if you have the action points. but the the rest of the game is still waiting for your turn to finish?

---

<div class="post-metadata">

### Author: ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)
#### Post date: [February 22, 2021, 3:46pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/6 "2021-02-22T15:46:38Z")

</div>

Yes. Try turning on speedydex, and debug in a couple hundred dexterity (it’s an easy way to get a lot of free move points) to examine this behaviour.

---

<div class="post-metadata">

### Author: ![Valase](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valase/32/6972_2.png) [@Valase](https://discourse.cataclysmdda.org/u/Valase)
#### Post date: [February 22, 2021, 4:03pm UTC](https://discourse.cataclysmdda.org/t/turn-time-system-algorithm/25955/7 "2021-02-22T16:03:02Z")

</div>

> [@wrathofgomorrah](#):
>
> so technically the world freezes until you use up you action points?

> [@anothersimulacrum](#):
>
> Try turning on speedydex, and debug in a couple hundred dexterity […]

Yes, or just tweak the config file. For one of my debugging/test runs I couldn’t set the dexterity that high (as that would mess with other things), so I’ve made these changes to the file:

```auto
  {
    "type": "EXTERNAL_OPTION",
    "name": "SPEEDYDEX_MIN_DEX",
    "stype": "int",
    "value": -1
  },
  {
    "type": "EXTERNAL_OPTION",
    "name": "SPEEDYDEX_DEX_SPEED",
    "stype": "int",
    "value": 21474836
  }

```

Just… don’t try to build anything that is built quickly, as it will bug the game out.  
Also, some actions (like reading, crafting, building and waiting, among others) that require under one turn or partial turns _ **will** _ use up / end on a full turn. This is done by design.
