Monday, April 17, 2006

Quest Game Tasks



This week we will be working on multiple tasks to work to improve the controls and to make sure we understand the quest file.

Before we get started I want to look at the restrictions() method.

Task 1:


Edit the go() method to work for movement in all directions (north, south, east, west, up, and down).

Task 2:


Create your own world. It needs to contain 5 rooms and at 4 items. The player should be able to navigate around. These do not need to be part of your final game, just a basic world for practice.

Task 3:


You need to add a "Drop" command for dropping items from your inventory into the room.

Task 4:


You need to add a "commands" command for listing all legal commands. It should list only the primary commands and not all the variations.

You should have all of these tasks completed by the end of the week! On Friday we will be able to begin work on your actual projects.

Tuesday, April 04, 2006


def findspot(self,num,array,low,high):
mid=(low+high)/2
if high==low:
if num>array[low]:
return high
else:
return low
else:
if num return self.findspot(num,array,low,mid)
elif num>array[mid]:
return self.findspot(num,array,mid+1,high)
else:
return mid

def sort(self):

items = self.cards
sorts=[Card(),Card()]
done = 0
for i in items:
if done == 0:
sorts[0]=i
else:
spot=self.findspot(i,sorts,0,done)
sorts[spot:spot]=[i]
done=done+1
self.cards = sorts[:len(sorts)-1]

Wednesday, March 08, 2006

For today's project you need to create a function that takes an input of a string and a list. The list should contain all valid commands. The string is an input from the user. The function should return True if one of the words is in the commands list and False if it is not.

Create a test program with a list of commands.

bob

Friday, February 24, 2006

I'd like you to continue to work on the program from yesterday. If you have completed the basic form of it, work on adding a while loop to allow you to repeat. DO NOT USE RECURSION! If you are having trouble with any part, ask your classmates for help. Travis has already completed this using a while loop.

There is a discussion of the while loop in chapter 6 of BoP.

If you get this done, read the end of chapter 5 in HtTLaCS. Starting at 5.6. These talk about recursion and calculations. They give a couple of great examples of recursion. Section 5.8 gives us a great way to make sure the input for a function is correct. Now we can use this statement with any input to be sure that we are getting an integer. We can compare the type to the type of an integer. This doesn't affect this program as much, but can be very useful at a later time.

Thursday, February 23, 2006

Please finish up your program from yesterday. It should start with a welcome message, then ask for the type of shape. According to the shape given, it should give the area in a neatly formatted way. Don't forget to add comments!

If the user gives a shape that is not recognized, you should give a message listing the shapes that are valid and give them the opportunity to try again.

When you are done, save the file as: area_[name].py into the class "python\area programs\" folder. (replace [name] with your first name!)

As a bonus, add a while loop that allows you to find the area of multiple shapes.

You can also add abbreviations for the shapes so the user doesn't have to type the full name in. (But they should also be able to type the full name as well).

Once you are done, you may play around with some of the things you've been learning.

Tuesday, February 21, 2006

Create a function that will take an input of a number and then prints that number of blank lines.

After you have finished this project, open to HtTLaCS 4. We will take some time to talk about input so that you can complete yesterday's assignment.

Monday, February 20, 2006

Today we will be continuing our look at functions. We will be learning how to use conditional statements as well as how to receive input from the user.



Create a program that will greet a user, then ask for their name and age.
Then the computer will print a blank line for each year of their age and say good-bye using the name given at the beginning.

You will need to create a function for the blank lines.

When you have completed it, post the program on your blog. Be sure to use
 and 
tags in "Edit Html" mode so that I can see the indentations.

Friday, February 17, 2006

My haiku is good.
But your haiku it stinketh.
I am haiku king!
Today we will be continuing through BoP Chapter 4 and HtTLaCS Chapter 3. Go ahead and click on the link for BoP and we will pick up there.

Today we will be finishing much of the basics so that next week we can begin actually doing some projects.

Thursday, February 09, 2006

OK, one more day without me. . . We will talk next week about the things you have been doing and applying them. Today I want you to open up Guido again. I have a new project for you. Open the file "binaryAdd.wld" from the "python\gvr" folder.

This world gives two binary numbers (along 2nd and 3rd avenues). You need to write a program that will add these binary numbers and place the result on first avenue with no other beepers left. When done, place guido on the east side of the wall. After completing the program your answer should be: 110010100

