From shasha@access1.cims.nyu.edu  Tue Nov 24 06:23:05 2009
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.80.107])
	by mail.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAOBN5kL009766
	for <shasha@mail.cims.nyu.edu>; Tue, 24 Nov 2009 06:23:05 -0500 (EST)
Received: from access1.cims.nyu.edu (access1.cims.nyu.edu [128.122.49.15])
	by mx.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAOBMwDg027719
	for <shasha@cs.nyu.edu>; Tue, 24 Nov 2009 06:22:58 -0500 (EST)
Received: from access1.cims.nyu.edu (localhost [127.0.0.1])
	by access1.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAOBMwm9021271;
	Tue, 24 Nov 2009 06:22:58 -0500 (EST)
Received: (from shasha@localhost)
	by access1.cims.nyu.edu (8.13.8+Sun/8.13.8/Submit) id nAOBMw3C021270;
	Tue, 24 Nov 2009 06:22:58 -0500 (EST)
Date: Tue, 24 Nov 2009 06:22:58 -0500 (EST)
From: Dennis Shasha <shasha@courant.nyu.edu>
Message-Id: <200911241122.nAOBMw3C021270@access1.cims.nyu.edu>
To: msmendelson@hotmail.com, shasha@cs.nyu.edu
Subject: Re: Maze program problem
X-Scanned-By: MIMEDefang 2.58 on 128.122.80.107
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (mx.cims.nyu.edu [128.122.80.107]); Tue, 24 Nov 2009 06:23:05 -0500 (EST)
Content-Length: 14279


Matthew,
When someone gives you software, please try to understand it before
using it. 
You have to do more than just add to it. 
I will give you some hints, but you will have to work to use them.


* winflag is undefined in the main program because it is a "local" variable
in the printscreen function. That means its value is not known outside
that function. To convey information outside, you have to return something.

* Also printscreen and the main routine do very similar things
in that they determine winning and losing.
That is bad practice. printscreen should do  screen work by itself.

* Finally, printscreen resets vpos and hpos. That's why the o doesn't move.

Best,
Dennis

#!/usr/bin/env python
#
# while statement
#
import time
import datetime

print "Your objective is to guide your 'o' through this maze. "
print "The stars that you see are actually spinning ninja stars. "
print "If you run into one, it will kill you. "
print "If you do not complete the maze in 60 seconds, the gates at the start and the "
print "finish will close and you will be trapped inside the maze to die of starvation. "
print "You have 5 chances to make it out of the maze alive. Good luck."
 
arr = "    ****************************************************************** \
*                                     *                              * \
*       **    *****            ***           ********      ********  * \
*   **       ***     ********   *****     *    ********      *****   * \
***     ***    ************       *****       **********             * \
******    **         ******          *************          ********** \
*****    ********                    ********       *******      ***** \
***     *********        ***          ***********  ************* ***** \
*****                 *************        ****** *************    *** \
***       *****************************                 *********    * \
***                   ***********                *****************   * \
********       ******        ******          **************         ** \
***********   ******************************************************** \
************                ********           *********             * \
**********************                ****                **********  "
hpos = 0 # horizontal position
vpos = 0  # vertical position
lifecount = 5
 
origscreen = [] # screen without a "o"
def formscreen():
   len = 70
   origscreen.append(arr)
 
def printscreen():
   screen = []
   mylen = len(origscreen)
   i = 0
   loseflag = 0
   winflag = 0
   hpos = 0
   vpos = 0
   while (i < mylen):
	x = origscreen[i]
	screen.append(x)
	if i == vpos:
		if (x[hpos] == "*"):
			loseflag = 1
	        if (x[vpos] == 14) and (x[hpos] == 69):
                        winflag = 1
		x = x[:hpos] + ("o") + x[hpos+1:]
		screen[i] = x
	i = i+1
   for s in screen:
	print s
   if loseflag == 1:
        lifecount = lifecount - 1
        if lifecount > 0:
            print "You died. Try again."
            hpos = 0
            vpos = 0
            i = 0
            loseflag = 0
        if lifecount == 0:
            print "You failed to complete the maze. That means you suck. Go waste someone else's time."
            i = mylen + 1
   if winflag == 1:
      print "Congratulations! For surviving my maze with " + lifecount + " lives, I will award you " + lifecount + ",000 awesomeness points."
      print "These points may not be real, but you can still brag about them if you wish."
      i = mylen + 1
      
totaltime = 0
formscreen()
i = 0
x = ""
while x != "s":
    printscreen()
    arr = (" ") + arr
    mybeforetime = time.time()
    # print mybeforetime
    x = raw_input("Please hit u(up), d(down), l(left), r(right), or s(stop):")
    myaftertime = time.time()
    diff = myaftertime - mybeforetime
    print ("You hit the letter: ") + x
    if x == "u":
	vpos = vpos-1
    if x == "d":
	vpos = vpos+1
    if x == "l":
        hpos = hpos-1
    if x == "r":
        hpos = hpos+1
    totaltime = totaltime + diff
    print totaltime
    if totaltime >= int(60):
        loseflag = 1
        if loseflag == 1:
            lifecount = lifecount - 1
        if lifecount > 0:
            print "You died. Try again."
        if lifecount == 0:
            print "You failed to complete the maze. That means you suck. Go waste someone else's time."
            x = s
        if winflag == 1:
            print "Congratulations! For surviving my maze with " + lifecount + " lives, I will award you " + lifecount + ",000 awesomeness points."
            print "These points may not be real, but you can still brag about them if you wish."
            x = s
    i=i+1
 
