Python:
class DiMemoryGame:
def __init__(self):
self.score = 0
self.game_on = False
self.game_str = ""
self.game_chars = ["r", "g", "b", "y"]
def input(self, ear):
if ear == "memory game on":
self.game_on = True
self.score = 0
self.game_str = self._get_a_response()
self._set_simple_alg(self.game_str)
if self.game_on:
temp = self._extract_regex("^[rgby]+$", ear)
if temp:
if temp == self.game_str:
temp = self._get_a_response()
self.game_str += temp
self.score += 1
self._set_simple_alg(temp)
else:
self.game_on = False
self._set_simple_alg(f"you scored {self.score}")
self.score = 0