When you have the program done, you can test it by doing this addition problem:
1101001
1001011

You should get this:
10110100

Once you get that, try changing your world so it will actually add more than two binary numbers (move the wall along the north.) You may have to carry multiple times. . .

If you are having troubles, here are a couple of hints. You will need to highlight the next section in order to read them. (In case you want to try without any accidental seeing of my algorithm.)

Hint 1:


















Hint 2:





OK, that was fun! Here is a real hint!

In order to do this I would create a couple of different stages. First I would take care of adding the columns, then of going through and taking care of any carrying.

If you can't get it from there, go ahead and look at hint 3.


Hint 3:

To add the columns you will want a definition that simply goes up collecting all beepers, then places them back at the bottom of the column. Do this until you reach the westward wall.

Hint 4:



Remember in binary you can only have a zero or a one. If any spot has a 2 it needs to be carried forward (leaving zero behind). Start at the far right, and check each spot to see if it needs to carry. (This can be another definition inside of a while loop.)
OK, well, after looking at your programs I see a couple of things they are missing. . .

First of all, they do not contain the two lines of comment at the beginning like they are supposed to, see previous post, the first two lines should start with #! and #.

Second is a misunderstanding of a splash screen. A splash screen is an image or message that fills up all or most of the screen while the actual program is loading. It should not be a scrolling message as everything should appear on the screen at once. I was looking for something that would display more like this:

Also, didn't sound like you actually got around to reading the the sections I assigned:
GvR - 18
HtTLaCS - 2
BoP - 4

Please read and comment upon!

Wednesday, February 08, 2006

Well, I just read through everyone's posts, and I found about what I expected. It took me a while to really understand what I was doing with the interface, I'm still not sure I completely understand it. . . But I'll give some ideas.

OK, first of all, when using IDLE there are 2 parts you have to think about. First is the basic interface you see first when you open the program. This interface allows you to run single commands, and test new things.

The other interface is more like a text editor, but with formatting and allows you to create and save modules (files). To get it open, go to file and new window. Now you can create your hello world program and save it to a file for later access.

To access and run the file you've created there are a couple of options:

The easiest one of these is to go to the run menu and select 'run module' (or hit f5)
We'll worry about other methods later, for now this should allow you to create and run files.

Another thing you may have noticed is that programs that have been shown have a couple of lines before the print command that don't seem to do anything, these are comments. These comments are not completely necessary, but have reasons. The first line should be:
"#! c:/python24/python -this line contains the directory of the interpreter

The second line should include the filename:
# helloworld.py

We'll also use comments in other places, but these are not necessary for as simply a program as we are creating now.

For your assignment today I'd like you to create a program that prints a splash screen (welcome screen). It should be at least 12 lines, though it can also include a couple blank lines. Try to make this welcome screen somewhat graphical and not just text (use symbols to draw it).

Once you have the program completed, please also read over:
GvR chapter 18
HtTlaCS chapter 2
BoP section 4


Please paste your program into your post for today. Also include any other comments about struggles you are having with the IDLE interface. And questions or comments from today's reading.


Have fun! Oh, and go to whittakersingapore.blogspot.com for pictures!

Sunday, February 05, 2006

OK, well, hopefully by now Aaron has arrived, but I'm not there! I would like you to look at the How to Think Like a Computer Scientist site again, re-read Chapter 1, hopefully it will make a little more sense now! After you have done that I want you to look through chapters 1-3 of Byte of Python. As you are doing this, open up IDLE from the Python folder in the Start menu. You can use this interface to try out some of the commands that are discussed in the sections. We will talk more about this as we work through this week.

I will try to post each day what I want you to do and try to give you some instruction. Please continue to post on your own blog with questions you might have for me about the things you are reading so I can address your struggles in my next post!

Also, please pray for a healthy labor and birth and a quick recovery!

Thursday, February 02, 2006

Three new parks to clean:

Park 1, Garbage needs to be left in North West Corner; Mom coming to South East

Park 2, Garbage left in South West; Mom in North East

Park 3, Garbage in South West; Mom in South West(beside pile)

Wednesday, February 01, 2006

Today we are going to finish playing with our mazes and make them work!

