Toggle menu
72
67
14
5K
1F616EMO Survival Server Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.


y5nw is a player on the server.

Personal bookmark

Notes

Note: This section is more or less written based on my own knowledge. Feel free to suggest corrections in my talk page.

Event chance calculation

For a one-shot event that fires with a probability of p checked at an interval of T (e.g. tree growth), the expected amount of time t it takes for the event to fire is E(t)=Tp.

Note that, in some definition tables in Minetest (e.g. ABMs), the probability is specified using the reciprocal of p.

Calculations: Let q:=1p be the probability of the event not firing at the next check.

E(t)=n=1(qn1(1q))(Tn)=(1q)Tn=1qn1n=(1q)Tn=1m=1nqn1=(1q)Tn=1m=nqm1=(1q)Tqn=1m=nqm=(1q)Tqn=1(m=0qmm=0n1qm)=(1q)Tqn=1(11q1qn1q)=(1q)Tqn=1qn1q=Tn=0qn=T11q=Tp

(Abandoned) Idea for prefix-notation syntax

For my railtour mod I considered using a simple prefix-notation syntax for filter expressions (although IMO filters have a low priority at the time of writing). A somewhat adequate prefix syntax can be made to sufficiently resemble infix notation used for mathematics. Consider the following example:

x >= 5

As an infix expression, this is parsed to something similar to ()(x,5) with :×𝔹.

However, given

F:X{{YX}Y},xFxFx:{XY}Y,ff(x),xXC:{X×YZ}{X{YZ}},fCfCf:X{YZ},Cf(x)(y):=f(x,y)

(i.e. C effectively performs function currying.)

The above expression can be parsed into Fx(C)(5). It can be checked that

=Fx(C)(5)=C(x)(5)=()(x,5)

It should be noted that this approach reaches its limitations when multiple "infix" operators are used, as in x >= y + 1, which is parsed into Fx(C)(y)(C+)(1). Evaluating this gives ()(x,Fy)(C+)(1) which does not have a sensible result.

The above issue can be avoided (albeit counterintuitively) by adding parentheses where appropriate, i.e. with x >= (y + 1) However, with the use of parentheses, a Lisp-based syntax à la (>= x (+ y 1)) appears more attractive as it also involves less function-related abstractions (which avoids issues arising from such abstractions; compare x >= 5 and 5 <= x with the custom prefix notation)