title: Issue with Python implementation of Kruskal's maze algorithm
body: <p>I decided to make a variable-size binary tree maze generator.  I am trying to use Kruskal's maze algorithm, and I need to create a program that sees if there is a way for the player to get from cell x to cell y.  I was having trouble figuring out the maze solving.  I decided to implement a maze solver into the binary tree generator, and I have the basics but it's having some issues I can't figure out.</p>
  <p>It starts in the middle of the first cell then randomly chooses a direction and tries to go forward to where the wall may or may not be, and if it isn't a possible move it tries again in another random direction.  Since I made the spaces in the walls simply but drawing them over in white, I had to create a list of every acceptable wall to pass through.</p>
  <p>My current issue is that it cannot go vertically twice for some reason, but it (usually) has no problem going horizontally twice.  Any ideas?</p>
  <pre><code>from turtle import *
  import random
  
  def online(y,z):
    first = z[0]
    second = z[1]
    firstx = first[0]
    firsty = first[1]
    secondx = second[0]
    secondy = second[1]
    if firstx &lt;= y[0] &lt;= secondx and firsty &gt;= y[1] &gt;= secondy:
      return(True)
    elif firstx &lt;= y[0] &lt;= secondx and firsty &lt;= y[1] &lt;= secondy:
      return(True)
    elif firstx &gt;= y[0] &gt;= secondx and firsty &gt;= y[1] &gt;= secondy:
      return(True)
    elif firstx &lt;= y[0] &lt;= secondx and firsty &gt;= y[1] &gt;= secondy:
      return(True)
  
  speed(0)
  gridsize = 4
  cellsize = 50
  hideturtle()
  
  cango = []
  
  for i in range(4):
    a = pos()
    forward(gridsize*cellsize)
    b = pos()
    x = (a,b)
    left(90)
  goto(0,0)
  for i in range(gridsize):
    forward(cellsize)
    left(90)
    a = pos()
    forward(gridsize*cellsize)
    b = pos()
    x = (a,b)
    forward(-gridsize*cellsize)
    seth(0)
  goto(0,0)
  seth(90)
  for i in range(gridsize):
    forward(cellsize)
    right(90)
    a = pos()
    forward(gridsize*cellsize)
    b = pos()
    x = (a,b)
    forward(-gridsize*cellsize)
    seth(90)
    
  color(&quot;white&quot;)
  pensize(2)
  seth(270)
  a = pos()
  forward(cellsize)
  b = pos()
  x = (a,b)
  forward(-cellsize)
  seth(0)
  
  
  choices = (1,2)
  for i in range(gridsize):
    choices = (1,2) #Choice 1 cuts the right wall and choice 2 cuts the bottom wall
    for i in range(gridsize):
      a = int(pos()[0])
      b = int(pos()[1])
      #if the x value is all the way on the right, force the choice to cut the bottom
      if a == (gridsize-1)*cellsize or a == (gridsize-1)*cellsize-1:
        x = 2
      #if the y value is all the way on the bottom, force the choice to cut the right
      elif b == cellsize or b == cellsize-1:
        x = 1
      else:
      #if not at x or y max choose randomly between cutting right and cutting down
        x = random.choice(choices)
      #cut right
      if x == 1:
        penup()
        seth(0)
        forward(cellsize)
        right(90)
        pendown()
        a = pos()
        forward(cellsize)
        b = pos()
        x = a,b
        cango.append(x)
        forward(-cellsize)
        seth(0)
      #cut bottom
      elif x == 2:
        penup()
        seth(270)
        forward(cellsize)
        seth(0)
        pendown()
        a = pos()
        forward(cellsize)
        b = pos()
        x = a,b
        cango.append(x)
        penup()
        seth(90)
        forward(cellsize)
        seth(0)
    penup()
    seth(180)
    forward(cellsize*gridsize)
    seth(270)
    forward(cellsize)
    seth(0)
  speed(3)
  showturtle()
  color(&quot;red&quot;)
  goto(25,175)
  penup()
  print(cango)
  pensize(4)
  for i in range(1000):
      if pos() == (175.0,0.0):
          pensize(10)
          pencolor(&quot;green&quot;)
          break
      direction = random.randint(1,4)
      penup()
      if direction == 1:
          seth(0)
      elif direction == 2:
          seth(90)
      elif direction == 3:
          seth(180)
      else:
          seth(270)
      penup()
      forward(25)
      nohit = True
      for i in cango:
        if online(pos(),i) == True:
            nohit = False
        x = i[0]
        y = i[1]
        #if x[0] == pos()[0] and x[1] == pos()[1] or y[0] == pos()[0] and y[1] == pos()[1]:
          #nohit = True
      if nohit == False:
        backward(25)
        pendown()
        forward(50)
      else:
        backward(25)
  </code></pre>
  <hr />
  <h3>Solved</h3>
  <p>If anyone runs into similar problems, my issue came from the fact that python turtle isn't 100% accurate when defining points, due to this my points were sometimes things like (24.999999991,100) and I ended up forcing them to be integers and for my program I was only working with multiples of 5's so for every point I tested if anything was a 4 or a 9 and if so I added 1.</p>