Adventurer #13
31 марта 2002

Exchange of experience - an unscientific Algorithm for Random Number (RND).

<b>Exchange of experience</b> - 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 taken  number (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:

From the authors - help: a description of the shell magazine.

From the authors - the contents of the new magazine.

From the authors - Forever young, or the Spectrum in the new millennium. Call Jam / XPJ to save the log ZX Power.

From the authors - The authors of the magazine.

Presentation - new game from Studio Stall - opener.

Presentation - the new font editor Hewly Font Editor.

Presentation - A new version of the music editor of Sound Tracker Pro.

Presentation - a program for optimization of black and white images skonverchennyh with a PC.

Presentation - ASCII graphics editor for directories in the TR-DOS.

Presentation - "Bard's Tale Merger Programm" - a program to manage shipments of the game Bard's Tale.

Interface - News from: Placebo, Brain- wave, Phantom Family, Volga Soft, Studio Stall, Gogin, Anarchia, Image Crew, Hackerz 'Design Software, Peters +, Fatal Snipe, Ellipse.

Interface - see what tusni are scheduled for Speccy freaks vtechenie year: Forever 3, ASCII ^ 2002, 2nd International Sinclair Sam days, Millenium 1902, Twilight Demoparty 2002, Syndeecate Demoparty 2002, Paradox 2002, CaFe 2002, Chaos Constructions 2002.

Interface - a letter reading rooms: NoViSeT / Brutal Creators, Di / LSg, Moroz1999, Shame / Madness Technology, Cannibal / Techno Lab.

Interface - "for the market to answer!" Russian language is so "Great and powerful", that well use it, unfortunately, is given not for everyone.

Interface - Overview of Windows like shells and systems for ZX Spectrum.

Interface - City of Dzerzhinsk and its Spectrum inhabitants.

Exchange of experience - How to write a 3D game such as DOOM.

Exchange of experience - Floyd-Steinberg method for converting images from a larger number of colors in the least.

Exchange of experience - an unscientific Algorithm for Random Number (RND).

Exchange of experience - Direct Programming General Sound.

Exchange of experience - work with the western disk systems MDOS and MD02.

Chaos Construction 2001 - an interview with Raid.

Chaos Construction 2001 - an interview with Stanly / Studio Stall.

Chaos Construction 2001 - an interview with Gogin (Hacker Smir).

Chaos Construction 2001 - an interview with the Constellation Team: Screamer, Kot, Justinas.

Chaos Construction 2001 - Interview with EYE-Q: Organism, Time Keeper, Mr. Wizard.

Chaos Construction 2001 - an interview with Justionas / Constellation.

Chaos Construction 2001 - an interview with the Moscow encoder Asman / Proxium.

Chaos Construction 2001 - intevyu with Vivid, Megus, Tiggr of Brain-Wave.

Chaos Construction 2001 - an interview with Stingrey and Steep from Izhevsk.

Chaos Construction 2001 - an interview with amizhnikom and organizer CC - Big Black.

Chaos Construction 2001 - an interview with the encoder from Ulyanovsk Faster / TNL.

Chaos Construction 2001 - an interview with Cyberfreak (mooh).

Chaos Construction 2001 - an interview with Ming spektrumistom Equator / PHD.

Chaos Construction 2001 - mini interview with Kano.

Chaos Construction 2001 - an epic dispute: Vivid VS Sairoos, Chanks VS Multicolor, Dogma VS Triptomine Dream.

Chaos Construction 2001 - an interview with Maddy and Drv53b6 of the Phantom Family.

Chaos Construction 2001 - an interview with the Paracels and Sairoos of Placebo.

Chaos Construction 2001 - an interview with Pheel and EA from Antares.

Chaos Construction 2001 - continuation of the epic dispute between megakoderami Vivid and Sairoos.

Chaos Construction 2001 - a detailed report from the CPU.

Promotion - Another shattered dream or a description of the "500 games" - where truth and falsehood.

Promotion - the story creators of the game Star Glider 2 - Steven dunn / Software developement and design.

Promotion - Dizzy in a dungeon or omelette again did not turn out: short story for the game Dizzy Unterground.

Promotion - description of the game "Talisman" - RPG with elements of arcade.

Iron - the modified scheme IDE-HDD adapter.

Ottyag - clean ottyag: Children's self-made newspaper Bird Kar Kar. "

Ottyag - intro: We will not pull the cat by the balls and start with the run ...

Ottyag - Army Suxx or How zakosit from the army, if you are completely healthy.

Ottyag - the depth of a gloomy world outlook Maxima Magnet ...


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Our news - Friday 13 February ...
Exchange of experience - Graphic effect IRIS (plasma).

В этот день...   21 November