summaryrefslogtreecommitdiff
path: root/specs/06.Demand.md
blob: b42348a228521a50a8912f69298a0a966ba01096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!--
    Hurry Curry! - a game about cooking
    Copyright 2024 Sofviic

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, version 3 of the License only.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

-->
# Demand

Every tick(?TODO: specify further), a probability is sampled from [the demand equation](#the-demand-equation),
that number is then multiplied by the [traffic coefficent](#traffic-coefficent),
that number is then multiplied by the [demand bias](#the-demand-bias),
that will give a probability on whether a customer will be spawned on this tick.

### The Demand Equation
$$\sin\left(3\sin\frac{\left(hour+offset\right)}{2}\right)+1$$
```c
demand = sin(3*sin((hour+offset)/2))+1
```
(always nonnegative below 2)

every day the `offset` will be offset by `[-1,1]` multiplied by the [sway coefficent](#sway-coefficent).
```c
offset += rand(-1,1) * sway
```

### The Demand Bias
Demand scale starts at 0%.
(from -50% to +50%)

every day the `bias` will be offset by `[-10,10]` multiplied by the [sway coefficent](#sway-coefficent).
(clamped to -50% & 50%).
```c
bias += rand(-10,10) * sway
bias = clamp(bias,-50,50)
```

### Traffic Coefficent
Usually 1%
can be changed by the host.

### Sway Coefficent
Usually 50%
can be changed by the host.