def SetUpPathsManager(cls): pathToThisFile = os.path.dirname(os.path.abspath(__file__)) PathsManager.mainPath = pathToThisFile.replace("Modules\\Settings", "") PathsManager.AddFile("car", "Assets\\sprites\\car.png") PathsManager.AddFile("barrier", "Assets\\sprites\\square.png") PathsManager.AddFile("map", "Assets\\maps\\map1.txt") TrainableCar.lengthOfCompleteDrive = 1300 PathsManager.AddDirectory("albums", "Scripts\\data\\albums\\")
def SetUpBaseCar(cls): cls.ExecuteIfHasNotBeenYet(SetUpManager.SetUpImagesManager) cls.ExecuteIfHasNotBeenYet(SetUpManager.SetUpBarrier) cls.ExecuteIfHasNotBeenYet(SetUpManager.SetUpMap) BaseCar.original_rect = ImagesManager.GetImage("car").get_rect() BaseCar.map = Map() BaseCar.map.LoadFromFile(PathsManager.GetPath("map")) BaseCar.maximalRandomRotChange = SETTINGS.BASE_CAR.MAXIMAL_RANDOM_ROTATION_CHANGE BaseCar.velocityValue = SETTINGS.BASE_CAR.VALUE_OF_VELOCITY
''' TEST Displayer::PlayAlbum(self) ''' from Modules.GUI.displayer import Displayer from Modules.Simulation.map import Map from Modules.General.general_tools import PathsManager from Modules.Simulation.data_containers import Album from Modules.Settings.set_up_manager import SetUpManager import os os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (100, 100) SetUpManager.SetUp() amap = Map() amap.LoadFromFile(PathsManager.GetPath("map")) adisplayer = Displayer adisplayer.map = amap album = Album() album.LoadFromFile(PathsManager.GetPath("albums", "album1.txt")) adisplayer.PlayAlbum(album)
def SetUpBarrier(cls): cls.ExecuteIfHasNotBeenYet(SetUpManager.SetUpPathsManager) Barrier.baseSize = Vector(pg.image.load(PathsManager.GetPath("barrier")).get_size())
def SetUpImagesManager(cls): ImagesManager.Initialize() ImagesManager.AddImage("barrier", PathsManager.GetPath("barrier")) ImagesManager.AddImage("car", PathsManager.GetPath("car"), scale=0.5)
from Modules.General.general_tools import PathsManager from Modules.Settings.set_up_manager import SetUpManager SetUpManager.SetUp() DELTA_POS = 5 DELTA_ROT = 5 RangefinderTransformCalculator.CalculateRelativeRots( SETTINGS.RADAR_EQUIPPED_CAR.RANGE_OF_RADAR, SETTINGS.COMMON_FOR_MANY.NUMBER_OF_RANGEFINDERS) cam = Camera amap = Map() amap.LoadFromFile(PathsManager.GetPath("map")) TrainableCar.map = amap # for barrier in amap.listOfBarriers: # print("rect", barrier.original_rect, "pos", barrier.pos) # barrier.CalculateCorners() listOfSBarriers = [] for barrier in amap.listOfBarriers: sbarrier = SBarrier() sbarrier.Create(barrier) listOfSBarriers.append(sbarrier) class test_Car(TrainableCar):
def SaveAlbum(cls, album): ''' Save album. In other words, the course of experiment, step by step. ''' album.SaveToFile( PathsManager.GetPath( "albums", "album" + str(cls.numberOfExperiment) + ".txt"))
def SaveAlbum(cls, album): album.SaveToFile( PathsManager.GetPath( "albums", "album" + str(cls.numberOfExperiment) + ".txt"))
beginning of the script. Albums must have correct order. ''' from Modules.General.general_tools import PathsManager from Modules.GUI.displayer import Displayer from Modules.Settings.set_up_manager import SetUpManager from Modules.Simulation.data_containers import Album from Modules.Simulation.map import Map # Set which albums we want to display. listOfAlbumFilenames = ["album1.txt", "album2.txt"] # Set up environment SetUpManager.SetUp() # Load map Displayer.map = Map() Displayer.map.LoadFromFile(PathsManager.GetPath("map")) # Create list of albums (which will be merged soon). listOfAlbums = [] for albumFilename in listOfAlbumFilenames: album = Album() album.LoadFromFile(PathsManager.GetPath("albums", albumFilename)) listOfAlbums.append(album) # Merge albums and set as one. album = Album.MergedAlbums(listOfAlbums) # Show the course of the experiment. Displayer.PlayAlbum(album)