<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Maze.py</id>
	<title>Maze.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Maze.py"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;action=history"/>
	<updated>2026-05-20T10:03:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Maze.py&amp;diff=3569&amp;oldid=prev</id>
		<title>PeterHarding at 14:40, 19 September 2011</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;diff=3569&amp;oldid=prev"/>
		<updated>2011-09-19T14:40:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://performiq.com/kb/index.php?title=Maze.py&amp;amp;diff=3569&amp;amp;oldid=3104&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Maze.py&amp;diff=3104&amp;oldid=prev</id>
		<title>PeterHarding at 06:11, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;diff=3104&amp;oldid=prev"/>
		<updated>2009-07-19T06:11:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:11, 19 July 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l218&quot;&gt;Line 218:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 218:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Examples]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1480&amp;oldid=prev</id>
		<title>PeterHarding at 04:01, 25 February 2008</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1480&amp;oldid=prev"/>
		<updated>2008-02-25T04:01:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:01, 25 February 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;maze.py&lt;/del&gt;=&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Overview&lt;/ins&gt;=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A Python implementation of a maze generator which demonstrates the use of classes.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A Python implementation of a maze generator which demonstrates the use of classes.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1479&amp;oldid=prev</id>
		<title>PeterHarding at 04:00, 25 February 2008</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1479&amp;oldid=prev"/>
		<updated>2008-02-25T04:00:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:00, 25 February 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=maze.py=&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=maze.py=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;python &lt;/del&gt;implementation of a maze generator&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Python &lt;/ins&gt;implementation of a maze generator &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;which demonstrates &lt;/ins&gt;the use of classes&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Shows &lt;/del&gt;the use of classes &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in Python&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Script==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Script==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1478&amp;oldid=prev</id>
		<title>PeterHarding: New page: =maze.py=  A python implementation of a maze generator.  Shows the use of classes in Python  ==Script==  &lt;pre&gt; #!/usr/bin/env python  # $Id: maze.py,v 1.2 2000/12/12 19:45:01 tlavoie Exp t...</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Maze.py&amp;diff=1478&amp;oldid=prev"/>
		<updated>2008-02-25T04:00:10Z</updated>

		<summary type="html">&lt;p&gt;New page: =maze.py=  A python implementation of a maze generator.  Shows the use of classes in Python  ==Script==  &amp;lt;pre&amp;gt; #!/usr/bin/env python  # $Id: maze.py,v 1.2 2000/12/12 19:45:01 tlavoie Exp t...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=maze.py=&lt;br /&gt;
&lt;br /&gt;
A python implementation of a maze generator.&lt;br /&gt;
&lt;br /&gt;
Shows the use of classes in Python&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# $Id: maze.py,v 1.2 2000/12/12 19:45:01 tlavoie Exp tlavoie $&lt;br /&gt;
# $Log: maze.py,v $&lt;br /&gt;
# Revision 1.2  2000/12/12 19:45:01  tlavoie&lt;br /&gt;
# Last save before changing self.cells from a list to a dictionary.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
import sys, random&lt;br /&gt;
&lt;br /&gt;
def debug(x):&lt;br /&gt;
       pass&lt;br /&gt;
    #print &amp;#039;DEBUG: &amp;#039; + `x`&lt;br /&gt;
    #sys.stdout.flush()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MazeCell:&lt;br /&gt;
    &amp;quot;Class which defines a single cell in an n-dimensional maze&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def __init__ (self, size=4):&lt;br /&gt;
        self.numNeighbours = size  # will be changed when initialized by maze routine&lt;br /&gt;
        self.currState = 0        # 0 is out, 1 is frontier, 2 is in.  This is used for Prim&amp;#039;s algorithm.&lt;br /&gt;
        self.myNeighbours = []&lt;br /&gt;
        self.myWalls = {}&lt;br /&gt;
