**** Programas em Jason para a disciplina PCS 5703 Sistemas Multiagentes **** **REGRAS** **EX1** /* Initial beliefs and rules */ can_afford(Something) :- price(Something,P) & bank_balance(B) & B>P. desire_items(bike). desire_items(motorcycle). desire_items(car). price(bike, 2000). price(motorcycle, 15000). price(car, 40000). bank_balance(60000). /* Initial goals */ !buy. /* Plans */ +!buy: desire_items(Something) & can_afford(Something) <- .print("I want buy this: ", Something). /** *** Para regras a ordem é a sequência de declaração. Nesse caso, como "Something" == bike atende ao contexto do plano +!buy, então "Something" assume o valor bike. *** */ ************************************************************************************ **EX2** /* Initial beliefs and rules */ can_afford(Something) :- price(Something,P) & bank_balance(B) & B>P. desire_items(bike). desire_items(motorcycle). desire_items(car). price(bike, 2000). price(motorcycle, 15000). price(car, 40000). bank_balance(1000). /* Initial goals */ !buy. /* Plans */ +!buy: desire_items(Something) & can_afford(Something) <- .print("I want buy this: ", Something). +!buy: desire_items(Something) & not can_afford(Something) <- .print("NO MONEY"). ************************************************************************************ **EX3** /* Initial goals */ !add_beliefs. /* Plans */ +!add_beliefs : true <- +plays(pedro, rugby); +plays(pedro, soccer); +plays(pedro, basketball); !check. +!check: true <- ?plays(pedro, SPORT); .print("Pedro plays ", SPORT). /** *** Para crenças a ordem segue a estrutura de pilha. Nesse caso, como "SPORT" == basketball é a última crença adicionada, então "SPORT" assume o valor basketball. *** */