예제 #1
0
       expr('In(C2, P1)'),
       expr('In(C2, P2)'),
       expr('At(C1, JFK)'),
       expr('In(C1, P1)'),
       expr('In(C1, P2)'),
       expr('At(P1, JFK)'),
       expr('At(P2, SFO)'),
       ]
init = FluentState(pos, neg)
goal = [expr('At(C1, JFK)'),
        expr('At(C2, SFO)'),
        ]

# lets see the FluentState object
# it has 2 main functions
print(init.sentence())
# that will print all predicates as a sentence like
# (At(C1, SFO) & At(C2, JFK) & At(P1, SFO) & At(P2, JFK) & ~At(C2, SFO) & ~In(C2, P1) & ~In(C2, P2) & ~At(C1, JFK)
#    & ~In(C1, P1) & ~In(C1, P2) & ~At(P1, JFK) & ~At(P2, SFO))
# and
print(init.pos_sentence())
# that omits the negation predicates

# initial state of the AirCargoProblem would be
state_map = init.pos + init.neg  # all predicates
initial_state_TF = encode_state(init, state_map)  # their mapped state (True or False)
print("The initial state of the Air Cargo Problem would be", state_map)
print("The initial_TF state of the Air Cargo Problem would be", initial_state_TF)
# decoding a state requires giving first the truth state of the predicates and then the predicates
# it returns a FluentObject and can extract a sentence with the sentence member function