Tuesday, January 31, 2006

Has been fun reading all your entries, we have some very violent people here! A couple already plotting Guido's death! Check out other's blogs if you don't already!

Friday, January 27, 2006

Navigating the maze -
Bonus Challenge 1: Collect all beepers on maze2.wld
Bonus Challenge 2: Collect all beepers on maze2.wld and end at the exit
Bonus Challenge 3: Collect all beepers on maze3.wld

In order to complete Challenge 3 you may need to add some beepers to start in Guido's bag. (I needed 124)

Wednesday, January 25, 2006

Create a program to have Guido harvest this field. You may want to alter the code/algorithm that was suggested for Step 15 to make him do it in a quicker process.

After harvesting all the beepers, guido needs to bring them to the storage shed in the south west corner (1,1). He needs to drop all the beepers, then move to the east and turn around. When the program ends, Guido should be looking at the pile of beepers.

Robot 2 3 e
Beepers 3 3 1
Beepers 6 3 1
Beepers 7 3 1
Beepers 9 3 1
Beepers 11 3 1
Beepers 12 3 1
Beepers 13 3 1
Beepers 14 3 1
Beepers 16 3 1
Beepers 19 3 1
Beepers 22 3 1
Beepers 25 3 1
Beepers 27 3 1
Beepers 3 4 1
Beepers 4 4 1
Beepers 5 4 1
Beepers 8 4 1
Beepers 11 4 1
Beepers 12 4 1
Beepers 13 4 1
Beepers 16 4 1
Beepers 18 4 1
Beepers 19 4 1
Beepers 22 4 1
Beepers 23 4 1
Beepers 25 4 1
Beepers 27 4 1
Beepers 3 5 1
Beepers 5 5 1
Beepers 8 5 1
Beepers 10 5 1
Beepers 12 5 1
Beepers 13 5 1
Beepers 14 5 1
Beepers 16 5 1
Beepers 17 5 1
Beepers 18 5 1
Beepers 20 5 1
Beepers 22 5 1
Beepers 25 5 1
Beepers 26 5 1
Beepers 4 6 1
Beepers 5 6 1
Beepers 6 6 1
Beepers 7 6 1
Beepers 8 6 1
Beepers 10 6 1
Beepers 13 6 1
Beepers 15 6 1
Beepers 17 6 1
Beepers 20 6 1
Beepers 21 6 1
Beepers 23 6 1
Beepers 26 6 1
Beepers 3 7 1
Beepers 5 7 1
Beepers 6 7 1
Beepers 7 7 1
Beepers 8 7 1
Beepers 10 7 1
Beepers 11 7 1
Beepers 12 7 1
Beepers 14 7 1
Beepers 16 7 1
Beepers 18 7 1
Beepers 20 7 1
Beepers 21 7 1
Beepers 24 7 1
Beepers 26 7 1
Beepers 5 8 1
Beepers 6 8 1
Beepers 8 8 1
Beepers 11 8 1
Beepers 13 8 1
Beepers 16 8 1
Beepers 18 8 1
Beepers 19 8 1
Beepers 22 8 1
Beepers 23 8 1
Beepers 25 8 1
Beepers 27 8 1
Beepers 4 9 1
Beepers 5 9 1
Beepers 7 9 1
Beepers 8 9 1
Beepers 9 9 1
Beepers 11 9 1
Beepers 12 9 1
Beepers 15 9 1
Beepers 16 9 1
Beepers 17 9 1
Beepers 19 9 1
Beepers 21 9 1
Beepers 24 9 1
Beepers 26 9 1
Beepers 5 10 1
Beepers 7 10 1
Beepers 10 10 1
Beepers 11 10 1
Beepers 12 10 1
Beepers 15 10 1
Beepers 17 10 1
Beepers 19 10 1
Beepers 22 10 1
Beepers 23 10 1
Beepers 26 10 1
Beepers 4 11 1
Beepers 6 11 1
Beepers 8 11 1
Beepers 11 11 1
Beepers 13 11 1
Beepers 16 11 1
Beepers 19 11 1
Beepers 21 11 1
Beepers 24 11 1
Beepers 26 11 1
Beepers 4 12 1
Beepers 7 12 1
Beepers 9 12 1
Beepers 12 12 1
Beepers 15 12 1
Beepers 16 12 1
Beepers 17 12 1
Beepers 18 12 1
Beepers 20 12 1
Beepers 23 12 1
Beepers 24 12 1
Beepers 27 12 1
Beepers 3 13 1
Beepers 5 13 1
Beepers 8 13 1
Beepers 10 13 1
Beepers 11 13 1
Beepers 12 13 1
Beepers 14 13 1
Beepers 17 13 1
Beepers 18 13 1
Beepers 20 13 1
Beepers 21 13 1
Beepers 23 13 1
Beepers 25 13 1
Beepers 26 13 1
Beepers 3 14 1
Beepers 4 14 1
Beepers 6 14 1
Beepers 7 14 1
Beepers 9 14 1
Beepers 10 14 1
Beepers 13 14 1
Beepers 16 14 1
Beepers 19 14 1
Beepers 22 14 1
Beepers 25 14 1
Beepers 26 14 1
Beepers 3 15 1
Beepers 5 15 1
Beepers 7 15 1
Beepers 10 15 1
Beepers 13 15 1
Beepers 15 15 1
Beepers 18 15 1
Beepers 20 15 1
Beepers 21 15 1
Beepers 23 15 1
Beepers 26 15 1
Beepers 4 16 1
Beepers 6 16 1
Beepers 8 16 1
Beepers 10 16 1
Beepers 12 16 1
Beepers 13 16 1
Beepers 15 16 1
Beepers 18 16 1
Beepers 20 16 1
Beepers 22 16 1
Beepers 24 16 1
Beepers 27 16 1
Beepers 4 17 1
Beepers 5 17 1
Beepers 6 17 1
Beepers 8 17 1
Beepers 11 17 1
Beepers 13 17 1
Beepers 15 17 1
Beepers 17 17 1
Beepers 20 17 1
Beepers 22 17 1
Beepers 23 17 1
Beepers 24 17 1
Beepers 27 17 1
Beepers 4 18 1
Beepers 5 18 1
Beepers 7 18 1
Beepers 9 18 1
Beepers 10 18 1
Beepers 12 18 1
Beepers 14 18 1
Beepers 17 18 1
Beepers 20 18 1
Beepers 22 18 1
Beepers 23 18 1
Beepers 26 18 1
Beepers 4 19 1
Beepers 7 19 1
Beepers 9 19 1
Beepers 10 19 1
Beepers 12 19 1
Beepers 13 19 1
Beepers 15 19 1
Beepers 18 19 1
Beepers 20 19 1
Beepers 22 19 1
Beepers 24 19 1
Beepers 26 19 1
Beepers 5 20 1
Beepers 6 20 1
Beepers 8 20 1
Beepers 10 20 1
Beepers 13 20 1
Beepers 16 20 1
Beepers 18 20 1
Beepers 20 20 1
Beepers 21 20 1
Beepers 24 20 1
Beepers 26 20 1
Beepers 4 21 1
Beepers 6 21 1
Beepers 9 21 1
Beepers 12 21 1
Beepers 13 21 1
Beepers 15 21 1
Beepers 17 21 1
Beepers 20 21 1
Beepers 23 21 1
Beepers 24 21 1
Beepers 26 21 1
Beepers 4 22 1
Beepers 5 22 1
Beepers 8 22 1
Beepers 9 22 1
Beepers 10 22 1
Beepers 13 22 1
Beepers 16 22 1
Beepers 19 22 1
Beepers 21 22 1
Beepers 24 22 1
Beepers 27 22 1
Beepers 4 23 1
Beepers 6 23 1
Beepers 9 23 1
Beepers 10 23 1
Beepers 11 23 1
Beepers 14 23 1
Beepers 15 23 1
Beepers 17 23 1
Beepers 19 23 1
Beepers 22 23 1
Beepers 24 23 1
Beepers 27 23 1
Beepers 5 24 1
Beepers 8 24 1
Beepers 11 24 1
Beepers 12 24 1
Beepers 15 24 1
Beepers 18 24 1
Beepers 21 24 1
Beepers 22 24 1
Beepers 24 24 1
Beepers 27 24 1
Beepers 3 25 1
Beepers 5 25 1
Beepers 7 25 1
Beepers 8 25 1
Beepers 9 25 1
Beepers 10 25 1
Beepers 13 25 1
Beepers 16 25 1
Beepers 18 25 1
Beepers 21 25 1
Beepers 22 25 1
Beepers 23 25 1
Beepers 26 25 1
Beepers 5 26 1
Beepers 6 26 1
Beepers 8 26 1
Beepers 10 26 1
Beepers 13 26 1
Beepers 14 26 1
Beepers 17 26 1
Beepers 18 26 1
Beepers 19 26 1
Beepers 20 26 1
Beepers 23 26 1
Beepers 26 26 1
Beepers 3 27 1
Beepers 5 27 1
Beepers 7 27 1
Beepers 8 27 1
Beepers 9 27 1
Beepers 11 27 1
Beepers 14 27 1
Beepers 16 27 1
Beepers 19 27 1
Beepers 22 27 1
Beepers 25 27 1
Beepers 27 27 1

