Skip to content

Commit

Permalink
Update: remove unnecessary rule restriction so that it can learn to p…
Browse files Browse the repository at this point in the history
…redict everything on the map properly
  • Loading branch information
patham9 committed Jan 5, 2024
1 parent ac6a9e9 commit 37b0554
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
5 changes: 0 additions & 5 deletions hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ def _Variants(rule): #location symmetry (knowledge about World_Movement operatio
action_values_precons = rule[0]
conditions = action_values_precons[2:]
action = action_values_precons[0]
for (y,x,v) in conditions: #unnecessary
if (action == left or action == right) and y != 0:
return []
if (action == up or action == down) and x != 0:
return []
rules = [rule]
if DisableOpSymmetryAssumption:
return rules
Expand Down
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
if __name__ == "__main__":
for Time in range(300):
start_time = time.time()
FocusSet, RuleEvidence, loc, observed_world, rules, negrules, world, debuginput = NACE_Cycle(Time, FocusSet, RuleEvidence, loc, observed_world, rules, negrules, deepcopy(world))
usedRules, FocusSet, RuleEvidence, loc, observed_world, rules, negrules, world, debuginput = NACE_Cycle(Time, FocusSet, RuleEvidence, loc, observed_world, rules, negrules, deepcopy(world))
end_time = time.time()
print("VALUES", world[VALUES], "FOCUS SET", FocusSet)
elapsed_time = end_time - start_time
Expand All @@ -56,13 +56,13 @@
if d == 'r':
predworld = deepcopy(world)
if d == 'a':
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), left, rules)
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), left, usedRules)
if d == 'd':
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), right, rules)
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), right, usedRules)
if d == 'w':
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), up, rules)
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), up, usedRules)
if d == 's':
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), down, rules)
predworld, score, age = NACE_Predict(Time, FocusSet, deepcopy(predworld), down, usedRules)
if d == 'l':
for x in rules:
Prettyprint_rule(RuleEvidence, Hypothesis_TruthValue, x)
Expand Down
3 changes: 2 additions & 1 deletion nace.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ def NACE_Cycle(Time, FocusSet, RuleEvidence, loc, observed_world, rulesin, negru
World_Print(planworld)
print("\033[0m")
FocusSet, RuleEvidence, newrules, newnegrules = _Observe(FocusSet, RuleEvidence, observed_world_old, action, observed_world, rules, negrules, predicted_world)
usedRules = deepcopy(newrules)
for rule in rulesExcluded: #add again so we won't loose them
newrules.add(rule)
return FocusSet, RuleEvidence, loc, observed_world, newrules, newnegrules, newworld, debuginput
return usedRules, FocusSet, RuleEvidence, loc, observed_world, newrules, newnegrules, newworld, debuginput

# APPLY MOVE TO THE WORLD MODEL WHEREBY WE USE THE EXISTING RULES TO DECIDE HOW A GRID ELEMENT CHANGES
def NACE_Predict(Time, FocusSet, oldworld, action, rules, customGoal = None):
Expand Down

0 comments on commit 37b0554

Please sign in to comment.