P3 überarbeitet
This commit is contained in:
75
P3/main.py
Normal file
75
P3/main.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import random
|
||||
import gym
|
||||
from ai_gym import fh_ac_ai_gym
|
||||
from Task.Propositions import *
|
||||
from Task.Propositions2 import *
|
||||
|
||||
#Create Gym environment
|
||||
wumpus_env = gym.make('Wumpus-v0', disable_env_checker=True)
|
||||
wumpus_env.reset()
|
||||
wumpus_env.render()
|
||||
|
||||
#Define the possible actions
|
||||
REVERSE_ACTION_DICT= {0: "WALK", 1:"TURNLEFT", 2:"TURNRIGHT", 3:"GRAB", 4: "SHOOT", 5:"CLIMB"}
|
||||
POSSIBLE_ACTIONS = {v: k for k, v in REVERSE_ACTION_DICT.items()}
|
||||
|
||||
|
||||
print("=" * 70)
|
||||
|
||||
agent = KnowledgebasedAgent("CNF")
|
||||
obs = wumpus_env.step(1)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("W21")
|
||||
agent.ASK("W12")
|
||||
wumpus_env.render()
|
||||
|
||||
print("=" * 70)
|
||||
obs = wumpus_env.step(0)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("W21")
|
||||
agent.ASK("W12")
|
||||
wumpus_env.render()
|
||||
|
||||
print("=" * 70)
|
||||
obs = wumpus_env.step(0)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("P12")
|
||||
agent.ASK("P23")
|
||||
agent.ASK("P14")
|
||||
wumpus_env.render()
|
||||
|
||||
print("=" * 70)
|
||||
wumpus_env.step(2)
|
||||
obs = wumpus_env.step(0)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("P12")
|
||||
agent.ASK("P23")
|
||||
agent.ASK("P14")
|
||||
wumpus_env.render()
|
||||
|
||||
wumpus_env.reset()
|
||||
print("=" * 70)
|
||||
print("=" * 70)
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
agent = HornKnowledgebasedAgent()
|
||||
wumpus_env.step(1)
|
||||
obs = wumpus_env.step(2)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("W21")
|
||||
agent.ASK("W12")
|
||||
wumpus_env.render()
|
||||
|
||||
print("=" * 70)
|
||||
obs = wumpus_env.step(0)
|
||||
print(obs)
|
||||
agent.TELL(obs)
|
||||
agent.ASK("W21")
|
||||
agent.ASK("W12")
|
||||
wumpus_env.render()
|
||||
Reference in New Issue
Block a user