コード例 #1
0
 def generate(self, cols, use_prev=False):
     emap = EnvironmentalSetBuilder(None)
     prev = self.buildSlice(None)
     for col in range(cols):
         if (use_prev):
             prev = self.buildSlice(prev)
         else:
             prev = self.buildSlice(None)
         #print(prev)
         emap.add_slice_to_map(prev)
     return emap
コード例 #2
0
 def generate(self, reference_set, noise = .01, cols=100):
     print(reference_set.shape)
     generated = EnvironmentalSetBuilder(None)
     slc = np.zeros((56))
     for chunk in range(cols//4):
         for i in range(56):
             src = reference_set[random.randrange(reference_set.shape[0])]
             slc[i] = src[i]
         slc = emap.add_noise_to_slice(slc, noise)
         gslc = model.predict_slice(slc)
         emap.compare_slice_to_col_string(slc, gslc[0])
         generated.add_slice_to_map(gslc[0,:])
     return generated
コード例 #3
0
 def rolling_mid_prev_generator(self, cp, noise = .01, cols=100):
     generated = EnvironmentalSetBuilder(None)
     slc = np.zeros(56)
     slc[13] = slc[27] = slc[41] = slc[55] = 1;
     prev = np.copy(slc[0:14])
     for chunk in range(cols):
         prev = cp.buildSlice(prev)
         for i in range(14):
             slc[42+i] = prev[i]
         slc = emap.add_noise_to_slice(slc, noise)
         gslc = model.predict_slice(slc)
         generated.add_slice_to_map(gslc[0,14:28])
         slc = np.roll(slc, -14)
     return generated        
コード例 #4
0
 def generate_with_prev(self, cp, noise = .01, cols=100):
     generated = EnvironmentalSetBuilder(None)
     prev = cp.buildSlice(None)
     for chunk in range(cols//4):
         prev = cp.buildSlice(prev)
         slc = np.copy(prev)
         for i in range(3):
             prev = cp.buildSlice(prev)
             slc = np.append(slc, prev)
         slc = generated.add_noise_to_slice(slc, noise)
         gslc = model.predict_slice(slc)
         emap.compare_slice_to_col_string(slc, gslc[0])
         generated.add_slice_to_map(gslc[0,:])
     return generated
コード例 #5
0
 def rolling_generator_mid(self, reference_set, noise = .01, cols=100):
     slc = np.copy(reference_set[0])
     generated = EnvironmentalSetBuilder(None)
     for chunk in range(cols):
         for i in range(14):
             src = reference_set[random.randrange(reference_set.shape[0])]
             slc[42+i] = src[42+i]
         slc = emap.add_noise_to_slice(slc, noise)
         gslc = model.predict_slice(slc)
         generated.add_slice_to_map(gslc[0,14:28])
         #print(slc)
         slc = np.roll(slc, -14)
         #print("<<", slc)
     return generated        
コード例 #6
0
def validateSMB(mapman):
    validate = ValidateMap()
    validate.print_test_results(emap)
    smb_levels =     [
        "levels/mario-1-1.txt", "levels/mario-1-2.txt", "levels/mario-1-3.txt",
        "levels/mario-2-1.txt",
        "levels/mario-3-1.txt", "levels/mario-3-3.txt",
        "levels/mario-4-1.txt", "levels/mario-4-2.txt",
        "levels/mario-5-1.txt", "levels/mario-5-3.txt",
        "levels/mario-6-1.txt", "levels/mario-6-2.txt", "levels/mario-6-3.txt",
        "levels/mario-7-1.txt",
        "levels/mario-8-1.txt"]
    for lvl in smb_levels:
        level = mapman.get_map(lvl)
        emap = EnvironmentalSetBuilder(level)
        validate.print_test_results(emap)
        validate.write_test_results_to_csv("smb.csv", emap)
コード例 #7
0
ファイル: repair_test.py プロジェクト: BillySpelchan/MarioAE
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 16:45:59 2019

@author: spelc
"""

from mario.level import Level, EnvironmentalSetBuilder, MapManager
from mario.model import MarioModel

mapman = MapManager()
level = mapman.get_map("levels/broken.txt")
emap = EnvironmentalSetBuilder(level)


test_list = mapman.load_and_slice_levels(["levels/broken.txt"], 4, True, False)

model = MarioModel()
model.load()
for i in range(15):
    prediction = model.predict_slice(test_list[i*4])
    emap.compare_slice_to_col_string(test_list[i*4], prediction[0])

コード例 #8
0
ファイル: tests.py プロジェクト: BillySpelchan/MarioAE
    "levels/mario-4-2.txt",
    "levels/mario-5-1.txt",
    "levels/mario-5-3.txt",
    "levels/mario-6-1.txt",
    "levels/mario-6-2.txt",
    "levels/mario-6-3.txt",
    "levels/mario-7-1.txt",
    "levels/mario-8-1.txt"
]

mapman = MapManager()
level = mapman.get_map("levels/mario-1-1.txt")
for col in range(150):
    level.column_to_string(col, True)

emap = EnvironmentalSetBuilder(level)
emap.print_bin_level_slice()

sub_map = emap.get_bin_level_slice(50, 8)
noisy_map = emap.add_noise_to_slice(sub_map, 0.05)
print("slice without noise")
emap.print_bin_level_slice(sub_map)
print("slice with noise")
emap.print_bin_level_slice(noisy_map)

emap.compare_slice_to_col_string(sub_map, noisy_map)

# model testing
test_list = mapman.load_and_slice_levels(LEVELS_IN_SET, 4, True, False)
print("Test data loaded")
コード例 #9
0
 def __init__(self, model):
     self.model = model
     self.emap = EnvironmentalSetBuilder(None)
コード例 #10
0
    for col in range(cols):
        for row in range(14):
            if (emap.emap[col+start,row] > .5):
                colour = "black"
            else:
                colour = "cyan"
            #print (col, ",", row, get_char_color(comp_str[col*52+row]), ",", get_char_color(comp_str[col*52+19+row]), ",",get_char_color(comp_str[col*52+37+row]))
#            cvs.create_rectangle(12*col, 184-12*row, 12*col+12, 184-12*row+12, fill=colour)   
            cvs.create_rectangle(12*col, 12*row, 12*col+12, 12*row+12, fill=colour)   
    mainloop()

if __name__ == "__main__":
    mapman = MapManager()
    #level = mapman.get_map("levels/mario-1-1.txt")
    level = mapman.get_map("levels/broken.txt")
    emap = EnvironmentalSetBuilder(level)

    mario_level_set = [
        "levels/mario-1-1.txt", "levels/mario-1-2.txt", "levels/mario-1-3.txt",
        "levels/mario-2-1.txt",
        "levels/mario-3-1.txt", "levels/mario-3-3.txt",
        "levels/mario-4-1.txt", "levels/mario-4-2.txt",
        "levels/mario-5-1.txt", "levels/mario-5-3.txt",
        "levels/mario-6-1.txt", "levels/mario-6-2.txt", "levels/mario-6-3.txt",
        "levels/mario-7-1.txt",
        "levels/mario-8-1.txt"]

    cp = ColumnPredictor(mapman, mario_level_set)
    test_list = mapman.load_and_slice_levels(mario_level_set, 4, True, False)