Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Handin for MP2 #13

wants to merge 2 commits into from

Conversation

akaushika
Copy link

No description provided.

@akaushika
Copy link
Author

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)]

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):

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants