[VA] SRC #012a - Then and Now: Probability
|
10-10-2022, 11:33 PM
Post: #17
|
|||
|
|||
RE: [VA] SRC #012a - Then and Now: Probability
Many thanks, Valentin.
Here is my formula. Although I used Plus42, I made sure it does not use any of the Plus42 extensions, so that it can work on a vanilla 17B,27S or 19BII. P=Σ(T:1:N:1:0×(L(J:1)+L(K:1)+Σ(I:1: S:1:L(Q:IF(J=1:2:IF(K=1 OR K=J:4:6)))+L(Z:INT(RAN#×Q))+IF(Z=0:L(J:J+1):IF(Z=1:L(J:J+1)+L(K:K+1):IF(Z=2:IF(K=1:L(K:2):L(K:K-1)):IF(Z=3:IF(K=1:L(J:J-1):IF(K=J:L(J:J-1)+L(K:K-1):L(K:K+1))):IF(Z=4:L(J:J-1)+L(K:K-1):L(J:J-1))))))))+IF(J=R:1:0))÷N This works by taking enough samples (N, 10.000 for instance) of scenarios defined by random numbers, like a Monte-Carlo simulation. I initially considered brute force, e. g. trying every single possible scenario, but if you ignore the edge cases you have something like 6 possible moves ^ S possibilities, which is astronomical if S=60, not feasible... Now the weakness of my code is the random numbers generation. The 27S language only has RAN# (pseudo-random numbers between 0 and 1), has no SEED function, and I am well aware that using INT(RAND#*6) as a proxy for dice rolling is grossly wrong, biased towards lower numbers... I just don't see what else to do. With S=4 and R=5, with N big enough (e.g. 1 million, which takes literally minutes, even on high performance Plus42 - I don't dare to imagine how much time it would take on a real machine), I get mediocre results that tend to be somewhat close to 23/288. With S=30 and R=60 I get almost every time a probability of 0. Strange! It does not go very deep down the rows, numbers in the range of 10-20. The algorithm is simple: J is the row number (from 1 to R), K is the position within the row (from 1 to J, as row J has J positions). If we are at the edges (K=1 or K=J), special treatment arises: only 4 possible moves (even only 2 at the top of the pyramid), so only 4 integer choices for the random numbers: 0 for down-left, 1 for down-right, 2 for horizontal-left (or right if we are at the left edge). The general case adds 3 more choices: 3 for horizontal-right, 4 for up-left, 5 for up-right. J and K are updated accordingly, until S moves are done. Then if J=R 1 is sumed, otherwise 0. In the end P is the number of successful scenarios, just divide by N to get the probability. This is still an alpha version, I will try to improve it, especially on the random number generation... Cheers, Vincent |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 11 Guest(s)