Help with homework assignment (lindenmayer system)

This is the place for queries that don't fit in any of the other categories.

Help with homework assignment (lindenmayer system)

Postby devin79 » Mon Sep 16, 2013 11:05 pm

Hi I am a college student who is in a CGI Film production program at the University of New Mexico. The program (called IFDM) is sponsored by Sony studios and Sony Imageworks.
I know a great deal about modeling, texturing, and some animation, using software such as Maya, 3DS Max, and Houdini....however one of our new core classes is a computer programming class: "Intro to Python". Unfortunately I have zero knowledge of how to use Python or any coding or programming skills whatsoever. So far I have been able to figure some of this stuff out (turtle graphics mainly), but this coding for the "Lindenmayer System" has me really stuck. Here is my assignment as posted on our college website for this class.

assignment:
Write a program that takes 3 inputs:
1) Draw String: This must be a string of draw commands (see the table below).
2) Length: This must be an integer equal greater than 0 and less than or equal to 100. It defines the length variable used in some of the draw commands.
3) Angle: This must be a floating point number equal greater than 0.0 and less than or equal to 360.0. It defines the angle variable used in some of the draw commands.
Input:

Character Draw Commands
h
Draw a straight line segment length pixels long in the current
heading.
f Same as h
g
Move, without drawing, a straight line segment length pixels
long in the current heading.
+ Turn the heading clockwise by angle.
- Turn the heading counter-clockwise by angle.
A
Each of these color commands must change the turtle color to
color that is different form the background and different from
the other 5 color commands. Pick colors that you think look good
together.
B
C
D
E
F
any other
character
Ignore

There is also one other piece of info:

Now that you have the "if" statement at your command, you do need to check for bad input. If the user inputs bad data, print an error message and exit the program.

so, I guess my question is, how do I go about coding this stuff. I think what I am doing is turning these letters into commands such as turtle.forward((something), or turtle.turn(right, or left)... I have a textbook and have read the chapter, but it doesn't really address this assignment. I would really appreciate any help anyone could give me on how to get started with this assignment. I am sorry it is such a long post, I am just trying to be as precise as I can on what the assignment is asking for. Any help or guidance would be very much appreciated. Thank You:)
Last edited by micseydel on Tue Sep 17, 2013 12:30 am, edited 1 time in total.
Reason: First post lock.
devin79
 
Posts: 10
Joined: Mon Sep 16, 2013 10:51 pm

Re: Help with homework assignment (lindenmayer system)

Postby micseydel » Tue Sep 17, 2013 12:34 am

There are a great deal of free sources online that assist in helping people teach themselves Python. We are very interested in helping people, but on this forum we expect some code first, even if it doesn't solve the problem. If it doesn't, explain what it does do, what it needs to do, and what you tried to make it do what it needs to do and why you think it should work when it doesn't. If you have no idea what code to write to accomplish the task, then you need to patiently go through a tutorial or maybe ask very specific coding questions.

You can start here with the input/output code. It's simple to take in and check for valid input. The logic is very straightforward, and the code equally so.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1508
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Help with homework assignment (lindenmayer system)

Postby devin79 » Tue Sep 17, 2013 12:44 am

I will try and post some code. And then maybe someone can tell me if I am even close to getting it right, thanks:)
devin79
 
Posts: 10
Joined: Mon Sep 16, 2013 10:51 pm

Re: Help with homework assignment (lindenmayer system)

Postby Marbelous » Tue Sep 17, 2013 6:13 pm

http://openbookproject.net/thinkcs/pyth ... rtles.html
http://www.eg.bucknell.edu/~hyde/Python ... tions.html

There are many more turtle tutorials out there. Turtle is designed to teach children programming concepts through graphics so most will seem a bit simplistic but it's a great way for people like you to get their feet wet with python.

The official Turtle module page: http://docs.python.org/2/library/turtle.html

BTW, Python is the scripting language used in Blender3D (in case you can't afford Maya like me. :cry: )
Marbelous
 
Posts: 158
Joined: Fri May 31, 2013 8:12 pm

Re: Help with homework assignment (lindenmayer system)

Postby devin79 » Tue Sep 17, 2013 8:03 pm

Ok, so just to let people know. I am familiar with turtle graphics in terms of basic stuff like how to write my name, or how to make a spiral design and color it (those were our last two assignments). But this L-System thing has me totally perplexed. Here is some code I did come up with, but I am not sure what to plug into it. If someone could tell me how to do one letter, maybe I could figure out how to code the remaining letters and symbols described in the assignment.

code.

command line = ("enter a command line"))

command length = len (command line)

print (command length)

# for i in range (command length):

# if(charAt(0) == b):

turtle.forward (length)

elif (char(0) == e):

I think I wrote this code accurately, but if there are mistakes...please let me know. Thank you:)
devin79
 
Posts: 10
Joined: Mon Sep 16, 2013 10:51 pm

Re: Help with homework assignment (lindenmayer system)

Postby micseydel » Tue Sep 17, 2013 8:15 pm

Please post working Python code in code tags even if it doesn't quite solve the problem, not pseudo code. Then, state precisely what the next thing you're trying to do is that you're not sure about, and any thoughts you have about it.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1508
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: W3C [Linkcheck] and 3 guests