[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-wiki-changes] PseudoRandomNumberGeneration
From: |
wiki |
Subject: |
[Wesnoth-wiki-changes] PseudoRandomNumberGeneration |
Date: |
Sun, 14 Nov 2004 11:07 +0100 |
UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.4
(KHTML, like Gecko) Safari/125.9
IP: 66.189.14.56
URI: http://wesnoth.slack.it/?PseudoRandomNumberGeneration
- - - - -
Index: PseudoRandomNumberGeneration
===================================================================
RCS file: /home/wesnoth/cvsroot/wikiroot/PseudoRandomNumberGeneration,v
retrieving revision 1.5
diff -u -r1.5 PseudoRandomNumberGeneration
--- PseudoRandomNumberGeneration 14 Nov 2004 03:18:54 -0000 1.5
+++ PseudoRandomNumberGeneration 14 Nov 2004 10:07:47 -0000
@@ -14,6 +14,122 @@
"ILLLEGITIMUS NON CARBORUNDUM"
.
+ Elvish Pillager: No need to bother with email, since this is a wiki. Behold:
+
+
################################################################################################
+ ################Pseudo-Random Number Generation Engine For
Multiplayer##########################
+
################################################################################################
+
+ #Don't use this, it's for internal use by other macros
+ #define GETNEXTNUMBER
+
+ #multiplying xrand by 421
+ {VARIABLE i 0}
+ {VARIABLE_OP temp_factor to_variable xrand}
+ [while]
+ [variable]
+ name=i
+ less_than=420
+ [/variable]
+ [do]
+ {VARIABLE_OP xrand add $temp_factor}
+ {VARIABLE_OP i add 1}
+ [/do]
+ [/while]
+
+ {VARIABLE_OP xrand add 2311}
+ [while]
+ [variable]
+ name=xrand
+ greater_than=32767
+ [/variable]
+ [do]
+ {VARIABLE_OP xrand add -32768}
+ [/do]
+ [/while]
+ #enddef
+
+ [event]
+ name=turn 2
+ {VARIABLE xrand 0}
+ [store_unit]
+ [filter]
+ [/filter]
+ variable=units
+ [/store_unit]
+ {FOREACH units i}
+ {VARIABLE_OP temp to_variable units[i].hitpoints}
+ {VARIABLE_OP xrand add $temp}
+ {NEXT i}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {GETNEXTNUMBER}
+ {CLEAR_VARIABLE temp}
+ {CLEAR_VARIABLE units}
+ [/event]
+
+ #Instead of {RANDOM 0..155}, use {PSEUDORANDOM 156}. This is the only way to
use it.
+ #You can use {VARIABLE_OP random add X} afterwards to get a higher range.
+ #define PSEUDORANDOM NUMBER
+ {GETNEXTNUMBER}
+ {VARIABLE_OP random to_variable xrand}
+
+ {VARIABLE_OP temp format ({NUMBER})}
+ [if]
+ [variable]
+ name=temp
+ less_than=33
+ [/variable]
+ [then]
+ #making temp equal {NUMBER}x1024
+ {VARIABLE i 0}
+ {VARIABLE temp 0}
+ [while]
+ [variable]
+ name=i
+ less_than={NUMBER}
+ [/variable]
+ [do]
+ {VARIABLE_OP temp add 1024}
+ {VARIABLE_OP i add 1}
+ [/do]
+ [/while]
+
+ {VARIABLE_OP temp2 to_variable temp}
+ {VARIABLE_OP temp2 multiply -1}
+ [while]
+ [variable]
+ name=temp
+ less_than=$random
+ [/variable]
+ [do]
+ {VARIABLE_OP random add $temp2}
+ [/do]
+ [/while]
+ [/then]
+ [/if]
+
+ [while]
+ [or]
+ [variable]
+ name=random
+ greater_than={NUMBER}
+ [/variable]
+ [/or]
+ [or]
+ [variable]
+ name=random
+ equals={NUMBER}
+ [/variable]
+ [/or]
+ [do]
+ {VARIABLE_OP random add -{NUMBER}}
+ [/do]
+ [/while]
+ #enddef
||See Also||
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/13
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration,
wiki <=
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/14
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/15
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/15
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/15
- [Wesnoth-wiki-changes] PseudoRandomNumberGeneration, wiki, 2004/11/16