Tuesday, January 24, 2006

Guido Algorithimizes a problem and saves his home from a deadly storm.

Monday, January 23, 2006

Guido explores the universe!

Friday, January 20, 2006

Guido does his chores at home too! - Step 11-12

Thursday, January 19, 2006

OK, so now Guido learns to dance!

Challenge update: I've now lowered my line count to 20.

Wednesday, January 18, 2006

Challenge



robot 1 1 N
wall 1 1 N
wall 1 2 E
wall 2 2 N
wall 2 3 E
wall 3 3 N
wall 3 4 E
wall 4 4 N
wall 4 5 E
wall 5 5 N
wall 5 6 E
wall 6 6 N
beepers 1 2 1
beepers 2 2 1
beepers 2 3 1
beepers 3 3 1
beepers 3 4 1
beepers 4 4 1
beepers 4 5 1
beepers 5 5 1
beepers 5 6 1
beepers 6 6 1

Test World



Robot 1 2 E
Beepers 2 2 1
Beepers 12 2 1
Wall 12 2 E
Guido, Civil Servant of the Year, after spending the day cleaning up second street, strutted his stuff on the dance floor of the local dance club.

Monday, January 16, 2006

Guido goes to school!

Friday, January 13, 2006

Guido builds walls!

Thursday, January 12, 2006

