EnglishРусский  

   ..

   random.g

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\other\random.g
 1 /******************************************************************************
 2 *
 3 * Copyright (C) 2007, The Gentee Group. All rights reserved. 
 4 * This file is part of the Gentee open source project - http://www.gentee.com. 
 5 * 
 6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 8 * ACCEPTANCE OF THE AGREEMENT.
 9 *
10 * ID: Random 15.03.2007 1.0
11 *
12 * Author: pROCKrammer ,Pretorian
13 *
14 * Summary: Random library which creates random numbers. It's re writed version of Pretorians random class.
15 *			  His class works only on windows but my is multi-platform
16 *
17 ******************************************************************************/
18 
19 type random<protected>
20 {
21 	uint rand
22 	uint begin
23 	uint end
24 	datetime dt
25 }
26 
27 /*-----------------------------------------------------------------------------
28 *
29 * ID: random.init() 15.03.2007 1.0
30 * 
31 * Summary: Get first params
32 *  
33 -----------------------------------------------------------------------------*/
34 method random.init()
35 {
36 	this.dt.gettime()
37 	this.end=0xFFFFFFFE
38 	this.rand = ( this.dt.msec + this.dt.second + this.dt.minute ) * this.dt.hour  
39 }
40 
41 /*-----------------------------------------------------------------------------
42 *
43 * ID: random.randseed(uint b, uint e) 15.03.2007 1.0
44 * 
45 * Summary: Returns random number from b to e
46 *  
47 -----------------------------------------------------------------------------*/
48 method uint random.randseed(uint b, uint e)
49 {
50 	this.begin = b
51 	this.end = e
52 	return (this.rand=( 16807 * this.rand ) % 0x7FFFFFFF)%(this.end-this.begin+1)+this.begin 
53 }
54 /*-----------------------------------------------------------------------------
55 *
56 * ID: random.init 15.03.2007 1.0
57 * 
58 * Summary: Returns any number
59 *  
60 -----------------------------------------------------------------------------*/
61 method uint random.randseed()
62 {
63 	return (this.rand=( 16807 * this.rand ) % 0x7FFFFFFF)%(this.end-this.begin+1)+this.begin 
64 }
Редактировать