From e14c34b980fdc2bf19eb326e7d4b967f0ad6a1c0 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Fri, 17 Mar 2017 17:17:51 +0530 Subject: [PATCH 01/42] Update utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in pseudo code the sequence of arguments is " WEIGHTED-SAMPLE-WITH-REPLACEMENT(N, S, W)"   --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 3c070293e..714512ae0 100644 --- a/utils.py +++ b/utils.py @@ -193,7 +193,7 @@ def probability(p): return p > random.uniform(0.0, 1.0) -def weighted_sample_with_replacement(seq, weights, n): +def weighted_sample_with_replacement(n,seq, weights): """Pick n samples from seq at random, with replacement, with the probability of each element in proportion to its corresponding weight.""" From 82983326e8365516366b7ebb6f2f7d12941dd82d Mon Sep 17 00:00:00 2001 From: sofmonk Date: Fri, 17 Mar 2017 17:27:54 +0530 Subject: [PATCH 02/42] Update utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in pseudo code the sequence of arguments is " WEIGHTED-SAMPLE-WITH-REPLACEMENT(N, S, W)"  same must follow in function "particle_filtering" in the file probability.py --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 3c070293e..714512ae0 100644 --- a/utils.py +++ b/utils.py @@ -193,7 +193,7 @@ def probability(p): return p > random.uniform(0.0, 1.0) -def weighted_sample_with_replacement(seq, weights, n): +def weighted_sample_with_replacement(n,seq, weights): """Pick n samples from seq at random, with replacement, with the probability of each element in proportion to its corresponding weight.""" From 588c3184cc81f7cb1fcf6a27ecfdca4711e2a359 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Fri, 17 Mar 2017 17:41:01 +0530 Subject: [PATCH 03/42] Update learning.py weight_sample_with_replacement sequence of args --- learning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learning.py b/learning.py index df5d6fce3..3e7f4690c 100644 --- a/learning.py +++ b/learning.py @@ -746,7 +746,7 @@ def weighted_replicate(seq, weights, n): wholes = [int(w * n) for w in weights] fractions = [(w * n) % 1 for w in weights] return (flatten([x] * nx for x, nx in zip(seq, wholes)) + - weighted_sample_with_replacement(seq, fractions, n - sum(wholes))) + weighted_sample_with_replacement(n - sum(wholes),seq, fractions, )) def flatten(seqs): return sum(seqs, []) From 8b2b94beee2d6041672238021b0380e6dd704802 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Fri, 17 Mar 2017 17:42:18 +0530 Subject: [PATCH 04/42] Update probability.py weighted_sample_with_replacement sequence of args --- probability.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probability.py b/probability.py index abbc07791..d28a8a38b 100644 --- a/probability.py +++ b/probability.py @@ -651,5 +651,5 @@ def particle_filtering(e, N, HMM): w[i] = float("{0:.4f}".format(w[i])) # STEP 2 - s = weighted_sample_with_replacement(s, w, N) + s = weighted_sample_with_replacement(N,s,w) return s From 35c9d51ac5b6a79108c0a0384c0b6b41cb6340b1 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 11:03:34 +0530 Subject: [PATCH 05/42] Update search.py --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index 04d5b6c51..e4e20da3f 100644 --- a/search.py +++ b/search.py @@ -587,7 +587,7 @@ def genetic_algorithm(population, fitness_fn, ngen=1000, pmut=0.1): new_population = [] for i in range(len(population)): fitnesses = map(fitness_fn, population) - p1, p2 = weighted_sample_with_replacement(population, fitnesses, 2) + p1, p2 = weighted_sample_with_replacement(2,population, fitnesses) child = p1.mate(p2) if random.uniform(0, 1) < pmut: child.mutate() From 0be9f2c3c03a19d2a3ac383f0d9f859db7eef5e4 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:33:56 +0530 Subject: [PATCH 06/42] Update planning.py added double_tennis_problem from chapter 11 , figure 11.10 --- planning.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/planning.py b/planning.py index a17677460..347fd944d 100644 --- a/planning.py +++ b/planning.py @@ -526,3 +526,43 @@ def spare_tire_graphplan(): graphplan.graph.expand_graph() if len(graphplan.graph.levels)>=2 and graphplan.check_leveloff(): return None + + +def double_tennis_problem(): + init = [expr('At(A, LeftBaseLine)'), + expr('At(B, RightNet)'), + expr('Approaching(Ball, RightBaseLine)'), + expr('Partner(A,B)'), + expr('Partner(A,B)')] + + + def goal_test(kb): + required = [expr('Goal(Returned(Ball'), + expr('At(a, RightNet)'), + expr('At(a, LeftNet)')] + for q in required: + if kb.ask(q) is False: + return False + return True + + + ###actions + #hit + precond_pos=[expr('Approaching(Ball,loc'),expr('At(actor,loc')] + precond_neg=[] + effect_add=[expr('Returned(Ball')] + effect_rem = [] + hit = Action(expr('Hit(actor,Ball'), [precond_pos, precond_neg], [effect_add, effect_rem]) + + ##go + precond_pos = [ expr('At(actor,loc')] + precond_neg = [] + effect_add = [expr('At(actor,to')] + effect_rem = [expr('At(actor,loc')] + go = Action(expr('Go(actor,to'), [precond_pos, precond_neg], [effect_add, effect_rem]) + + return PDLL(init, [hit, go], goal_test) + + + + From 76bd895ae5327c632672c6e0b9b98a54ffddbfa6 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:38:12 +0530 Subject: [PATCH 07/42] Update utils.py added missing space after comma --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 714512ae0..6d181dd4c 100644 --- a/utils.py +++ b/utils.py @@ -193,7 +193,7 @@ def probability(p): return p > random.uniform(0.0, 1.0) -def weighted_sample_with_replacement(n,seq, weights): +def weighted_sample_with_replacement(n, seq, weights): """Pick n samples from seq at random, with replacement, with the probability of each element in proportion to its corresponding weight.""" From f9b8ad475792f9ef9a613c3b85e5eddf22f0c871 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:40:50 +0530 Subject: [PATCH 08/42] Update learning.py added missing space after comma --- learning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learning.py b/learning.py index 3e7f4690c..88d5e474b 100644 --- a/learning.py +++ b/learning.py @@ -746,7 +746,7 @@ def weighted_replicate(seq, weights, n): wholes = [int(w * n) for w in weights] fractions = [(w * n) % 1 for w in weights] return (flatten([x] * nx for x, nx in zip(seq, wholes)) + - weighted_sample_with_replacement(n - sum(wholes),seq, fractions, )) + weighted_sample_with_replacement(n - sum(wholes), seq, fractions)) def flatten(seqs): return sum(seqs, []) From a60ef5a6a1a2b25e4fe985636163a00e3c27f5f4 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:41:50 +0530 Subject: [PATCH 09/42] Update probability.py added missing space after comma --- probability.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probability.py b/probability.py index d28a8a38b..0d7b996f4 100644 --- a/probability.py +++ b/probability.py @@ -651,5 +651,5 @@ def particle_filtering(e, N, HMM): w[i] = float("{0:.4f}".format(w[i])) # STEP 2 - s = weighted_sample_with_replacement(N,s,w) + s = weighted_sample_with_replacement(N ,s ,w) return s From f1b4e258e835306a02c581790753e3130d5cc16b Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:43:28 +0530 Subject: [PATCH 10/42] Update search.py added missing space after comma --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index e4e20da3f..45e061119 100644 --- a/search.py +++ b/search.py @@ -587,7 +587,7 @@ def genetic_algorithm(population, fitness_fn, ngen=1000, pmut=0.1): new_population = [] for i in range(len(population)): fitnesses = map(fitness_fn, population) - p1, p2 = weighted_sample_with_replacement(2,population, fitnesses) + p1, p2 = weighted_sample_with_replacement(2, population, fitnesses) child = p1.mate(p2) if random.uniform(0, 1) < pmut: child.mutate() From d45d8d4b052a4a33bc3327fa7e7b68c7fa2115ae Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:52:52 +0530 Subject: [PATCH 11/42] Update planning.py --- planning.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/planning.py b/planning.py index 347fd944d..b94a8526e 100644 --- a/planning.py +++ b/planning.py @@ -535,11 +535,8 @@ def double_tennis_problem(): expr('Partner(A,B)'), expr('Partner(A,B)')] - def goal_test(kb): - required = [expr('Goal(Returned(Ball'), - expr('At(a, RightNet)'), - expr('At(a, LeftNet)')] + required = [expr('Goal(Returned(Ball'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] for q in required: if kb.ask(q) is False: return False @@ -548,18 +545,18 @@ def goal_test(kb): ###actions #hit - precond_pos=[expr('Approaching(Ball,loc'),expr('At(actor,loc')] + precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] precond_neg=[] - effect_add=[expr('Returned(Ball')] + effect_add=[expr("Returned(Ball)")] effect_rem = [] - hit = Action(expr('Hit(actor,Ball'), [precond_pos, precond_neg], [effect_add, effect_rem]) + hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) ##go - precond_pos = [ expr('At(actor,loc')] + precond_pos = [ expr("At(actor,loc)")] precond_neg = [] - effect_add = [expr('At(actor,to')] - effect_rem = [expr('At(actor,loc')] - go = Action(expr('Go(actor,to'), [precond_pos, precond_neg], [effect_add, effect_rem]) + effect_add = [expr("At(actor,to)")] + effect_rem = [expr("At(actor,loc)")] + go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) return PDLL(init, [hit, go], goal_test) From c43fd7ee8a7eb63df26fac8f046bac4e79a76f2e Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:53:43 +0530 Subject: [PATCH 12/42] Update planning.py --- planning.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/planning.py b/planning.py index b94a8526e..d7bf3c44f 100644 --- a/planning.py +++ b/planning.py @@ -542,8 +542,7 @@ def goal_test(kb): return False return True - - ###actions + ##actions #hit precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] precond_neg=[] @@ -551,7 +550,7 @@ def goal_test(kb): effect_rem = [] hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) - ##go + #go precond_pos = [ expr("At(actor,loc)")] precond_neg = [] effect_add = [expr("At(actor,to)")] From dc20b935344a62bb6069fa2b1b11e1b35e99687f Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 13:57:56 +0530 Subject: [PATCH 13/42] Update planning.py --- planning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planning.py b/planning.py index d7bf3c44f..4002cb54b 100644 --- a/planning.py +++ b/planning.py @@ -536,7 +536,7 @@ def double_tennis_problem(): expr('Partner(A,B)')] def goal_test(kb): - required = [expr('Goal(Returned(Ball'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] + required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] for q in required: if kb.ask(q) is False: return False From 4bac0585b91b91419c2ec5246bc288c46d7c05f8 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 15:01:17 +0530 Subject: [PATCH 14/42] Update planning.py --- planning.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/planning.py b/planning.py index 4002cb54b..6a159cec9 100644 --- a/planning.py +++ b/planning.py @@ -558,7 +558,3 @@ def goal_test(kb): go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) return PDLL(init, [hit, go], goal_test) - - - - From cdbbde70057d08467bc20b6bddfb0f770d84224c Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:01:54 +0530 Subject: [PATCH 15/42] Update planning.py --- planning.py | 67 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/planning.py b/planning.py index 4002cb54b..6fb952a8b 100644 --- a/planning.py +++ b/planning.py @@ -237,6 +237,39 @@ def goal_test(kb): return PDLL(init, [eat_cake, bake_cake], goal_test) + +def double_tennis_problem(): + init = [expr('At(A, LeftBaseLine)'), + expr('At(B, RightNet)'), + expr('Approaching(Ball, RightBaseLine)'), + expr('Partner(A,B)'), + expr('Partner(A,B)')] + + def goal_test(kb): + required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] + for q in required: + if kb.ask(q) is False: + return False + return True + + ##actions + #hit + precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] + precond_neg=[] + effect_add=[expr("Returned(Ball)")] + effect_rem = [] + hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + + #go + precond_pos = [ expr("At(actor,loc)")] + precond_neg = [] + effect_add = [expr("At(actor,to)")] + effect_rem = [expr("At(actor,loc)")] + go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + + return PDLL(init, [hit, go], goal_test) + + class Level(): """ Contains the state of the planning problem @@ -528,37 +561,3 @@ def spare_tire_graphplan(): return None -def double_tennis_problem(): - init = [expr('At(A, LeftBaseLine)'), - expr('At(B, RightNet)'), - expr('Approaching(Ball, RightBaseLine)'), - expr('Partner(A,B)'), - expr('Partner(A,B)')] - - def goal_test(kb): - required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] - for q in required: - if kb.ask(q) is False: - return False - return True - - ##actions - #hit - precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] - precond_neg=[] - effect_add=[expr("Returned(Ball)")] - effect_rem = [] - hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) - - #go - precond_pos = [ expr("At(actor,loc)")] - precond_neg = [] - effect_add = [expr("At(actor,to)")] - effect_rem = [expr("At(actor,loc)")] - go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) - - return PDLL(init, [hit, go], goal_test) - - - - From 86615b38a99d6019e3f81c18a5bf4ae702d3d54a Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:09:40 +0530 Subject: [PATCH 16/42] Update planning.py --- planning.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/planning.py b/planning.py index 6fb952a8b..c1130dd2f 100644 --- a/planning.py +++ b/planning.py @@ -237,7 +237,6 @@ def goal_test(kb): return PDLL(init, [eat_cake, bake_cake], goal_test) - def double_tennis_problem(): init = [expr('At(A, LeftBaseLine)'), expr('At(B, RightNet)'), @@ -269,7 +268,6 @@ def goal_test(kb): return PDLL(init, [hit, go], goal_test) - class Level(): """ Contains the state of the planning problem From 9d272b73dacef0520709e9340498935206b02ee3 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:26:13 +0530 Subject: [PATCH 17/42] Update test_agents.py pep8 changes, showed flake8 errors --- tests/test_agents.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index 89ee3fcf3..7d251f547 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -1,21 +1,23 @@ from agents import Direction + def test_move_forward(): d = Direction("up") - l1 = d.move_forward((0,0)) - assert l1 == (0,-1) + l1 = d.move_forward((0, 0)) + assert l1 == (0, -1) d = Direction(Direction.R) - l1 = d.move_forward((0,0)) - assert l1 == (1,0) + l1 = d.move_forward((0, 0)) + assert l1 == (1, 0) d = Direction(Direction.D) - l1 = d.move_forward((0,0)) - assert l1 == (0,1) + l1 = d.move_forward((0, 0)) + assert l1 == (0, 1) d = Direction("left") - l1 = d.move_forward((0,0)) - assert l1 == (-1,0) - l2 = d.move_forward((1,0)) - assert l2 == (0,0) + l1 = d.move_forward((0, 0)) + assert l1 == (-1, 0) + l2 = d.move_forward((1, 0)) + assert l2 == (0, 0) + def test_add(): d = Direction(Direction.U) l1 = d + "right" @@ -36,5 +38,4 @@ def test_add(): l1 = d + Direction.R l2 = d + Direction.L assert l1.direction == Direction.U - assert l2.direction == Direction.D #fixed - + assert l2.direction == Direction.D # fixed From 1581f7a72b3f91267e5a87fcfffa0f07d0140beb Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:32:01 +0530 Subject: [PATCH 18/42] Update test_agents.py --- tests/test_agents.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index 7d251f547..aece69d7f 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -17,7 +17,6 @@ def test_move_forward(): l2 = d.move_forward((1, 0)) assert l2 == (0, 0) - def test_add(): d = Direction(Direction.U) l1 = d + "right" @@ -38,4 +37,4 @@ def test_add(): l1 = d + Direction.R l2 = d + Direction.L assert l1.direction == Direction.U - assert l2.direction == Direction.D # fixed + assert l2.direction == Direction.D From 7f9d0534f52faa3f137c5a14f3ed45a75080bf52 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:34:40 +0530 Subject: [PATCH 19/42] Update test_agents.py --- tests/test_agents.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index aece69d7f..20aa33af6 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -16,7 +16,8 @@ def test_move_forward(): assert l1 == (-1, 0) l2 = d.move_forward((1, 0)) assert l2 == (0, 0) - + + def test_add(): d = Direction(Direction.U) l1 = d + "right" @@ -37,4 +38,4 @@ def test_add(): l1 = d + Direction.R l2 = d + Direction.L assert l1.direction == Direction.U - assert l2.direction == Direction.D + assert l2.direction == Direction.D From 594736d3cb27954e496f3f171fcb41ade76078ca Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:38:02 +0530 Subject: [PATCH 20/42] Update test_agents.py --- tests/test_agents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index 20aa33af6..2512ccddf 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -16,8 +16,8 @@ def test_move_forward(): assert l1 == (-1, 0) l2 = d.move_forward((1, 0)) assert l2 == (0, 0) - - + + def test_add(): d = Direction(Direction.U) l1 = d + "right" From b6f9de464bda1d5bf2ef5c5a16f4da59f9881805 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:41:23 +0530 Subject: [PATCH 21/42] Update test_text.py added missing whitespace after comma --- tests/test_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_text.py b/tests/test_text.py index d58cd497a..577ad661b 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -54,7 +54,7 @@ def test_viterbi_segmentation(): P = UnigramTextModel(wordseq) text = "itiseasytoreadwordswithoutspaces" - s, p = viterbi_segment(text,P) + s, p = viterbi_segment(text, P) assert s == [ 'it', 'is', 'easy', 'to', 'read', 'words', 'without', 'spaces'] From 7d5dcba1de45cd511e85e44ce197eccf2f717c31 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:48:32 +0530 Subject: [PATCH 22/42] Update utils.py added space after comma --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index cfdc88d37..73dd63d63 100644 --- a/utils.py +++ b/utils.py @@ -194,7 +194,7 @@ def probability(p): return p > random.uniform(0.0, 1.0) -def weighted_sample_with_replacement(n,seq, weights): +def weighted_sample_with_replacement(n, seq, weights): """Pick n samples from seq at random, with replacement, with the probability of each element in proportion to its corresponding weight.""" From 2783b6a981a4cef8c7f653fe16f4a82092393e82 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:49:12 +0530 Subject: [PATCH 23/42] Update search.py added space after comma --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index c8885a9ed..94f4949d2 100644 --- a/search.py +++ b/search.py @@ -587,7 +587,7 @@ def genetic_algorithm(population, fitness_fn, ngen=1000, pmut=0.1): new_population = [] for i in range(len(population)): fitnesses = map(fitness_fn, population) - p1, p2 = weighted_sample_with_replacement(2,population, fitnesses) + p1, p2 = weighted_sample_with_replacement(2, population, fitnesses) child = p1.mate(p2) if random.uniform(0, 1) < pmut: child.mutate() From 99cbbaf72c3be44c84ed5e0b4a5958934bbb55e6 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:49:35 +0530 Subject: [PATCH 24/42] Update probability.py added space after comma --- probability.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probability.py b/probability.py index fa856c330..1d7992e6d 100644 --- a/probability.py +++ b/probability.py @@ -643,5 +643,5 @@ def particle_filtering(e, N, HMM): w[i] = float("{0:.4f}".format(w[i])) # STEP 2 - s = weighted_sample_with_replacement(N,s,w) + s = weighted_sample_with_replacement(N, s, w) return s From 620cb4182fed8b4fb4af005a69d0e8b6607deb41 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:50:29 +0530 Subject: [PATCH 25/42] Update learning.py added space after comma --- learning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learning.py b/learning.py index 4917a2cf0..2b86ff8e4 100644 --- a/learning.py +++ b/learning.py @@ -754,7 +754,7 @@ def weighted_replicate(seq, weights, n): wholes = [int(w * n) for w in weights] fractions = [(w * n) % 1 for w in weights] return (flatten([x] * nx for x, nx in zip(seq, wholes)) + - weighted_sample_with_replacement(n - sum(wholes),seq, fractions, )) + weighted_sample_with_replacement(n - sum(wholes), seq, fractions)) def flatten(seqs): return sum(seqs, []) From ab26cd8971b4eaa9cd37dc11781be9507ab62972 Mon Sep 17 00:00:00 2001 From: sofmonk Date: Sat, 18 Mar 2017 17:52:40 +0530 Subject: [PATCH 26/42] Update planning.py added double_tennis_problem --- planning.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/planning.py b/planning.py index a17677460..17028e4c6 100644 --- a/planning.py +++ b/planning.py @@ -526,3 +526,34 @@ def spare_tire_graphplan(): graphplan.graph.expand_graph() if len(graphplan.graph.levels)>=2 and graphplan.check_leveloff(): return None + +def double_tennis_problem(): + init = [expr('At(A, LeftBaseLine)'), + expr('At(B, RightNet)'), + expr('Approaching(Ball, RightBaseLine)'), + expr('Partner(A,B)'), + expr('Partner(A,B)')] + + def goal_test(kb): + required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] + for q in required: + if kb.ask(q) is False: + return False + return True + + ##actions + #hit + precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] + precond_neg=[] + effect_add=[expr("Returned(Ball)")] + effect_rem = [] + hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + + #go + precond_pos = [ expr("At(actor,loc)")] + precond_neg = [] + effect_add = [expr("At(actor,to)")] + effect_rem = [expr("At(actor,loc)")] + go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + + return PDLL(init, [hit, go], goal_test) From f69e7c1e7ab1689da33766ae856fb7f55b2ee8ad Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sun, 19 Mar 2017 12:43:08 +0530 Subject: [PATCH 27/42] Update rl.py In the pseudocode figure 21.8, the first 'if' starts with argument 's', which is the previous state, not s1(i.e, the current state). --- rl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rl.py b/rl.py index 5241710fe..77a04f98a 100644 --- a/rl.py +++ b/rl.py @@ -154,13 +154,13 @@ def __call__(self, percept): s1, r1 = self.update_state(percept) Q, Nsa, s, a, r = self.Q, self.Nsa, self.s, self.a, self.r alpha, gamma, terminals, actions_in_state = self.alpha, self.gamma, self.terminals, self.actions_in_state - if s1 in terminals: - Q[s1, None] = r1 + if s in terminals: + Q[s, None] = r1 if s is not None: Nsa[s, a] += 1 Q[s, a] += alpha(Nsa[s, a]) * (r + gamma * max(Q[s1, a1] for a1 in actions_in_state(s1)) - Q[s, a]) - if s1 in terminals: + if s in terminals: self.s = self.a = self.r = None else: self.s, self.r = s1, r1 From fce259abe690e0fd7380b1490c3502dfefacf440 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sun, 19 Mar 2017 15:05:45 +0530 Subject: [PATCH 28/42] Update search.py the 'uniform_cost_search' in notebook 'search-4e.ipynb' resembles more to the pseudocode in book. --- search.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/search.py b/search.py index 94f4949d2..416855008 100644 --- a/search.py +++ b/search.py @@ -268,9 +268,22 @@ def best_first_graph_search(problem, f): return None -def uniform_cost_search(problem): - "[Figure 3.14]" - return best_first_graph_search(problem, lambda node: node.path_cost) +def uniform_cost_search(problem, costfn=lambda node: node.path_cost): + """[Figure 3.14]""" + frontier = FrontierPQ(Node(problem.initial), costfn) + explored = set() + while frontier: + node = frontier.pop() + if problem.is_goal(node.state): + return node + explored.add(node.state) + for action in problem.actions(node.state): + child = node.child(problem, action) + if child.state not in explored and child not in frontier: + frontier.add(child) + elif child in frontier and frontier.cost[child] < child.path_cost: + frontier.replace(child) + return None def depth_limited_search(problem, limit=50): From 6b82783aebe359b43e11119f942b1ff3ecb38f79 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sun, 19 Mar 2017 15:17:16 +0530 Subject: [PATCH 29/42] Update search.py --- search.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/search.py b/search.py index 416855008..342daf13a 100644 --- a/search.py +++ b/search.py @@ -268,9 +268,10 @@ def best_first_graph_search(problem, f): return None -def uniform_cost_search(problem, costfn=lambda node: node.path_cost): - """[Figure 3.14]""" - frontier = FrontierPQ(Node(problem.initial), costfn) +def uniform_cost_search(problem, costfn = lambda node: node.path_cost): + "[Figure 3.14]" + node = Node(problem.initial) + frontier = PriorityQueue(node, costfn) explored = set() while frontier: node = frontier.pop() From 5e628be627aaec90265c66b6c95120532033ecf9 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sun, 19 Mar 2017 15:24:37 +0530 Subject: [PATCH 30/42] Update search.py --- search.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/search.py b/search.py index 342daf13a..44d6961be 100644 --- a/search.py +++ b/search.py @@ -268,23 +268,9 @@ def best_first_graph_search(problem, f): return None -def uniform_cost_search(problem, costfn = lambda node: node.path_cost): +def uniform_cost_search(problem): "[Figure 3.14]" - node = Node(problem.initial) - frontier = PriorityQueue(node, costfn) - explored = set() - while frontier: - node = frontier.pop() - if problem.is_goal(node.state): - return node - explored.add(node.state) - for action in problem.actions(node.state): - child = node.child(problem, action) - if child.state not in explored and child not in frontier: - frontier.add(child) - elif child in frontier and frontier.cost[child] < child.path_cost: - frontier.replace(child) - return None +return best_first_graph_search(problem, lambda node: node.path_cost) def depth_limited_search(problem, limit=50): From 86f10d5eefacc6d8261a16fe144927b5fb6d3194 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sun, 19 Mar 2017 15:28:04 +0530 Subject: [PATCH 31/42] Update search.py --- search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.py b/search.py index 44d6961be..94f4949d2 100644 --- a/search.py +++ b/search.py @@ -270,7 +270,7 @@ def best_first_graph_search(problem, f): def uniform_cost_search(problem): "[Figure 3.14]" -return best_first_graph_search(problem, lambda node: node.path_cost) + return best_first_graph_search(problem, lambda node: node.path_cost) def depth_limited_search(problem, limit=50): From 1bd46b96024f492afbb9f99c61684ad084de687b Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 17:26:36 +0530 Subject: [PATCH 32/42] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 08e5e23fd..d1e972197 100644 --- a/README.md +++ b/README.md @@ -76,16 +76,16 @@ Here is a table of algorithms, the figure, name of the code in the book and in t | 9.3 | FOL-FC-Ask | `fol_fc_ask` | [`logic.py`][logic] | | 9.6 | FOL-BC-Ask | `fol_bc_ask` | [`logic.py`][logic] | | 9.8 | Append | | | -| 10.1 | Air-Cargo-problem | | -| 10.2 | Spare-Tire-Problem | | -| 10.3 | Three-Block-Tower | | -| 10.7 | Cake-Problem | | +| 10.1 | Air-Cargo-problem |air_cargo |[planning.py][planning]| +| 10.2 | Spare-Tire-Problem | spare_tire |[planning.py][planning]| +| 10.3 | Three-Block-Tower | three_block_tower |[planning.py][planning]| +| 10.7 | Cake-Problem | have_cake_and_eat_cake_too |[planning.py][planning]| | 10.9 | Graphplan | | | 10.13 | Partial-Order-Planner | | | 11.1 | Job-Shop-Problem-With-Resources | | | 11.5 | Hierarchical-Search | | | 11.8 | Angelic-Search | | -| 11.10 | Doubles-tennis | | +| 11.10 | Doubles-tennis | double_tennis_problem |[planning.py][planning]| | 13 | Discrete Probability Distribution | `ProbDist` | [`probability.py`][probability] | | 13.1 | DT-Agent | `DTAgent` | [`probability.py`][probability] | | 14.9 | Enumeration-Ask | `enumeration_ask` | [`probability.py`][probability] | From 6e3fb8eaed5d0d1d8619b429e58fbb57a2833c6e Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 17:28:56 +0530 Subject: [PATCH 33/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1e972197..7001c3b95 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Here is a table of algorithms, the figure, name of the code in the book and in t | 10.2 | Spare-Tire-Problem | spare_tire |[planning.py][planning]| | 10.3 | Three-Block-Tower | three_block_tower |[planning.py][planning]| | 10.7 | Cake-Problem | have_cake_and_eat_cake_too |[planning.py][planning]| -| 10.9 | Graphplan | | +| 10.9 | Graphplan | GraphPlan |[planning.py][planning]| | 10.13 | Partial-Order-Planner | | | 11.1 | Job-Shop-Problem-With-Resources | | | 11.5 | Hierarchical-Search | | From 3f3ef6dc47233ccede6fa309a715cbd65e9b6104 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 17:30:29 +0530 Subject: [PATCH 34/42] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7001c3b95..7cb796b02 100644 --- a/README.md +++ b/README.md @@ -76,16 +76,16 @@ Here is a table of algorithms, the figure, name of the code in the book and in t | 9.3 | FOL-FC-Ask | `fol_fc_ask` | [`logic.py`][logic] | | 9.6 | FOL-BC-Ask | `fol_bc_ask` | [`logic.py`][logic] | | 9.8 | Append | | | -| 10.1 | Air-Cargo-problem |air_cargo |[planning.py][planning]| -| 10.2 | Spare-Tire-Problem | spare_tire |[planning.py][planning]| -| 10.3 | Three-Block-Tower | three_block_tower |[planning.py][planning]| -| 10.7 | Cake-Problem | have_cake_and_eat_cake_too |[planning.py][planning]| -| 10.9 | Graphplan | GraphPlan |[planning.py][planning]| +| 10.1 | Air-Cargo-problem |`air_cargo` |[`planning.py`][planning]| +| 10.2 | Spare-Tire-Problem | `spare_tire` |[`planning.py`][planning]| +| 10.3 | Three-Block-Tower | `three_block_tower` |[`planning.py`][planning]| +| 10.7 | Cake-Problem | `have_cake_and_eat_cake_too` |[`planning.py`][planning]| +| 10.9 | Graphplan | `GraphPlan` |[`planning.py`][planning]| | 10.13 | Partial-Order-Planner | | | 11.1 | Job-Shop-Problem-With-Resources | | | 11.5 | Hierarchical-Search | | | 11.8 | Angelic-Search | | -| 11.10 | Doubles-tennis | double_tennis_problem |[planning.py][planning]| +| 11.10 | Doubles-tennis | `double_tennis_problem` |[`planning.py`][planning]| | 13 | Discrete Probability Distribution | `ProbDist` | [`probability.py`][probability] | | 13.1 | DT-Agent | `DTAgent` | [`probability.py`][probability] | | 14.9 | Enumeration-Ask | `enumeration_ask` | [`probability.py`][probability] | From 8f0899a0dcf1c367456a7b2e68ed9ade10654156 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 19:05:46 +0530 Subject: [PATCH 35/42] Update planning.py --- planning.py | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/planning.py b/planning.py index e31b82f13..6f436fdb8 100644 --- a/planning.py +++ b/planning.py @@ -237,36 +237,6 @@ def goal_test(kb): return PDLL(init, [eat_cake, bake_cake], goal_test) -def double_tennis_problem(): - init = [expr('At(A, LeftBaseLine)'), - expr('At(B, RightNet)'), - expr('Approaching(Ball, RightBaseLine)'), - expr('Partner(A,B)'), - expr('Partner(A,B)')] - - def goal_test(kb): - required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] - for q in required: - if kb.ask(q) is False: - return False - return True - - ##actions - #hit - precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] - precond_neg=[] - effect_add=[expr("Returned(Ball)")] - effect_rem = [] - hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) - - #go - precond_pos = [ expr("At(actor,loc)")] - precond_neg = [] - effect_add = [expr("At(actor,to)")] - effect_rem = [expr("At(actor,loc)")] - go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) - - return PDLL(init, [hit, go], goal_test) class Level(): """ From 0ed9512ba03d0732bd9e39d60ce4cd01871e7632 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 19:32:05 +0530 Subject: [PATCH 36/42] Update planning.py added spaces after comma --- planning.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/planning.py b/planning.py index 6f436fdb8..90e4151bc 100644 --- a/planning.py +++ b/planning.py @@ -532,8 +532,8 @@ def double_tennis_problem(): init = [expr('At(A, LeftBaseLine)'), expr('At(B, RightNet)'), expr('Approaching(Ball, RightBaseLine)'), - expr('Partner(A,B)'), - expr('Partner(A,B)')] + expr('Partner(A, B)'), + expr('Partner(B, A)')] def goal_test(kb): required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')] @@ -544,17 +544,17 @@ def goal_test(kb): ##actions #hit - precond_pos=[expr("Approaching(Ball,loc)"), expr("At(actor,loc)")] + precond_pos=[expr("Approaching(Ball, loc)"), expr("At(actor, loc)")] precond_neg=[] effect_add=[expr("Returned(Ball)")] effect_rem = [] - hit = Action(expr("Hit(actor,Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + hit = Action(expr("Hit(actor, Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) #go - precond_pos = [ expr("At(actor,loc)")] + precond_pos = [ expr("At(actor, loc)")] precond_neg = [] - effect_add = [expr("At(actor,to)")] - effect_rem = [expr("At(actor,loc)")] - go = Action(expr("Go(actor,to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) + effect_add = [expr("At(actor, to)")] + effect_rem = [expr("At(actor, loc)")] + go = Action(expr("Go(actor, to)"), [precond_pos, precond_neg], [effect_add, effect_rem]) return PDLL(init, [hit, go], goal_test) From 8845d4ba647a5af7eebb24847305d7f9ea057d15 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 19:36:00 +0530 Subject: [PATCH 37/42] Update planning.py --- planning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planning.py b/planning.py index 90e4151bc..47eae77da 100644 --- a/planning.py +++ b/planning.py @@ -551,7 +551,7 @@ def goal_test(kb): hit = Action(expr("Hit(actor, Ball)"), [precond_pos, precond_neg], [effect_add, effect_rem]) #go - precond_pos = [ expr("At(actor, loc)")] + precond_pos = [expr("At(actor, loc)")] precond_neg = [] effect_add = [expr("At(actor, to)")] effect_rem = [expr("At(actor, loc)")] From da4733f135d204fd9f5d9310576e0474e289766e Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 19:52:52 +0530 Subject: [PATCH 38/42] Update test_planning.py added double_tennis_problem test --- tests/test_planning.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_planning.py b/tests/test_planning.py index 461cdcdbb..6b01c7ca6 100644 --- a/tests/test_planning.py +++ b/tests/test_planning.py @@ -81,3 +81,16 @@ def test_graph_call(): graph() assert levels_size == len(graph.levels) - 1 + + + + +def test_double_tennis_problem(): + p = double_tennis_problem() + assert p.goal_test() is False + solution = [expr("Go(A, RightBaseLine)"), expr("Hit(A, Ball)")] + + for action in solution: + p.act(action) + + assert p.goal_test() From 32cd0e69a24bea3d22409f8912f24ff060e1c307 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Thu, 23 Mar 2017 19:53:43 +0530 Subject: [PATCH 39/42] Update test_planning.py --- tests/test_planning.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_planning.py b/tests/test_planning.py index 6b01c7ca6..ab6383cf7 100644 --- a/tests/test_planning.py +++ b/tests/test_planning.py @@ -83,12 +83,10 @@ def test_graph_call(): assert levels_size == len(graph.levels) - 1 - - def test_double_tennis_problem(): p = double_tennis_problem() assert p.goal_test() is False - solution = [expr("Go(A, RightBaseLine)"), expr("Hit(A, Ball)")] + solution = [expr('Go(A, RightBaseLine)'), expr('Hit(A, Ball)')] for action in solution: p.act(action) From 7afe3522c2869c8682d4f2386a23c4e831a8c0df Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sat, 25 Mar 2017 10:39:55 +0530 Subject: [PATCH 40/42] Update logic.py added fol_fc_ask from fig 9.3 --- logic.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/logic.py b/logic.py index 9054cdfc7..6ba95850b 100644 --- a/logic.py +++ b/logic.py @@ -842,7 +842,22 @@ def subst(s, x): def fol_fc_ask(KB, alpha): - raise NotImplementedError + """A simple forward-chaining algorithm. [Figure 9.3]""" + while new is not None: + new = [] + for rule in KB: + p, q = parse_definite_clause(standardize_variables(rule)) + for p_ in random.KB.clauses: + if p != p_: + for theta in (subst(theta, p) == subst(theta, p_)): + q_ = subst(theta, q) + if not unify(q_,KB.sentence in KB) or not unify(q_, new): + new.append(q_) + phi = unify(q_,alpha) + if phi is not None: + return phi + KB.tell(new) + return None def standardize_variables(sentence, dic=None): @@ -875,7 +890,8 @@ class FolKB(KB): >>> kb0.retract(expr('Rabbit(Pete)')) >>> kb0.ask(expr('Hates(Mac, x)'))[x] Flopsie - >>> kb0.ask(expr('Wife(Pete, x)')) + >>> kb0.ask(expr('Wife(Pete, x)'))"""A simple backward-chaining algorithm for first-order logic. [Figure 9.6] + KB should be an instance of FolKB, and query an atomic sentence.""" False """ From 00d29b49d0b8f39f7a3d54636863abb523a6e02f Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sat, 25 Mar 2017 10:45:52 +0530 Subject: [PATCH 41/42] Update logic.py --- logic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/logic.py b/logic.py index 6ba95850b..bd9c92334 100644 --- a/logic.py +++ b/logic.py @@ -890,8 +890,7 @@ class FolKB(KB): >>> kb0.retract(expr('Rabbit(Pete)')) >>> kb0.ask(expr('Hates(Mac, x)'))[x] Flopsie - >>> kb0.ask(expr('Wife(Pete, x)'))"""A simple backward-chaining algorithm for first-order logic. [Figure 9.6] - KB should be an instance of FolKB, and query an atomic sentence.""" + >>> kb0.ask(expr('Wife(Pete, x)')) False """ From b5b1b9170865b6689d1c205b77a6ad79af6bff51 Mon Sep 17 00:00:00 2001 From: Angira Sharma Date: Sat, 25 Mar 2017 10:47:42 +0530 Subject: [PATCH 42/42] Update test_planning.py --- tests/test_planning.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/test_planning.py b/tests/test_planning.py index ab6383cf7..461cdcdbb 100644 --- a/tests/test_planning.py +++ b/tests/test_planning.py @@ -81,14 +81,3 @@ def test_graph_call(): graph() assert levels_size == len(graph.levels) - 1 - - -def test_double_tennis_problem(): - p = double_tennis_problem() - assert p.goal_test() is False - solution = [expr('Go(A, RightBaseLine)'), expr('Hit(A, Ball)')] - - for action in solution: - p.act(action) - - assert p.goal_test()