File size: 845 Bytes
eaf2e33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os

from src.olgen.ol_generator import VecOnlineGenerator
from src.olgen.olg_game import MarioOnlineGenGame
from src.olgen.olg_policy import RLGenPolicy
from src.smb.level import save_batch
from src.utils.filesys import getpath
from src.utils.img import make_img_sheet

if __name__ == '__main__':
    path = 'models/example_policy'
    # Generate with example policy model
    N, L = 8, 10
    plc = RLGenPolicy.from_path(path)
    generator = VecOnlineGenerator(plc)
    fd, _ = os.path.split(getpath(path))
    os.makedirs(fd, exist_ok=True)

    lvls = generator.generate(N, L)
    save_batch(lvls, f'{path}/samples.lvls')
    imgs = [lvl.to_img() for lvl in lvls]
    make_img_sheet(imgs, 1, save_path=f'{path}/samples.png')

    # # Play with the example policy model
    # game = MarioOnlineGenGame(path)
    # game.play()
    pass