vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 07, 2013, 06:16:35 AM |
|
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/6472113Note: Op is not a programmer and is learning this as a hobby.
|
|
|
|
b!z
Legendary
Offline
Activity: 1582
Merit: 1010
|
|
September 07, 2013, 06:42:39 AM |
|
So are you learning to code, or playing a game? or both?
|
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 07, 2013, 01:47:36 PM |
|
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.
|
|
|
|
jackjack
Legendary
Offline
Activity: 1176
Merit: 1255
May Bitcoin be touched by his Noodly Appendage
|
|
September 07, 2013, 03:04:19 PM |
|
Where is robot.py? while x == 3 - 4: Do you really mean while x==-1?
|
Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2 Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 07, 2013, 03:14:09 PM |
|
Where is robot.py? 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.
|
|
|
|
FirstAscent
|
|
September 07, 2013, 03:24:16 PM |
|
Where is robot.py? 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.
|
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 07, 2013, 03:44:55 PM Last edit: September 07, 2013, 04:32:01 PM by vite |
|
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 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
|
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 07, 2013, 04:46:18 PM |
|
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.
|
|
|
|
polrpaul
Full Member
Offline
Activity: 238
Merit: 100
Love the Bitcoin.
|
|
September 07, 2013, 04:50:43 PM |
|
this probably belongs in a python developers forum?
|
|
|
|
jackjack
Legendary
Offline
Activity: 1176
Merit: 1255
May Bitcoin be touched by his Noodly Appendage
|
|
September 07, 2013, 06:17:03 PM |
|
You can use "while x in [3, 4]"
|
Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2 Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
|
|
|
Moogle
Full Member
Offline
Activity: 238
Merit: 100
KUPO!
|
|
September 07, 2013, 11:04:04 PM |
|
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
|
|
|
|
FirstAscent
|
|
September 08, 2013, 01:38:31 AM |
|
Are we dealing with floats?
In such a case, perhaps you meant something like this:
while x >= 3 and x < 4:
|
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 09, 2013, 08:15:05 PM |
|
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()
|
|
|
|
FirstAscent
|
|
September 09, 2013, 08:25:00 PM |
|
What error?
|
|
|
|
vite (OP)
Legendary
Offline
Activity: 1018
Merit: 1000
|
|
September 11, 2013, 12:31:17 PM |
|
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.
|
|
|
|
FirstAscent
|
|
September 11, 2013, 04:48:06 PM |
|
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
|
|
|
|
|