[VA] SRC #012a - Then and Now: Probability
|
10-11-2022, 07:07 PM
(This post was last modified: 10-11-2022 08:34 PM by rawi.)
Post: #23
|
|||
|
|||
RE: [VA] SRC #012a - Then and Now: Probability
Very nice and complicated problem. Thank you very much, Valentin.
Since I was not able to find the exact solution (like Fernando was, chapeau!) I did what statisticians do if brain is not enough: They replace brain by computer power and make simulations of the proplem. So I did with the DM42, which is not really vintage but vintage in programming. So I hope it is within the rules. I did 250.000 simulations (no typo, it took about 9 hours with power supply attached) and got in total 2 cases where the man ended at the bottom line of the triangle with a triangle size of 30 and 60 movements. This is 8E-6 which is not bad compared to the exact solution of 9.5 E-6. Here is the code: 00 { 203-Byte Prgm } 01 LBL „VA“ 02 „ROWS?“ 03 PROMPT 04 STO 00 05 „MOVES?“ 06 PROMPT 07 STO 01 08 „SIMUL?“ 09 PROMPT 10 STO 04 11 „SEED?“ 12 PROMPT 13 SEED 14 0 15 STO 05 16 STO 06 17 LBL 00 18 RCL 01 19 1000 20 / 21 STO11 22 1 23 STO 02 24 STO 03 25 STO+06 26 LBL 07 27 0 28 X<>F 29 RCL 03 30 1 31 X=Y? 32 SF 02 33 X=Y? 34 SF 03 35 X<>Y 36 RCL 02 37 X=Y? 38 SF 06 39 X=Y? 40 SF01 41 RCL 00 42 X=Y? 43 SF 04 44 X=Y? 45 SF 05 46 1 47 ENTER 48 ENTER 49 ENTER 50 FS? 01 51 + 52 FS? 02 53 + 54 FS? 03 55 + 56 FS? 04 57 + 58 FS? 05 59 + 60 FS? 06 61 + 62 +/- 63 7 64 + 65 1/X 66 RAN 67 X<>Y 68 / 69 IP 70 1 71 + 72 STO 08 73 0 74 STO 09 75 STO 10 76 LBL 08 77 1 78 STO+ 09 79 FS? IND 09 80 GTO 08 81 STO+ 10 82 RCL 10 83 RCL 08 84 X>Y? 85 GTO 08 86 1 87 XEQ IND 09 88 ISG 11 89 GTO 07 90 RCL 00 91 RCL 02 92 X=Y? 93 XEQ 09 94 RCL 06 95 RCL 04 96 X>Y? 97 GTO 00 98 RCL 05 99 RCL 04 100 / 101 RTN 102 LBL 09 103 1 104 STO+ 05 105 RTN 106 LBL 01 107 STO- 02 108 RTN 109 LBL 02 110 STO- 02 111 STO- 03 112 RTN 113 LBL 03 114 STO- 03 115 RTN 116 LBL 04 117 STO+ 02 118 RTN 119 LBL 05 120 STO+ 02 121 STO+ 03 122 RTN 123 LBL 06 124 STO+ 03 125 RTN 126 END Some explanations: Number: Register, L+Number: Line in program ROWS = Size of the triangle, e.g. 30 MOVES = Steps through the triangle, e.g. 60 SIMUL = Number of Simulations, e.g. 10000 SEED = Starting value of random number generator LBL 00: Start of simulation 01 Number of moves 02 Actual row position in the triangle 03 Actual column position in the triangle 06 Count of simulation LBL 07: Start of random walk through triangle, starting at the top (row 1, column 1) L28: Deleting flags; flags are used to denote those directions that are blocked starting with FLAG 1 for the upper left direction and then FlAGS 2 to 6 in clockwise direction. L46 – L64: Getting the number of directions the man can go (depending on position) L66: Random number for simulated walk 08: Random walk; 1: first possible, starting with upper left direction, 2-6 clockwise LBL 08: Getting the direction of the random walk L77-80: Skipping walks that are not allowed because of actual position 09: Direction 1-6 with starting 1 at upper left and 2-6 in a clockwise direction L90-93: Add 1 to Reg 05 if man ends at bottom LBL 09: Counting number of cases when random walk ends at the button of the triangle LBL 1 to LBL 6: Changing position in triangle. Row from top to bottom, columns from right to left |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)