Created
May 6, 2019 20:44
-
-
Save MalteWegener99/56272dee0e11d43beb38fb4d59eb9993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
We basically want to do a binary tree that has quastions as splitting | |
""" | |
yes = ["y", "yes", "Y", "Yes"] | |
def ask(question): | |
ans = input(question+"? ") | |
if ans in: | |
return True | |
else: | |
return False | |
class Node: | |
def __init__(self, animal): | |
self.left = None | |
self.right = None | |
self.animal = animal | |
self.question = None | |
def traverse(self): | |
if self.question is None: | |
print(self.animal) | |
was_right = ask("Was I right") | |
if was_right: | |
print("ez") | |
else: | |
print("Yikes") | |
new_animal = input("What was the animal: ") | |
self.question = input("Say question to distinguish: ") | |
new_a_true = ask("is this a yes for {}".format(new_animal)) | |
if new_a_true: | |
self.left = Node(new_animal) | |
self.right = Node(self.animal) | |
else: | |
self.right = Node(new_animal) | |
self.left = Node(self.animal) | |
self.animal = None | |
return | |
else: | |
if ask(self.question): | |
return self.left.traverse() | |
else: | |
return self.right.traverse() | |
N0 = Node("Dog") | |
while True: | |
print() | |
print("Mew round") | |
N0.traverse() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment