My code is pretty long and I need help condensing it to make it more convenient. The code I have is suppose to do the set of instructions I commanded it to do on a fluke robot. I am using python. The robot is suppose to do the following code using it sensors. I need help condensing it.

EDIT:

My code: 

from Myro import *
from Graphics import *
init('/dev/tty.IPRE6-366079-DevB')

def markYellow(pic):
    for pix in getPixels(pic):
        r = getRed(pix)
        g = getGreen(pix)
        b = getBlue(pix)
        if r &gt; 200 and b &lt; 90 and g &gt; 150:
            setRed(pix,255)
            setGreen(pix,255)
            setBlue(pix,255)
        else:
            setRed(pix,0)
            setGreen(pix,0)
            setBlue(pix,0)

def pctMarked(pic):
    totalPixels = 0
    whitePixels = 0
    for pix in getPixels(pic):
        if getRed(pix) == 255:
            whitePixels = whitePixels + 1
        totalPixels = totalPixels + 1
    result = whitePixels / float(totalPixels)
    return result


def findAvgX(pic):
    pixelCount  = 0
    totalXCount = 0
    for pix in getPixels(pic):
        if getRed(pix) == 255:
            x = getX(pix)
            totalXCount = totalXCount + x
            pixelCount = pixelCount + 1
    avgX = totalXCount / float( pixelCount)
    return avgX


def turn():
    findAvgX(pic)
    if wallLocation &lt;= 85:
        turnLeft(1,0.25)
    elif ballLocation &gt;= 170:
        turnRight(1,0.25)


def celebrate():
    move(0.25,1)
    beep(1,800)
    beep(1,1600)
    beep(1,800)
    stop()

def main():
    p = takePicture()
    markYellow(p)
    pctMarked(p)
    while pctMarked(pic) &lt; 0.2: 
        rotate(1,1)
        p = takePicture()
        markYellow(p)
        pctMarked(p)
    turn()
    while getObstacle('center')&gt; 1000: # I'm not sure about the number. We can test it tomorrow
        forward(1,1)
    celebrate()



Question: How can I draw these pictures with TikZ?
Answer: How about this:

\documentclass[tikz,border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{%
  zeroarrow/.style = {-stealth,dashed},
  onearrow/.style = {-stealth,solid},
  c/.style = {circle,draw,solid,minimum width=2em,
        minimum height=2em},
  r/.style = {rectangle,draw,solid,minimum width=2em,
        minimum height=2em}
}

\begin{document}

\begin{tikzpicture}[node distance=1cm and 1cm]\footnotesize
   \node[c] (a) {a};
   \node[c] (b) [below right=of a] {b};
   \node[c] (c) [below left=of b] {c};
   \node[c] (d) [below=of c] {d};
   \node[r] (final-one) [below right=of d,xshift=-2pt] {1};
   \node[r] (final-zero) [below left=of d] {0};

   \draw[onearrow] (a) -- (b);
   \draw[onearrow] (b) -- (final-one);
   \draw[onearrow] (c) -- (d); 
   \draw[onearrow] (d) -- (final-one);

   \draw[zeroarrow] (a) -- (c);
   \draw[zeroarrow] (c) -- (final-zero);
   \draw[zeroarrow] (b) -- (c);
   \draw[zeroarrow] (d) -- (final-zero);
\end{tikzpicture}

\begin{tikzpicture}[
level 1/.style={sibling distance=60mm},
level 2/.style={sibling distance=30mm},
level 3/.style={sibling distance=15mm},
level 4/.style={sibling distance=7mm}
]
\node[c] {a}
    child{ node[c]  {b} edge from parent[zeroarrow]
            child{ node[c] {c} 
                    child{ node[c] {d} 
                        child{ node[r] {0}}
                        child{ node[r] {0} edge from parent[onearrow]} 
                    }
                    child{ node[c] {d} edge from parent[onearrow]
                        child{ node[r] {0} edge from parent[zeroarrow]}
                        child{ node[r] {1}} 
                    }
            }
            child{ node [c] {c} edge from parent[onearrow]
                    child{ node[c] {d}  edge from parent[zeroarrow]
                        child{ node[r] {0}} 
                        child{ node[r] {0} edge from parent[onearrow]} 
                    }
                    child{ node[c] {d} edge from parent[onearrow]
                        child{ node[r] {0} edge from parent[zeroarrow]} 
                        child{ node[r] {1}} 
                    }
            }
    }
    child{ node[c] {b} edge from parent[onearrow]
            child{ node [c] {c} edge from parent[zeroarrow]
                    child{ node[c] {d} 
                        child{ node[r] {0}} 
                        child{ node[r] {0} edge from parent[onearrow]} 
                    }
                    child{ node[c] {d} edge from parent[onearrow]
                        child{ node[r] {0} edge from parent[zeroarrow]} 
                        child{ node[r] {1}} 
                    }
            }
            child{ node [c] {c} edge from parent[onearrow]
                    child{ node[c] {d} edge from parent[zeroarrow]
                        child{ node[r] {1}} 
                        child{ node[r] {1} edge from parent[onearrow]} 
                    }
                    child{ node[c] {d} edge from parent[onearrow]
                        child{ node[r] {1} edge from parent[zeroarrow]} 
                        child{ node[r] {1}} 
                    }
            }
    }
;
\end{tikzpicture}


\end{document}


You might want to fine-tune it a bit, e.g. if you want to have curved edges in the BDD. I had to manually shift the final 1 node in order for the edge from b being truly vertical.