Adventurer #13
31 марта 2002 |
![]() |
Exchange of experience - an unscientific Algorithm for Random Number (RND).

(C) Research / Volgasoft Scientific RND In my esteemed journal Spectrum Expert were laid out at least all the materials for self-writing wire, and even the cast wire engine ELITE. Now we learn how to generate pseudo-random numbers, and thus learn to write everything that happens inside the station (map of the galaxy and the names of the planets for example:). Enough will scrape a modest materialchik on likeness of artificial intelligence, and anyone can write the elite for two months: Main methods of generating random There are two numbers (and finally can - one): 1) the shift of floating point numbers (Sometimes with the admixture of shifted copies); 2) Papal method:) Tyk Now, consider the Pope's method: N [i +1] = mod (A * N [i], Z); - where mod = Modulo In other words: the next number = remainder of division of some constants A, multiplied by the previous number and the constant Z. That's it! On the finger assembly: constA EQU 137 ; Z EQU 8 N EQU 3; seed LD IX, array; array address LD (IX), N LD DE, constA; constant A LD B, 32; how many numbers to generate LL1 LD L, (IX) LD H, 0 PUSH DE CALL MUL_HL_DE; "A * N [i]" POP DE LD (IX +1), L; remainder of the division by 256, also known as the low byte INC IX DJNZ LL1 ; Ready The range of values generated numbers depends on the constants. In the example, Z = 256, A = 137. The values of Z - choose to taste (Actually, in this example would not hurt beginning to shift the result of multiplying right by one bit, and then take the remainder). The values of A are chosen so that the distribution was close to uniform. Usually takennumber (I forgot how their school was named - which are divided into themselves and one) such as 5, 7.13, 17, 19, 23, etc. Make sure that there was no zeros, otherwise the generator will rise. As I have said that numbers were obtained not only odd or even - to play with the translations. To generate numbers not only arranged in a specified number of bits (8 - 1 .. 255, 7 - 1 .. 127) will have to ruin a few numbers, or use multiple generators, for example the numbers 1 .. 191: LD A, n1 AND A, 1963 LD C, A LD A, n2 AND A, 127 ADD A, C LD (RESULT), A But how to generate the names of the planets in the elite - everyone knows - we take, we make an array of syllables (two letters) and we start the generator - one number corresponds to one syllable, and rolls the two-letter planet, four, six: By the way, like algorithm is used in calculating the checksum, the including at the same VG93. Well that's all: How to tell you about the current AI (or someone will tell in the pages Adventurer 'a) from you with each of the elite :))).
Other articles:
Similar articles:
В этот день... 1 April
Info Guide #13,
ACNews #50,
Avro News #01,
ACNews #47,
ACNews #40,
ACNews #29,
Black Metall #01,
ACNews #16,
Adventurer #13,
Polesse #19,
Subliminal Extacy #03,
ZX Pilot #37,
Always #03,
Born Dead #0G,
Odyssey paper #08,
Optron #26,
City #08,
Zodiac #02,
Polesse #05,
Nicron #108,
X-Magazine #10,
Nicron #82,
Energy #01,
Sorrow News #03,
Sorrow News #02,
Proton #27,
Think #08,
Wallpaper #01,
Spectrum Progress #03,
Spectrum Expert #02,
Micro #01,
X-Files #02,
Gorodok #05,
Deja Vu #04,
Anecdotes #01,
X-Files #02,
Maximum #35,
Impulse #01,
Spectrofun #01,
Faultless #07,
Breeze #06,
Nicron #27,
Echo #03,
Oberon #01,
Spectrofon #19,
On-Line #30,
Sinclair Town #01,
Sinclair Classic #04,
Spectrofon #04