forked from SeAIPalette/SeAIPalette
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from argparse import ArgumentParser
|
|
|
|
from Palette.env import make, SeaEnv
|
|
from Palette.constants import UP, DOWN, LEFT, RIGHT, FINISHED, BROKEN
|
|
from Palette.algos import Boustrophedon
|
|
|
|
|
|
def main(env: SeaEnv, agent: Boustrophedon):
|
|
state, info = env.reset()
|
|
while True:
|
|
act = agent.step(state, info)
|
|
if act == FINISHED:
|
|
print(f'Congrates! Covered all the places!')
|
|
break
|
|
elif act == BROKEN:
|
|
print(f'Broken!')
|
|
break
|
|
state, terminate, info = env.step(act)
|
|
if terminate:
|
|
print(f'Terminate!')
|
|
break
|
|
|
|
|
|
def get_args():
|
|
parser = ArgumentParser()
|
|
parser.add_argument('-c', "--config_name", type=str, required=True,
|
|
help="The name of config file, e.g., map0")
|
|
parser.add_argument('--render', action='store_true',
|
|
help='render or not')
|
|
return parser.parse_args()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = get_args()
|
|
sea_env = make(env_config=args.config_name, render=args.render)
|
|
algo = Boustrophedon()
|
|
main(sea_env, algo)
|