-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariable.py
executable file
·72 lines (66 loc) · 2.05 KB
/
variable.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import random
#from Actor import Player
#from util import getNewId
mapX=640/32
mapY=480/32
char = [[-1 for i in range(256)] for j in range(256)]
actors=[]
NOACT=0
ACTED=1
WAIT_KEY=2
WAIT=3
LAND=5
SEA=3
idList=[0 for i in range(1024)]
worldMap=[[0 for i in range(256)] for j in range(256)]
for i in range(256*256):
worldMap[random.randint(0,255)][random.randint(0,255)]=1
def worldInit(n):
def func(x,y):
s = worldMap[y + 1][x + 1] + worldMap[y + 1][x - 1] + worldMap[y + 1][x] + worldMap[y][x + 1] + worldMap[y][x - 1] + \
worldMap[y - 1][x + 1] + worldMap[y - 1][x] + worldMap[y - 1][x - 1]
if s == 0:
worldMap[y][x] = 0
elif s == 1:
worldMap[y][x] = 1
if random.randint(1, 100) < 100:
worldMap[y][x] = 0
elif s == 2:
worldMap[y][x] = 1
if random.randint(1, 100) < 100:
worldMap[y][x] = 0
elif s == 3:
worldMap[y][x] = 1
if random.randint(1, 100) < 100:
worldMap[y][x] = 0
elif s == 4:
worldMap[y][x] = 1
if random.randint(1, 100) < 50:
worldMap[y][x] = 0
elif s == 6:
worldMap[y][x] = 1
if random.randint(1, 100) < 10:
worldMap[y][x] = 0
elif s == 7:
worldMap[y][x] = 1
if random.randint(1, 100) < 0:
worldMap[y][x] = 0
elif s == 8:
worldMap[y][x] = 1
for x in range(256):
for y in range(256):
if worldMap[y][x]==LAND:
worldMap[y][x]=0
elif worldMap[y][x]==SEA:
worldMap[y][x]=1
for t in range(n):
for i in range(256-2):
for j in range(256-2):
x,y=i+1,j+1
func(x,y)
for x in range(256):
for y in range(256):
if worldMap[y][x]==0:
worldMap[y][x]=LAND
else:
worldMap[y][x]=SEA