print totaltime
 
 
 
>From msmendelson@hotmail.com  Mon Nov 23 23:47:58 2009
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.80.107])
	by mail.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAO4lwlY023691
	for <shasha@mail.cims.nyu.edu>; Mon, 23 Nov 2009 23:47:58 -0500 (EST)
Received: from col0-omc4-s3.col0.hotmail.com (col0-omc4-s3.col0.hotmail.com [65.55.34.205])
	by mx.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAO4lu5W024406
	for <shasha@cs.nyu.edu>; Mon, 23 Nov 2009 23:47:56 -0500 (EST)
Received: from COL118-W3 ([65.55.34.200]) by col0-omc4-s3.col0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 23 Nov 2009 20:47:49 -0800
Message-ID: <COL118-W32949310E21172C17A349A89D0@phx.gbl>
Content-Type: multipart/mixed;
	boundary="_17045ff2-8282-452f-bbe6-f3e715ad86dd_"
X-Originating-IP: [216.165.45.113]
From: Matthew Mendelson <msmendelson@hotmail.com>
To: <shasha@cs.nyu.edu>
Subject: Maze program problem
Date: Mon, 23 Nov 2009 23:47:49 -0500
Importance: Normal
MIME-Version: 1.0
X-OriginalArrivalTime: 24 Nov 2009 04:47:49.0074 (UTC) FILETIME=[45E71320:01CA6CC1]
X-Scanned-By: MIMEDefang 2.58 on 128.122.80.107
X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-3.0 (mx.cims.nyu.edu [128.122.80.107]); Mon, 23 Nov 2009 23:47:58 -0500 (EST)
Status: R
Content-Length: 8266

--_17045ff2-8282-452f-bbe6-f3e715ad86dd_
Content-Type: multipart/alternative;
	boundary="_7f947e10-6495-40c2-81fa-9fd153778034_"

--_7f947e10-6495-40c2-81fa-9fd153778034_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Professor -=20

I'm doing well on my maze program=2C but I've come up with a few problems.
First of all=2C when the program reprints the screen=2C the "o" reappears i=
n the same place=2C so I can't tell if you get the desired result when you =
win.
Secondly=2C I tested it to see if it keeps the right time limit=2C and it d=
oes=2C but it tells me that "lifecount=2C" which I am using to keep track o=
f how many lives the player has left=2C is undefined.
I am attaching my program as it reads now. Please look it over and get back=
 to me as soon as possible with any suggestions you may have as to what I c=
an do or where I might find the solutions I need. Thank you very much!!

Regards=2C
Matthew
 		 	   		 =20
_________________________________________________________________
Windows 7: I wanted simpler=2C now it's simpler. I'm a rock star.
http://www.microsoft.com/Windows/windows-7/default.aspx?h=3Dmyidea?ocid=3DP=
ID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_myidea:112009=

--_7f947e10-6495-40c2-81fa-9fd153778034_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Verdana
}
--></style>
</head>
<body class=3D'hmmessage'>
Professor - <br><br>I'm doing well on my maze program=2C but I've come up w=
ith a few problems.<br>First of all=2C when the program reprints the screen=
=2C the "o" reappears in the same place=2C so I can't tell if you get the d=
esired result when you win.<br>Secondly=2C I tested it to see if it keeps t=
he right time limit=2C and it does=2C but it tells me that "lifecount=2C" w=
hich I am using to keep track of how many lives the player has left=2C is u=
ndefined.<br>I am attaching my program as it reads now. Please look it over=
 and get back to me as soon as possible with any suggestions you may have a=
s to what I can do or where I might find the solutions I need. Thank you ve=
ry much!!<br><br>Regards=2C<br>Matthew<br> 		 	   		  <br /><hr />Windows 7=
: I wanted simpler=2C now it's simpler. <a href=3D'http://www.microsoft.com=
/Windows/windows-7/default.aspx?h=3Dmyidea?ocid=3DPID24727::T:WLMTAGL:ON:WL=
:en-US:WWL_WIN_myidea:112009' target=3D'_new'>I'm a rock star.</a></body>
</html>=

--_7f947e10-6495-40c2-81fa-9fd153778034_--

--_17045ff2-8282-452f-bbe6-f3e715ad86dd_
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="mendelsonmazescreengame.py"

[encoded data, 5320 characters]
PWkrMQogCnByaW50IHRvdGFsdGltZQogCiAKIAo=

--_17045ff2-8282-452f-bbe6-f3e715ad86dd_--

