多层迷宫生成中的maze_def.py

maze_def.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# create by 火苗999℃

# 多层迷宫
#标记
# 墙
NOWALL = 0x0e # 无墙
WALL = 0x01 # 有墙
WALL_NO_VISIT = 0x01 # 没访问过的墙
WALL_VISIT = 0x03 # 访问过的墙
STEEL = 0X05 # 不能打通的墙

# 格子
CELL = 0x10 # 单元格
CELL_NO_VISIT = 0x10 # 没访问过的格子
CELL_VISIT = 0x30 # 访问过的格子
CELL_VISIT_FLAG = 0X20 # 访问过标记
STAIRS_U = 0x40 # 楼梯上
STAIRS_D = 0x80 # 楼梯下
STAIRS_UD = 0xC0 # 楼梯上下
CELL_EXT_FLAG = 0X100 # 扩建标记
CELL_EXT = 0X110 # 扩建的没访问过的房间

# 方向
LR = 1 # 左右
FB = 2 # 前后
UD = 3 # 上下


LEFT = 'L'
RIGHT = 'R'
FORWARD = 'F'
BACKWARD='B'
UP = 'U'
DOWN = 'D'


class Grid:
def __new__(cls, *args, **kwargs):
return super().__new__(cls)

def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.u = 0
self.d = 0
self.l = 0
self.r = 0
self.f = 0
self.b = 0

def __str__(self):
return "x={},y={},z={}".format(self.name, self.age, self.sex)

def __del__(self):
return