-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtank_lib.java
More file actions
52 lines (33 loc) · 1.15 KB
/
tank_lib.java
File metadata and controls
52 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.Date;
import java.util.Calendar;
public class tank_lib {
public static void log ( String in ) {
System.out.println ( miniTMS() + " - " + in );
}
/**
* tanks will be responded to within a set period, say 100 ms, so
* that even tanks on a bad network connection will not be hindered
* . This slows the whole simulation down to the advantage of the
* longest thinking tank, to a point
*/
public static int miniTMS () {
Date curr = new Date();
//System.out.println ( "Date info : " + curr.toString () );
Calendar now = Calendar.getInstance ();
int hour = now.get ( Calendar.HOUR );
int sec = now.get ( Calendar.SECOND );
int msec = now.get ( Calendar.MILLISECOND );
//System.out.println ( "from Cal(sec): " + sec );
//System.out.println ( "from Cal(msec): " + msec );
int mini = ((( hour*100) + sec ) *1000 ) + msec;
//System.out.println ( "combined : " + mini ) ;
return mini;
}
public static long randomRange ( int min, int max ) {
int diff = max-min;
double z=Math.random () *diff;
long zz = Math.round ( z ) +1;
System.out.println ( "made rand # : " + zz );
return ( zz) ;
}
};