-
Notifications
You must be signed in to change notification settings - Fork 0
/
webmaze.py
61 lines (46 loc) · 1.49 KB
/
webmaze.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
import random
startNumber = 1
endNumber = 10000
roomNumberList = []
i = startNumber
while i <= endNumber:
roomNumberList.append(i)
i = i + 1
random.shuffle(roomNumberList)
enterRoom = roomNumberList[0]
print "enterRoom" + str(enterRoom)
exitRoom = roomNumberList[-1]
print "exitRoom" + str(exitRoom)
roomNumberPath = roomNumberList[:]
for each in roomNumberList:
doorList = []
try:
pathDoor = roomNumberPath.pop(1)
doorList.append(pathDoor)
except IndexError:
pass
randomDoor1 = random.randrange(startNumber,endNumber)
doorList.append(randomDoor1)
randomDoor2 = random.randrange(startNumber,endNumber)
doorList.append(randomDoor2)
room = "rooms/room" + str(each) + ".html"
file = open(room,"w+")
if each == enterRoom:
file.write("WELCOME TO THE MAZE<br />")
print "Enter " + str(each) + "."
if each == exitRoom:
file.write("YOU WIN!<br />")
print "Exit " + str(each) + "."
randomDoor3 = random.randrange(startNumber,endNumber)
doorList.append(randomDoor3)
a = 1
while a < endNumber:
b = random.randrange(0,1)
if b == 1:
random.shuffle(doorList)
a = a + 1
for door in doorList:
aHrefElement = '<a href="room' + str(door) + '.html">A door leads out of this room.</a>'
file.write(aHrefElement)
file.write("</br>")
file.close()