Posted 14 January 2016 - 07:37 AM
Hi, I'm new here and still a beginner at programming but I decided this year I should do some more programming.
So I installed CC and started playing with turtles again (I have a little experience with it already).
So long story short I got the idea to do a sort of turtle AI where it would roam the land free and multiply.
Here is a bit of code that I use to clear a square or rectangular area :
http://pastebin.com/ErTZQQ0R
Alright so here is my question : is the function clearLayer "optimized" ?
To explain quickly what it does, the 1st IF check if the number of rows is odd, if so it's fairly straight forward.
Then the ELSEIF is the part that was harder to come up with. So this execute only if the number of rows are even because when the turtle finish clearing a layer it's not facing the same way when it goes up to the next layer. That's why the reste of the code is there.
So is it optimized, I was really proud of it all when it was finaly working handling all conditions but I feel there is a lot of stuff that could be simplified but I fail to see how.
Simply looking to improve my programming skills, thank you in advance for anyone leaving a reply.
So I installed CC and started playing with turtles again (I have a little experience with it already).
So long story short I got the idea to do a sort of turtle AI where it would roam the land free and multiply.
Here is a bit of code that I use to clear a square or rectangular area :
http://pastebin.com/ErTZQQ0R
Alright so here is my question : is the function clearLayer "optimized" ?
To explain quickly what it does, the 1st IF check if the number of rows is odd, if so it's fairly straight forward.
Then the ELSEIF is the part that was harder to come up with. So this execute only if the number of rows are even because when the turtle finish clearing a layer it's not facing the same way when it goes up to the next layer. That's why the reste of the code is there.
So is it optimized, I was really proud of it all when it was finaly working handling all conditions but I feel there is a lot of stuff that could be simplified but I fail to see how.
Simply looking to improve my programming skills, thank you in advance for anyone leaving a reply.