def test_is_spare(self): r = solver.Rules( rule1=solver.Code(code_str='frame[0] < 10'), rule2=solver.Code(code_str='frame[0] + frame[1] == 10'), output=True) r.solve(start_bowling.is_spare, self)
def test_OR_function(self): # The output is implicitly set to true r = solver.Rules(a=False, b=True) r.add(a=True, b=False) r.add(a=True, b=True) r.solve(start_sample.or_function, self)
def test_get_next_throw(self): i = Code() r = solver.Rules(before_last=(i < 9), output=solver.Code(code_str='game[i+1][0]')) r.add(last_bonus_thow=(i == 9), output=solver.Code(code_str='game[i][2]')) r.solve(start_bowling.get_next_throw, self)
def test_recursive_get_score(self): r = solver.Rules( solver.Code(code_str='i == len(game)'), output=0, default=solver.Code( code_str= 'recursive_get_score(game, i + 1) + get_frame_score(game[i], game, i)' )) r.solve(start_bowling.recursive_get_score, self)
def test_get_frame_score(self): r = solver.Rules( not_strike=solver.Code(code_str='not is_strike(frame)'), not_spare=solver.Code(code_str='not is_spare(frame)'), output=solver.Code(code_str='frame[0] + frame[1]')) r.add(is_spare=solver.Code(code_str='is_spare(frame)'), output=solver.Code( code_str='frame[0] + frame[1] + get_next_throw(i, game)')) r.add(is_strike=solver.Code(code_str='is_strike(frame)'), output=solver.Code( code_str='frame[0] + get_next_2_throws(i, game)')) r.solve(start_bowling.get_frame_score, self)
def test_get_next_2_throws(self): i = Code() r = solver.Rules( last_bonus_throw=(i == 9), output=solver.Code(code_str='game[i][1] + game[i][2]')) r.add(i == 8, solver.Code(code_str='is_strike(game[i+1])'), output=solver.Code(code_str='game[i+1][0] + game[i+1][1]')) r.add(next_is_not_strike=solver.Code( code_str='not is_strike(game[i+1])'), output=solver.Code(code_str='game[i+1][0] + game[i+1][1]')) r.add(next_is_strike=solver.Code(code_str='is_strike(game[i+1])'), output=solver.Code(code_str='game[i+1][0] + game[i+2][0]')) r.solve(start_bowling.get_next_2_throws, self)
def test_is_strike(self): r = solver.Rules(rule=solver.Code(code_str='frame[0] == 10'), output=True) r.solve(start_bowling.is_strike, self)
def test_AND_3_VARIABLES_function(self): r = solver.Rules(a=True, b=True, c=True) r.solve(start_sample.and_function_3_variables, self)
def test_XOR_function(self): r = solver.Rules(a=False, b=True) r.add(a=True, b=False) r.solve(start_sample.xor_function, self)
def test_AND_function(self): # The output is explicitly set to true r = solver.Rules(a=True, b=True, output=True) r.solve(start_sample.and_function, self)