Today we will be finishing looking at Chapter 1, then we will begin programming a robot!!

Wednesday, January 11, 2006

Welcome to Computer Programming!


Welcome to class! I've been looking forward to this class for the past 8 months ever since I learned I would be teaching it this semester. I hope you are as excited as I am! We will be learning new problem solving techniques and new ways to look at problems. We will also be learning a new language with its own grammar and syntax. We will have a lot of fun, and be challenged in many ways!

Tuesday, January 10, 2006

Course Syllabus

  1. Content
    • How to Think Like a Computer Scientist
    • A Byte of Python
  2. Prerequisites
    • Keyboarding class (or ability to type 25 wpm)
    • Computer Applications
    • Algebra 1 & Geometry
  3. Course Goals
    • To learn the concepts and methodologies of structured computer programming.
    • To become familiar with Python.
    • To analyze problems and learn to think like a computer programmer.
  4. Course Outline
    • Weeks 1-3 Introduction
      • Understanding the thought process behind program creation
    • Weeks 4-9 Python
      • Variable, Functions, Conditionals, and Recurrsion
      • Strings, Lists, and Tuples
    • Weeks 10-18 Python
      • Object-Oriented Programming
      • Classes, objects, functions, and methods
      • Linked Lists and Stacks
  5. Grading Criteria
    • Online Journal -- 40%
    • Assignments -- 40%
    • Quizzes -- 10%
    • Final Project -- 10%

First Assignment

For this class you will need to create a blog site. On this site you will be posting a short journal entry during each class discussing things you have learned or are struggling with. You can also post about the project you are working on and difficulties you are having with it. This journal will be a large portion of your grade (40%). It does not need to be a huge task each day, but I want to be able to see how you are doing and what you are struggling with.

The blog you create needs to be solely used for this class. Be sure that you enable comments for registered users so I can comment on your posts and give you pointers.

Also, once you have created your site, comment on this post and give me the website of your blog. I will be adding links to each of your sites.

To create the page, click on the link at the top of this page "Get your own blog".

The OFFICIAL Dilbert Widget