-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handin for MP2 #13
base: master
Are you sure you want to change the base?
Handin for MP2 #13
Conversation
This is my Handin for MP2 |
one = ['x','y'] | ||
function = ['x','y','cos_pi','sin_pi','prod','square','average','square_root'] | ||
if max_depth == 1: | ||
return one[random.randint(0,1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also use random.choice(one), that grabs a random element from the list and is (in my opinion, at least) a slightly cleaner way to handle it. That said, it's entirely your call!
@@ -2,6 +2,7 @@ | |||
|
|||
import random | |||
from PIL import Image | |||
import math | |||
|
|||
|
|||
def build_random_function(min_depth, max_depth): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I don't believe that the function, as you've written it, actually uses min_depth for anything - it always makes a function of max_depth. That said, it still works, and I suppose that it's technically correct.
For what it's worth, there's a handful of different ways you could handle min_ and max_depth - one option is to just randomly pick one if they're not the same, and another would be to start allowing the 'one' functions as soon as min_depth hits 1, but not force them until max_depth is 1.
#check reversed input range | ||
reverseInput = False | ||
oldMin = min( input_interval_start, input_interval_end ) | ||
# print(oldMin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, before turning things in it's best to remove these debugging print statements.
No description provided.