Author

Topic: Learning Python part 3 (Read 1198 times)

hero member
Activity: 812
Merit: 1000
September 11, 2013, 11:48:06 AM
#16
Well, I don't know anything about LABY. Why don't you write some code from the ground up?

Here's a good project for you: Write a program that builds a 2d road network using recursion, by growing roads one branch at a time, creating a road topology that is reasonable and authentic looking, including urban areas, suburbs, and rural areas. Print the topological data out to a Renderman RIB file, and use the freely available 3Delight renderer to render the network.

Use this paper as inspiration, but do not adopt the L-system methodology: http://graphics.ethz.ch/Downloads/Publications/Papers/2001/p_Par01.pdf
legendary
Activity: 1018
Merit: 1000
September 11, 2013, 07:31:17 AM
#15
What error?

The solutions you offered are written correctly.

But it seems the game LABY does not have a complete python library or just cannot read them.

Gives me a track... syntax... on line depending on where I placed the code.
hero member
Activity: 812
Merit: 1000
September 09, 2013, 03:25:00 PM
#14
What error?
legendary
Activity: 1018
Merit: 1000
September 09, 2013, 03:15:05 PM
#13
Are we dealing with floats?

In such a case, perhaps you meant something like this:

while x >= 3 and x < 4:

Are we dealing with floats?

In such a case, perhaps you meant something like this:

while x >= 3 and x < 4:

both  this solutions  give me an error within laby

using if and or gives me and error

The best thing was to do

if x == 1:
    left()
if x == 2:
    right()
main()
hero member
Activity: 812
Merit: 1000
September 07, 2013, 08:38:31 PM
#12
Are we dealing with floats?

In such a case, perhaps you meant something like this:

while x >= 3 and x < 4:
full member
Activity: 238
Merit: 100
KUPO!
September 07, 2013, 06:04:04 PM
#11
Good effort :-) I'm trying to learn java in my spare time. Wanna start making some apps for my phone :-P might finally be able yo get all my ahitty c# games playable on a phone :-D
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
September 07, 2013, 01:17:03 PM
#10
You can use "while x in [3, 4]"
full member
Activity: 238
Merit: 100
Love the Bitcoin.
September 07, 2013, 11:50:43 AM
#9
this probably belongs in a python developers forum?  Undecided
legendary
Activity: 1018
Merit: 1000
September 07, 2013, 11:46:18 AM
#8
Disregard the previous solution and thanks for the feedback...

I will just remove x == 3 - 4 all together,
since I have the range from 1 to 4
if it does not generate 1 or 2 in the random number it will go back to function to check on other conditions and just move accordingly.
legendary
Activity: 1018
Merit: 1000
September 07, 2013, 10:44:55 AM
#7
What I find odd is that the ant is behaving the way I want it to behave. Meaning that if random outputs 3 or 4 it moves forward.

I guess I should do x == none instead. To break the loop  Huh

Just trying to figure out why the ant behaves as intended.

Edit: figured it out
X >= 3

That way %50 it will check to move forward
And the rest of the other time it will try left or right
The behavior can be altered by increasing/decreasing the range of the random numbers
hero member
Activity: 812
Merit: 1000
September 07, 2013, 10:24:16 AM
#6
Where is robot.py?

Quote
while x == 3 - 4:
Do you really mean while x==-1?

Robot.py comes within LABY if you see the gist comment; the link to laby is there.

Hmm since x is a random generated number I thought I was telling pythin if x equals 3 or 4 then go back to function...

Then it should be:

while x == 3 or x == 4:

In your code, it should be obvious that 3 - 4 is an expression which subtracts 4 from 3. Furthermore, - has greater precedence than ==, thus the expression 3 - 4 evaluates before the equality operator. Finally, 3 and 4 are constants, thus the interpreter can evaluate them at compile time, if it does do a mini-compile upon running, and convert them into the value -1.

Now, let's look at some aspects of precedence and predicates.

If the == operator had greater precedence than the - operator (which it doesn't), then we would have a statement which attempts to subtract 4 from the value of True or False. If coding in C, which you are not, the equality expression would evaluate to 0 or 1. Interestingly, we could do this:

while((x == 3) - 4) {

Which would evaluate to -3 if x did indeed equal 3.
legendary
Activity: 1018
Merit: 1000
September 07, 2013, 10:14:09 AM
#5
Where is robot.py?

Quote
while x == 3 - 4:
Do you really mean while x==-1?

Robot.py comes within LABY if you see the gist comment; the link to laby is there.

Hmm since x is a random generated number I thought I was telling pythin if x equals 3 or 4 then go back to function...

Edit : if u run ubuntu desktop you can install it from the software center.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
September 07, 2013, 10:04:19 AM
#4
Where is robot.py?

Quote
while x == 3 - 4:
Do you really mean while x==-1?
legendary
Activity: 1018
Merit: 1000
September 07, 2013, 08:47:36 AM
#3
So are you learning to code, or playing a game? or both?

Learning to code
Solving the LABY maze challenges was to test what I have learned so far.
b!z
legendary
Activity: 1582
Merit: 1010
September 07, 2013, 01:42:39 AM
#2
So are you learning to code, or playing a game? or both?
legendary
Activity: 1018
Merit: 1000
September 07, 2013, 01:16:35 AM
#1
Well i'm half way through LPTHW at this point the book wants me to memorize symbols and their functions and practice.

So to take a break from the usual study drill I decided to make an automata to run on top of something called.

LABY a game it seems to solve the maze part of the problems roughly about 4 of them.

You can review my attempt at the game here:

https://gist.github.com/vitepython/6472113

Note: Op is not a programmer and is learning this as a hobby.
Jump to: