Strengths = any size room, hallway or tile can be used
since collision is used to ‘cull’ bad rooms, a border can be established to control a build area geometry
weakness at the moment/areas I need help
1.can’t use random.seed correctly at the moment to always make the same maze from the same conditions.
2.having trouble connecting adjacent areas together (like joining two hallways that are growing from diff directions)
3.density - Thinking maybe after maze is ‘landlocked’ (no open places to build) - try replacing I sections (hallways)
- landlocking early (too many dead end caps or intersecting paths)
with T’s and rooms.
Maze Generator
import bge
from mathutils import Vector
import random
def multi_delete(list_, args):
indexes = sorted(list(args), reverse=True)
for index in indexes:
try:
del list_[index]
except:
break
return list_
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
if 'Seed' not in own:
random.seed ="Dug"
if 'Choices' not in own:
own['Choices']=[]
pieceList = ["1","1","1","2","3","1","1","1"]
choice = random.randint(0, 7)
piece = own.scene.addObject(pieceList[choice],own,0)
piece['Spawner']=own.parent
else:
for objects in own.scene.objects:
if 'CP' in objects:
for objects2 in own.scene.objects:
if 'CP' in objects2:
if objects2!=objects:
if objects.getDistanceTo(objects2)<.25:
if objects2!=own:
objects2['No']=True
if objects!=own:
objects2['No']=True
CPL =[]
for objects in own.scene.objects:
if 'CP' in objects:
if 'No' not in objects:
if objects.name!="Map":
CPL.append(objects)
for objects in CPL:
if own['E']>=1:
pieceList = ["1","1","1","2","3","1","1","4"]
choice = random.randint(0, 7)
piece = own.scene.addObject(pieceList[choice],objects,0)
point = Vector(eval(objects['CP']))
point = objects.worldPosition+(objects.worldOrientation*po int)
piece.alignAxisToVect(piece.getVectTo(point)[1],0,1)
piece['Spawner']=objects
own['E']-=1
main()
kill overlapping rooms code*
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
Collision = cont.sensors['Collision']
if Collision.positive:
for objects in Collision.hitObjectList:
if objects!=own.parent['Spawner']:
if objects.parent:
if objects.parent!=own.parent['Spawner']:
if objects.parent!=own.parent:
if not own.parent.invalid:
for child in objects.parent.children:
if 'CP' in child:
if 'No' not in child:
for childz in own.parent.children:
if 'CP' in childz:
D = child.getDistanceTo(childz)
if D<.25:
break
own.scene.objects['Map']['E']+=1
own.parent.endObject()
break
else:
if not own.parent.invalid:
own.scene.objects['Map']['E']+=1
own.parent.endObject()
break
main()
it’s raw and prototypish at the moment.
Attachments
Non_repetitive_Random_Dungeon_DesignDocument2.blend (1.13 MB)