def __init__(self): # init the renderer self.renderer = renderer.Renderer(screen_width=80, screen_height=50, fps_limit=20) # init the input self.keyhandler = k() #keyhandler.KeyHandler() # init the map self.zone = zone.Zone() # populate zone with roomer algorithm self.zone.roomer(max_rooms=30) # init fov self.fov = renderer.Fov(algo=0, light_walls=True, light_radius=10) # load zone information to fov self.fov.read_zone(self.zone) # create a player object in the zone and make him a fighter self.player = entities.Actor('@', 'player', libtcod.white, blocks=True, design=entities.Actor.designs.player, ai=entities.AI.ais.player_control) # put player to random coords inside the zone self.zone.add_entity(self.player)
def __init__(self, size=(DEFAULT_WIDTH, DEFAULT_HEIGHT), title='MegaMinerAI Bland Title Text', fullscreen=False): self.window = Window(width=size[0], height=size[1], caption=title, visible=True, fullscreen=fullscreen, resizable=True, style=Window.WINDOW_STYLE_DEFAULT, vsync=False, display=None, context=None, config=None) self.updates = [] # Set up the event dispatcher self.ed = EventDispatcher() self.ed.register_class_for_events(self) # Build the game loader self.loader = gameloader.GameLoader(self.ed) #Build the renderer self.renderer = renderer.Renderer() # Request updates self.request_update_on_draw(self.renderer.init_frame, 0) self.request_update_on_draw(self.renderer.draw_frame, 100)
def __init__(self, getter, initial_resolution=1024): self.renderer = renderer.Renderer( initial_resolution=initial_resolution) self.renderer.show_fps = True self.getter = getter self.game_is_in_interpolating_mode = False self.saved_first_index_selected = -1 self.saved_second_index_selected = -1 self.counter_start = 0 self.latent_vector_size = 512 self.saved_already = 0 self.keep_p1 = False # special case for v0b self.toggle_save_frames_in_loop = False # network hacking self.multiplier_value = 1.0 self.target_tensor = 0 ##self.target_tensors = ["16x16/Conv0_up/weight", "32x32/Conv0_up/weight", "64x64/Conv0_up/weight", "128x128/Conv0_up/weight", "256x256/Conv0_up/weight"] self.target_tensors = [ "16x16/Conv0/weight", "32x32/Conv0/weight", "64x64/Conv0/weight", "128x128/Conv0/weight", "256x256/Conv0/weight" ] # << Pre-trained PGGAN has these self.convolutional_layer_reconnection_strength = 0.3 # plotting: self.plotter = plotter.Plotter(self.renderer, getter)
def main(filename, num_frames=None): [unscrambled, scrambled] = parser.parse_file(filename) frames = [] def callback(pos, world, ticks, hopper_contents, capacity): world = copy.deepcopy(world) for x in range(len(world)): for y in range(len(world[x])): world[x][y].append(None) x, y, z = pos world[x][y][z] = (0, 255, 0) frames.append((ticks, world, hopper_contents, capacity)) d = drone.Drone(scrambled, 0, 0, callback) b = brain.Brain(d, unscrambled) try: b.mainloop() except AssertionError: traceback.print_exc() r = renderer.Renderer() if num_frames is None: r.animate(frames) else: r.animate(frames[::len(frames)//int(num_frames)] + [frames[-1]])
def task_load_map(self, file): try: self.camera = camera.Camera() self.element_tree = None self.osm_helper = None self.renderer = None from gc import collect as gc_collect gc_collect() log('-- loading map:', file) self._status(status='parsing xml') self.element_tree = ElementTree.parse(file) gc_collect() self.renderer = renderer.Renderer(self.camera, self.element_tree) try: self.osm_helper = self.renderer.osm_helper except AttributeError: log('Could not find OsmHelper in Renderer, creating a duplicate in Gui', level=2) self.osm_helper = osm_helper.OsmHelper(self.element_tree) self.settings = {} self.renderer.center_camera() self.settings['zoom'] = self.camera.zoom_level self.dirty = True log('-- map loaded') except FileNotFoundError: log('File {} does not exist.'.format(file), level=3) log(level=3) log('Use "{0} -f FILE" to specify a map file or "{0} -h" to show help.' .format(sys.argv[0]), level=3)
def __init__(self, screen): self.screen = screen self.renderer = renderer.Renderer('level.tmx') self.full_map = self.renderer.make_map() self.viewport = self.make_viewport(self.full_map) self.level_surface = self.make_level_surface(self.full_map) self.blockers = self.make_blockers('collision')
def __init__(self): self.done = False self.next = None self.quit = False self.previous = None self.screen = (10, 10) self.r = renderer.Renderer(self.screen)
def __init__(self, render, xml_file): if render: self.renderer = renderer.Renderer(600, 500, 'Maze Simulator') self.env = env.Environment(xml_file) self.pois_reached = [False] * len(self.env.pois) self.reached_goal = False
def test_render_char_head_file_error(self): rend = renderer.Renderer() with pytest.raises( FileNotFoundError, match=r"Head sprite file bin/bad_file.spr is not found"): rend.render_char("bin/taekwon.spr", "bin/bad_file.spr", "out_file_path.bmp")
def __init__(self, fractal): self.rules = fractal['rules'] self.axiom = fractal['axiom'] self.turn_angle = fractal['turn_angle'] self.draw_forward = fractal['draw_forward'] self.move_forward = fractal['move_forward'] self.starting_angle = fractal['starting_angle'] self.renderer = renderer.Renderer(800, 600, 10, self.starting_angle)
def __init__(self, args, is_train=True): if '-light' in args.net_G: CANVAS_WIDTH = 32 else: CANVAS_WIDTH = 128 self.rderr = renderer.Renderer(renderer=args.renderer, CANVAS_WIDTH=CANVAS_WIDTH, train=True) self.is_train = is_train
def __init__(self, *args, **kwargs): """Initialize a new http client for the grafana API.""" self.http_client = http.HTTPClient(*args, **kwargs) self.http_client.login() self.orgs = organizations.OrganizationManager(self.http_client) self.users = users.UserManager(self.http_client) self.dashboards = dashboards.DashboardManager(self.http_client) self.datasources = datasources.DatasourceManager(self.http_client) self.renderer = renderer.Renderer(self.http_client)
def __init__(self, args, dataloaders): self.dataloaders = dataloaders self.rderr = renderer.Renderer(renderer=args.renderer) # define G self.net_G = define_G(rdrr=self.rderr, netG=args.net_G).to(device) # Learning rate self.lr = args.lr # define optimizers self.optimizer_G = optim.Adam(self.net_G.parameters(), lr=self.lr, betas=(0.9, 0.999)) # define lr schedulers self.exp_lr_scheduler_G = lr_scheduler.StepLR(self.optimizer_G, step_size=100, gamma=0.1) # define some other vars to record the training states self.running_acc = [] self.epoch_acc = 0 self.best_val_acc = 0.0 self.best_epoch_id = 0 self.epoch_to_start = 0 self.max_num_epochs = args.max_num_epochs self.G_pred_foreground = None self.G_pred_alpha = None self.batch = None self.G_loss = None self.is_training = False self.batch_id = 0 self.epoch_id = 0 self.checkpoint_dir = args.checkpoint_dir self.vis_dir = args.vis_dir # define the loss functions self._pxl_loss = loss.PixelLoss(p=2) self.VAL_ACC = np.array([], np.float32) if os.path.exists(os.path.join(self.checkpoint_dir, 'val_acc.npy')): self.VAL_ACC = np.load( os.path.join(self.checkpoint_dir, 'val_acc.npy')) # check and create model dir if os.path.exists(self.checkpoint_dir) is False: os.mkdir(self.checkpoint_dir) if os.path.exists(self.vis_dir) is False: os.mkdir(self.vis_dir) # visualize model if args.print_models: self._visualize_models()
def __init__(self, args, device=DEVICE): self.args = args self.device = device self.rderr = renderer.Renderer(renderer=args.renderer, CANVAS_WIDTH=args.canvas_size, canvas_color=args.canvas_color) # define G self.net_G = define_G(rdrr=self.rderr, netG=args.net_G).to(device) # define some other vars to record the training states self.x_ctt = None self.x_color = None self.x_alpha = None self.G_pred_foreground = None self.G_pred_alpha = None self.G_final_pred_canvas = torch.zeros([1, 3, 128, 128]).to(device) self.G_loss = torch.tensor(0.0) self.step_id = 0 self.anchor_id = 0 self.renderer_checkpoint_dir = args.renderer_checkpoint_dir self.output_dir = args.output_dir self.lr = args.lr # define the loss functions self._pxl_loss = loss.PixelLoss(p=1) self._sinkhorn_loss = loss.SinkhornLoss(epsilon=0.01, niter=5, normalize=False) # some other vars to be initialized in child classes self.input_aspect_ratio = None self.img_path = None self.img_batch = None self.img_ = None self.final_rendered_images = None self.m_grid = None self.m_strokes_per_block = None if os.path.exists(self.output_dir) is False: os.mkdir(self.output_dir) if os.path.exists(args.vector_file): npzfile = np.load(args.vector_file) print(npzfile['x_ctt'].shape) print(npzfile['x_color'].shape) print(npzfile['x_alpha'].shape) self.x_ctt = np.copy(npzfile['x_ctt'][:, ::-1, :]) self.x_color = np.copy(npzfile['x_color'][:, ::-1, :]) self.x_alpha = np.copy(npzfile['x_alpha'][:, ::-1, :]) self.m_grid = int(np.sqrt(self.x_ctt.shape[0])) self.anchor_id = self.x_ctt.shape[1] - 1
def __init__(self, width, height): self.renderer = renderer.Renderer() self.clock = pygame.time.Clock() self.width = width self.height = height self.t_elapsed = 0 self.fps = 0 self.base_scene = None self._focus_scene_stack = []
def __init__(self): self.saveManager = saveManager.SaveManager() if input("Load level? y/n \n> ") == "y": self.level = self.saveManager.loadLevel( int(input("Enter level id:\n> "))) else: self.level = level.Level() self.level.width = int(input("Enter width:\n> ")) self.level.height = int(input("Enter height:\n> ")) self.camera = camera.Camera() self.renderer = renderer.Renderer(self.camera, self.level, editorMode=True) self.running = True self.mouseDown = False self.mouseX = 0 self.mouseY = 0 self.absMouseX = 0 self.absMouseY = 0 self.clicked = False self.keysDown = { "esc": False, "w": False, "a": False, "s": False, "d": False, "q": False, "e": False, "z": False, "x": False, "ctrl": False } self.keysPressed = { "esc": False, "w": False, "a": False, "s": False, "d": False, "q": False, "e": False, "z": False, "x": False, "ctrl": False } self.currentTime = time.clock() self.timePassed = 0 self.gridLock = 4 self.mode = MODE_WALLS self.idSelected = 0 pygame.font.init() self.uiFont = pygame.font.SysFont("Arial", 30) self.mainLoop()
def __init__(self, filename_obj='./data/obj/sphere_642.obj', lambda_smoothness=0.): super(Model, self).__init__() self.lambda_smoothness = lambda_smoothness self.vertices_predicted_a = None self.vertices_predicted_b = None with self.init_scope(): self.encoder = ResNet18(dim_out=512) self.decoder = Decoder(filename_obj) self.smoothness_loss_parameters = loss_functions.smoothness_loss_parameters(self.decoder.faces) self.renderer = renderer.Renderer() self.renderer.image_size = 128 self.renderer.viewing_angle = 15. self.renderer.anti_aliasing = True
def graphicsInitialisation(): global mapRenderer, assetManager assetManager = assets.AssetManager() assetManager.addImage("grass", "assets/images/test8060.png") assetManager.addImage("water", "assets/images/test8060water.png") assetManager.addImage("wall", "assets/images/test80Object.png") assetManager.addImage("robot1", "assets/images/test80robot1.png") assetManager.addImage("robot2", "assets/images/test80robot2.png") assetManager.addImage("hoverGround", "assets/images/test80Hover.png") assetManager.addImage("healthbar", "assets/images/healthbar.png") assetManager.addImage("healthstatus", "assets/images/healthstatus.png") assetManager.addImage("selectedCursor", "assets/images/test80Cursor.png") assetManager.load() backgroundColor = 16, 17, 18 mapRenderer = renderer.Renderer(assetManager, backgroundColor)
def __init__(self, args): self.args = args self.rderr = renderer.Renderer( renderer=args.renderer, CANVAS_WIDTH=args.canvas_size, canvas_color=args.canvas_color, ) # define G self.net_G = define_G(rdrr=self.rderr, netG=args.net_G).to(device) # define some other vars to record the training states self.x_ctt = None self.x_color = None self.x_alpha = None self.G_pred_foreground = None self.G_pred_alpha = None self.G_final_pred_canvas = torch.zeros( [1, 3, self.net_G.out_size, self.net_G.out_size]).to(device) self.G_loss = torch.tensor(0.0) self.step_id = 0 self.anchor_id = 0 self.renderer_checkpoint_dir = args.renderer_checkpoint_dir self.output_dir = args.output_dir self.lr = args.lr # define the loss functions self._pxl_loss = loss.PixelLoss(p=1) self._sinkhorn_loss = loss.SinkhornLoss(epsilon=0.01, niter=5, normalize=False) # some other vars to be initialized in child classes self.input_aspect_ratio = None self.img_path = None self.img_batch = None self.img_ = None self.final_rendered_images = None self.m_grid = None self.m_strokes_per_block = None if os.path.exists(self.output_dir) is False: os.mkdir(self.output_dir)
def main(): fun = StrangeFun() simAnnealing = SimulatedAnnealing(fun, localMovement=False, dxMovement=0.1, tStart=15.0, tEnd=3.0) ren = renderer.Renderer(w=800, h=800, samples=8, distance=(fun.maxx - fun.minx), updateFun=simAnnealing.run, updateTime=0.01) simAnnealing.add_callback(ren.unschedule) ren.addToRender(simAnnealing) ren.addToRender(fun) ren.run()
def to_wire(self, origin=None, max_size=0, **kw): """Return a string containing the message in DNS compressed wire format. Additional keyword arguments are passed to the rrset to_wire() method. @param origin: The origin to be appended to any relative names. @type origin: mname.Name object @param max_size: The maximum size of the wire format output; default is 0, which means 'the message's request payload, if nonzero, or 65536'. @type max_size: int @raises exception.TooBig: max_size was exceeded @rtype: string """ if max_size == 0: if self.request_payload != 0: max_size = self.request_payload else: max_size = 65535 if max_size < 512: max_size = 512 elif max_size > 65535: max_size = 65535 r = renderer.Renderer(self.id, self.flags, max_size, origin) for rrset in self.question: r.add_question(rrset.name, rrset.rdtype, rrset.rdclass) for rrset in self.answer: r.add_rrset(renderer.ANSWER, rrset, **kw) for rrset in self.authority: r.add_rrset(renderer.AUTHORITY, rrset, **kw) if self.edns >= 0: r.add_edns(self.edns, self.ednsflags, self.payload, self.options) for rrset in self.additional: r.add_rrset(renderer.ADDITIONAL, rrset, **kw) r.write_header() if not self.keyname is None: r.add_tsig(self.keyname, self.keyring[self.keyname], self.fudge, self.original_id, self.tsig_error, self.other_data, self.request_mac, self.keyalgorithm) self.mac = r.mac return r.get_wire()
def __init__(self, width, height): self.width = width self.height = height self.camera = camera.Camera(Vec2(0, 0), width, height) self.input_handler = input_handler.InputHandler() self.renderer = renderer.Renderer(self.width, self.height) self.fps = 60 self.player = player.Player(width/2, height/2) ## Stores all of the enemies, currently creates them self.enemies = [enemy.Enemy(10, 100, (255,0,0))] self.reflected_bullets = [] self.unreflected_bullets = [] self.regular_updates_per_render = 10 self.updates_per_render = self.regular_updates_per_render self.updates_since_render = 0 self.slomo_updates_per_render = 1
def __init__(self, w, h): self.G = 6.67384 * (10**-11) self.bodies = [] self.camera = camera.Camera(w, h) self.w = w self.h = h self.FPS = 100 self.update_count = 0 self.updates_per_render = 15 #Renderer object self.renderer = renderer.Renderer(w, h) # dt is the timestep in seconds self.dt = IntPointer(30000.0 * self.FPS) #Stack of mouse objects. The first item in the list should be prioritised last self.mouse_objects_stack = [self.camera] #List of infolabels that exist self.infolabels = [] #Add all gui elements self.add_gui() self.body_being_created = None self.editing_body = False #The current mouse object that is being clicked self.grabbed_mouse_object = None #Stores the options flags (e.g. render_tracers, render_planet_labels) self.flags = flags_file.RENDER_TRACERS + flags_file.RENDER_PLANET_LABELS + flags_file.SHADOWS + flags_file.REALISTIC self.planet_shadow = pygame.image.load("../res/shadow.png")
# coords for 2D positions. cam = pi3d.Camera(is_3d=False, at=(0, 0, 0), eye=(0, 0, -1000)) light = pi3d.Light(lightpos=(0, -500, -500), lightamb=(0.2, 0.2, 0.2)) # eyeRadius is the size, in pixels, at which the whole eye will be rendered # onscreen. eyePosition, also pixels, is the offset (left or right) from # the center point of the screen to the center of each eye. eyePosition = OLED_WIDTH // 2 + GAP // 2 eyeRadius = OLED_WIDTH / 2.1 rightEye = eye.Eye(eyeRadius, -eyePosition, 0, True) leftEye = eye.Eye(eyeRadius, eyePosition, 0, False) eyesModel = model.TwoEyesModel() renderer = renderer.Renderer(display, [leftEye, rightEye], eyesModel) leftOLEDCopier = copier.FrameCopier( renderer, leftOLED, displayWidth // 2 - eyePosition - OLED_WIDTH // 2, 0) rightOLEDCopier = copier.FrameCopier( renderer, rightOLED, displayWidth // 2 + eyePosition - OLED_WIDTH // 2, 0) leftOLEDCopier.start() rightOLEDCopier.start() thread.start_new_thread(controlThread, (renderer, eyesModel)) # Renderer's run() method never returns. And of course it needs to be invoked from the main thread. # Because pi3d... renderer.run()
import sys, pygame, renderer, tile, player pygame.init() n = 10 m = 10 r = renderer.Renderer(n, m) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.event.post(pygame.event.Event(pygame.QUIT)) r.render()
print("________________/\\\\\\________________/\\\\\\\\\\\\_____/\\\\\\\\\\\\_________________________________ ") print(" _______________\\/\\\\\\_______________\\////\\\\\\____\\////\\\\\\_________________________________ ") print(" _______________\\/\\\\\\__________/\\\\\\____\\/\\\\\\_______\\/\\\\\\_________________________________ ") print(" _____/\\\\\\\\\\\\\\\\_\\/\\\\\\_________\\///_____\\/\\\\\\_______\\/\\\\\\_____/\\\\\\\\\\\\\\\\\\_____/\\\\\\____/\\\\\\_ ") print(" ___/\\\\\\//////__\\/\\\\\\\\\\\\\\\\\\\\___/\\\\\\____\\/\\\\\\_______\\/\\\\\\____\\////////\\\\\\___\\///\\\\\\/\\\\\\/__ ") print(" __/\\\\\\_________\\/\\\\\\/////\\\\\\_\\/\\\\\\____\\/\\\\\\_______\\/\\\\\\______/\\\\\\\\\\\\\\\\\\\\____\\///\\\\\\/____ ") print(" _\\//\\\\\\________\\/\\\\\\___\\/\\\\\\_\\/\\\\\\____\\/\\\\\\_______\\/\\\\\\_____/\\\\\\/////\\\\\\_____/\\\\\\/\\\\\\___ ") print(" __\\///\\\\\\\\\\\\\\\\_\\/\\\\\\___\\/\\\\\\_\\/\\\\\\__/\\\\\\\\\\\\\\\\\\__/\\\\\\\\\\\\\\\\\\_\\//\\\\\\\\\\\\\\\\/\\\\__/\\\\\\/\\///\\\\\\_ ") print(" ____\\////////__\\///____\\///__\\///__\\/////////__\\/////////___\\////////\\//__\\///____\\///__") print() print("\t\t\t Welcome to the our lovely solution to") print("\t\t\t IF2123 Geometric Algebra's 2nd Big Mission") print() dimension = input('Please choose between "2D" or "3D": ') while ((dimension != "3D") and (dimension != "2D")): dimension = input('Please enter valid input ("2D" or "3D"): ') else: print("Your input is " + dimension) if (dimension == "3D"): s.points = [[100,100,100],[100,100,-100],[100,-100,100],[100,-100,-100],[-100,100,100],[-100,100,-100],[-100,-100,100],[-100,-100,-100]] s.points_backup = s.points[:] s.points_before = s.points[:] # MAIN s = shape.Shape() welcomeScreen() showCmds() renderer = renderer.Renderer(s, dimension) renderer.render()
def render(self): htmlrenderer = renderer.Renderer(result=self.result) htmlrenderer.run()
# see CHANGELOG.md for detailed changes in each version # # (c) 2017 kj/P1X # import world import renderer import time import players import config import sys import select import os wrd = world.World() ren = renderer.Renderer() plr = players.Players(wrd) cfg = config.Config() wrd.load_map('map_02.txt') width, height = wrd.get_map_dimensions() plr.set_master_id(plr.player_join(('HUMAN', 28, 12, 0, 3))) plr.player_join(('ROBOT1', 7, 4, 1, 1)) plr.player_join(('ROBOT2', 40, 12, 1, 1)) plr.player_join(('ROBOT3', 70, 8, 1, 1)) plr.player_join(('ROBOT4', 60, 9, 1, 1)) plr.player_join(('ROBOT5', 70, 10, 1, 1)) game_time = 0
def __init__(self): self.renderer = renderer.Renderer() self.field = field.Field.generate_field()
def GamePlayButtonClicked(self): director.replace(FadeTransition(renderer.Renderer(cfg.loadedLevel, cfg.loadedGameMode), duration = 1))