&lt;br /&gt;
    def stateFrontier(self):&lt;br /&gt;
        if(self.currState == 0):&lt;br /&gt;
            self.currState = 1&lt;br /&gt;
            return(1)   # used to decide whether or not maze code should increment  frontier counter.&lt;br /&gt;
        else:&lt;br /&gt;
            return(None)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def stateIn(self):&lt;br /&gt;
        self.currState = 2&lt;br /&gt;
        #  Incrementing &amp;quot;out&amp;quot; neighbours to &amp;quot;frontier&amp;quot; state will be handled by maze code, not here.&lt;br /&gt;
&lt;br /&gt;
class PrimMaze:&lt;br /&gt;
    &amp;quot;Creates a maze using Prim&amp;#039;s algorithm&amp;quot;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        self.frontiers = {}   # keep a dict of current frontier cells.&lt;br /&gt;
        self.cells = {}          # Store cell data here...&lt;br /&gt;
        self.opposites = {}        # create a list of &amp;quot;return&amp;quot; paths since cell walls map both ways.&lt;br /&gt;
        self.height = 0&lt;br /&gt;
        self.width = 0&lt;br /&gt;
&lt;br /&gt;
    def genPrim(self):&lt;br /&gt;
        currCell = random.randint(0,len(self.cells))&lt;br /&gt;
        self.cells[currCell].stateIn()&lt;br /&gt;
        debug(&amp;#039;cell &amp;#039; + `currCell` + &amp;#039; now IN&amp;#039;)&lt;br /&gt;
        for i in range(self.cells[0].numNeighbours):&lt;br /&gt;
            thisNeigh = self.cells[currCell].myNeighbours[i]&lt;br /&gt;
            if(thisNeigh != -1):&lt;br /&gt;
                if(self.cells[thisNeigh].stateFrontier() == 1):&lt;br /&gt;
                    self.frontiers[thisNeigh] = 1&lt;br /&gt;
                    debug(&amp;#039;cell &amp;#039; + `thisNeigh` + &amp;#039; now FRONTIER&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
        # Now, if there are any frontier cells, pick one, give it a path to an &amp;#039;IN&amp;#039; cell,  and make it IN also.&lt;br /&gt;
        while(len(self.frontiers) &amp;gt; 0):&lt;br /&gt;
            debug(&amp;#039;frontier cells: &amp;#039; + `self.frontiers`)&lt;br /&gt;
            nextCell = self.frontiers.keys()[random.randint(0,len(self.frontiers.keys()) -1)]&lt;br /&gt;
            debug(&amp;#039;cell &amp;#039; + `nextCell` + &amp;#039; is NEXT&amp;#039;)&lt;br /&gt;
            foundIn = 0&lt;br /&gt;
            # Now, pick a neighbour who&amp;#039;s IN, at random&lt;br /&gt;
            while(foundIn == 0):&lt;br /&gt;
                myPalRef = random.randint(0, len(self.cells[nextCell].myNeighbours) - 1)&lt;br /&gt;
                myPal = self.cells[nextCell].myNeighbours[myPalRef]&lt;br /&gt;
                if (myPal != -1):&lt;br /&gt;
                    debug(&amp;#039;cell &amp;#039; + `myPal` + &amp;#039; is my pal&amp;#039;)&lt;br /&gt;
                    if(self.cells[myPal].currState == 2):&lt;br /&gt;
                        foundIn = 1&lt;br /&gt;
&lt;br /&gt;
           # OK, we&amp;#039;ve got a route out to the existing maze. Move own state to IN&lt;br /&gt;
            self.cells[nextCell].stateIn()&lt;br /&gt;
            # break down walls&lt;br /&gt;
            # debug(&amp;#039;BAD WALL: &amp;#039; + `self.cells[nextCell].myWalls[myPal]`)&lt;br /&gt;
            debug(&amp;#039;BAD WALL1: &amp;#039; + `myPalRef`)&lt;br /&gt;
            debug(&amp;#039;BAD WALL2: &amp;#039; + `self.opposites[myPalRef]`)&lt;br /&gt;
            debug(&amp;#039;nextCell walls: &amp;#039; + `self.cells[nextCell].myWalls`)&lt;br /&gt;
            del self.cells[nextCell].myWalls[myPalRef]&lt;br /&gt;
            del self.cells[myPal].myWalls[self.opposites[myPalRef]]&lt;br /&gt;
&lt;br /&gt;
            # update OUT neighbours to FRONTIER&lt;br /&gt;
            currCell = nextCell&lt;br /&gt;
            for i in range(self.cells[0].numNeighbours):&lt;br /&gt;
                thisNeigh = self.cells[currCell].myNeighbours[i]&lt;br /&gt;
                if(thisNeigh != -1):&lt;br /&gt;
                    if(self.cells[thisNeigh].stateFrontier() == 1):&lt;br /&gt;
                        self.frontiers[thisNeigh] = 1&lt;br /&gt;
                        debug(&amp;#039;cell &amp;#039; + `thisNeigh` + &amp;#039; now FRONTIER&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
            # remove currCell from frontiers{}&lt;br /&gt;
            del self.frontiers[currCell]&lt;br /&gt;
&lt;br /&gt;
    def ortho(self, x=10, y=10):&lt;br /&gt;
        self.width = x&lt;br /&gt;
        self.height = y&lt;br /&gt;
&lt;br /&gt;
        # Define wall-mapping for this maze geometry.&lt;br /&gt;
        self.opposites[0] = 2&lt;br /&gt;
        self.opposites[1] = 3&lt;br /&gt;
        self.opposites[2] = 0&lt;br /&gt;
        self.opposites[3] = 1&lt;br /&gt;
&lt;br /&gt;
        # Create basic stuff prior to maze generation&lt;br /&gt;
        counter = 0&lt;br /&gt;
        for i in range(y):&lt;br /&gt;
            sys.stdout.flush()&lt;br /&gt;
            for j in range(x):&lt;br /&gt;
                self.cells[counter] = MazeCell(4)&lt;br /&gt;
&lt;br /&gt;
                # fill for neighbour to &amp;quot;north&amp;quot;&lt;br /&gt;
                if(i == 0):&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(-1)&lt;br /&gt;
                else:&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(counter - x)&lt;br /&gt;
&lt;br /&gt;
                # fill for neighbour to &amp;quot;east&amp;quot;&lt;br /&gt;
                if(j == (x - 1)):&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(-1)&lt;br /&gt;
                else:&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(counter + 1)&lt;br /&gt;
&lt;br /&gt;
                # fill for neighbour to &amp;quot;south&amp;quot;&lt;br /&gt;
                if(i == (y - 1)):&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(-1)&lt;br /&gt;
                else:&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(counter + x)&lt;br /&gt;
&lt;br /&gt;
                # fill for neighbour to &amp;quot;west&amp;quot;&lt;br /&gt;
                if(j == 0):&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(-1)&lt;br /&gt;
                else:&lt;br /&gt;
                    self.cells[counter].myNeighbours.append(counter - 1)&lt;br /&gt;
&lt;br /&gt;
                self.cells[counter].myWalls[0] = 1&lt;br /&gt;
                self.cells[counter].myWalls[1] = 1&lt;br /&gt;
                self.cells[counter].myWalls[2] = 1&lt;br /&gt;
                self.cells[counter].myWalls[3] = 1&lt;br /&gt;
&lt;br /&gt;
                # If we&amp;#039;re done in this loop, increment counter&lt;br /&gt;
                counter = counter + 1&lt;br /&gt;
&lt;br /&gt;
        ## Basic init done, now actually traverse this crap to build maze structure.&lt;br /&gt;
        self.genPrim()&lt;br /&gt;
&lt;br /&gt;
        # DEBUG: print out stuff for maze&lt;br /&gt;
##        print &amp;quot;Test: &amp;quot;+ `x` + &amp;#039; &amp;#039; + `y`&lt;br /&gt;
##        counter = 0&lt;br /&gt;
##        for i in range(y):&lt;br /&gt;
##            for j in range(x):&lt;br /&gt;
##                print &amp;#039;Neighbours: &amp;#039; +`len(self.cells[counter].myNeighbours)`&lt;br /&gt;
##                for z in range(len(self.cells[counter].myNeighbours)):&lt;br /&gt;
##                    sys.stdout.write(`self.cells[counter].myNeighbours[z]` + &amp;#039; &amp;#039;)&lt;br /&gt;
##                sys.stdout.write(&amp;#039;\n&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
##                counter = counter + 1&lt;br /&gt;
&lt;br /&gt;
    def printOrthoAscii(self):&lt;br /&gt;
        debug(&amp;#039;***PRINTING***   height: &amp;#039; + `self.height` + &amp;#039;   width: &amp;#039; + `self.width`)&lt;br /&gt;
        # print very top bit&lt;br /&gt;
        y = 0&lt;br /&gt;
&lt;br /&gt;
        sys.stdout.write(&amp;#039;+&amp;#039;)&lt;br /&gt;
        for j in range(self.width):&lt;br /&gt;
            if(self.cells[j].myWalls.has_key(0)):&lt;br /&gt;
                sys.stdout.write(&amp;#039;--+&amp;#039;)&lt;br /&gt;
            else:&lt;br /&gt;
                sys.stdout.write(&amp;#039;  +&amp;#039;)&lt;br /&gt;
        sys.stdout.write(&amp;#039;\n&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
        # Now, for each row, print sides, then bottoms&lt;br /&gt;
&lt;br /&gt;
        for i in range(self.height):&lt;br /&gt;
&lt;br /&gt;
            # sides&lt;br /&gt;
            sys.stdout.write(&amp;#039;|&amp;#039;)&lt;br /&gt;
            for j in range(self.width):&lt;br /&gt;
                if(self.cells[(i * self.width) + j].myWalls.has_key(1)):&lt;br /&gt;
                    sys.stdout.write(&amp;#039;  |&amp;#039;)&lt;br /&gt;
                else:&lt;br /&gt;
                    sys.stdout.write(&amp;#039;   &amp;#039;)&lt;br /&gt;
            sys.stdout.write(&amp;#039;\n&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
            # bottom&lt;br /&gt;
            sys.stdout.write(&amp;#039;+&amp;#039;)&lt;br /&gt;
            for j in range(self.width):&lt;br /&gt;
                if(self.cells[(i * self.width) + j].myWalls.has_key(2)):&lt;br /&gt;
                    sys.stdout.write(&amp;#039;--+&amp;#039;)&lt;br /&gt;
                else:&lt;br /&gt;
                    sys.stdout.write(&amp;#039;  +&amp;#039;)&lt;br /&gt;
            sys.stdout.write(&amp;#039;\n&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
def mazeBench():&lt;br /&gt;
       import profile,pstats&lt;br /&gt;
&lt;br /&gt;
       profile.run(&amp;#039;foo = PrimMaze()&amp;#039;)&lt;br /&gt;
       profile.run(&amp;#039;foo.ortho(25,25)&amp;#039;, &amp;#039;maze_prof&amp;#039;)&lt;br /&gt;
       foo.printOrthoAscii()&lt;br /&gt;
       sys.stdout.flush()&lt;br /&gt;
       p = pstats.Stats(&amp;#039;maze_prof&amp;#039;)&lt;br /&gt;
       p.sort_stats(&amp;#039;time&amp;#039;)&lt;br /&gt;
       p.print_stats()&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039;:&lt;br /&gt;
    foo = PrimMaze()&lt;br /&gt;
    foo.ortho(25,25)&lt;br /&gt;
    foo.printOrthoAscii()&lt;br /&gt;
    # mazeBench()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>