Metrics
0
Watch 22 Star 47 Fork 15

jollysone / mazePython

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
python+tkinter+pyinstaller开发的的迷宫小游戏,这个迷宫小游戏界面简洁明了,难度系数不大,适合少年儿童,还可以培养他们的耐心和自己动手的能力,正如只能看一次答案一样,让他们能够经得起考验,而不是追求结果。同时递归解出答案让他们明白其中的原理,享受过程化的体验。 spread retract

Clone or download
maze_room.py 1.31 KB
Copy Edit Web IDE Raw Blame History
jollysone authored 2018-03-19 09:31 . 最终版本
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: Jolly_Son
# 功能:迷宫的小格子
U_WALL = 1
R_WALL = 2
D_WALL = 4
L_WALL = 8
ALL_WALLS = 15
FRONT = 16
VISITED = 32
# 迷宫的小格子
class MazeRoom(object):
room = None
# 构造函数初始化
def __init__(self):
self.room = ALL_WALLS
# 清除格子
def clear(self):
self.room = ALL_WALLS
# 打破格子
def breakWall(self, wall):
self.room &= ~wall
# 代表有墙
def hasWall(self, wall):
if self.room & wall == 0:
return False
else:
return True
# 代表没有墙
def noWall(self,wall):
if self.room & wall == 0:
return True
else:
return False
# 访问这个格子
def visit(self):
self.room |= VISITED
# 返回是否已经访问了这个格子 访问了True 否则 False
def visited(self):
if self.room & VISITED == 0:
return False
else:
return True
# 设置在前面的格子
def setFront(self):
self.room |= FRONT
# 是否格子在前面
def isFront(self):
if self.room & FRONT == 0:
return False
else:
return True
# 获得这个格子
def getRoom(self):
return self.room

Comment ( 0 )

You need to Sign in for post a comment

Help Search

183227_9af5e6a8_1826025 111910_4d91f001_1826025