def __init__(self, config): self.config = config if self.config['random_seed'] != -1: random.seed(self.config['random_seed']) self.game = Game(self, self.config) if not self.config['test']: self.display = graphics.Display(self, self.config) self.running = False self.gameover = False self.timestamp = datetime.datetime.utcnow() self.messages = []
def main(): maze_file, search = get_arguments() quest = Problem(maze_file) # Initialize our search problem for this quest search_function = getattr(uninformed_search, search) start_time = time.time() solution = search_function(quest) # Invoke the search algorithm specified elapsed_time = time.time() - start_time # Print some statistics if solution is not None: print('Path length: ', len(solution)) print('Path cost: ', quest.path_cost(solution)) else: print('The quest failed!') print('Number of nodes expanded: ',(quest.nodes_expanded())) print('Processing time: {:.4f} (sec)'.format(elapsed_time)) graphics.Display(quest, solution) # Visualize the solution
def main(): maze_file, search, heuristic = get_arguments() quest = Problem(maze_file) # Initialize our search problem for this quest start_time = time.time() if search == "astar": heuristic_function = getattr(informed_search, heuristic) search_function = getattr(informed_search, search) solution = search_function(quest, heuristic_function) else: search_function = getattr(uninformed_search, search) solution = search_function(quest) # Invoke the search algorithm elapsed_time = time.time() - start_time # Print some statistics if solution is not None: print('Path length: ', len(solution)) print('Carrots consumed: ', quest.path_cost(solution)) else: print('The quest failed!') print(f'Number of nodes expanded: {quest.nodes_expanded():,}') print(f'Processing time: {elapsed_time:.4f}(sec)') graphics.Display(quest, solution) # Visualize the solution
import time, sys, os.path, os import song, graphics, layout, video import OpenGL.GL as gl import OpenGL.GLUT as glut import subprocess s = song.Song(sys.argv[1]) output = sys.argv[2] width = int(sys.argv[3]) height = int(sys.argv[4]) fps = float(sys.argv[5]) variant = int(sys.argv[6]) if len(sys.argv) > 6 else 0 headstart = 0.3 display = graphics.Display(width, height, False) renderer = layout.Renderer(display) layout = layout.SongLayout(s, s.variants.keys()[variant], renderer) file = AudioFile(s.audiofile, 48000) length = file.frames / float(file.rate) if s.videofile is not None: v = video.BackgroundVideo(s, async=False) else: v = None song_time = 0 x264 = subprocess.Popen([
import OpenGL.GLUT as glut fullscreen = False if sys.argv[1] == "-fs": sys.argv = sys.argv[1:] fullscreen = True songs_dir = sys.argv[1] width = int(sys.argv[2]) height = int(sys.argv[3]) print "Loading song DB..." song_database = songlist.SongDatabase(sys.argv[1]) print "Done." display = graphics.Display(width, height, fullscreen) renderer = layout.Renderer(display) audio = AudioEngine() print "Engine sample rate: %dHz" % audio.sample_rate queue = songlist.SongQueue() class AudioConfig(object): def __init__(self): self.volume = 50 self.mic_volume = 80 self.mic_feedback = 20 self.mic_delay = 12 self.headstart = 30
Written by Ali Zandian ([email protected]) for University project, researching a better way to gauge unlimited trees. A project at the university of Ashrafi Esfahani. """ import entities as Entities import graphics as Graphics import bot as Bot import profiler as Profiler import statistics as Statistics import game as Game import player as Player import threading as Threading import statistics # Global instances Display = Graphics.Display("Fox and Sheeps!", '#ccb684') Board = Entities.Board() Gameplay = None GameplayThread = None def Initialization(): """ Each time we are refreshing the page, we're doing this """ Display.Initialization(Board) def Start(): """ Equivalent to the action of the 'Start' button. Roughly making a new game play """ global GameplayThread global DefaultFox global oncePressed
variant = int(sys.argv[3]) if len(sys.argv) >= 4 else 0 headstart = 0.3 a = AudioEngine() a.set_mic_volume(0) print "Sample Rate: %dHz" % a.sample_rate print "Loading audio file..." file = AudioFile(s.audiofile, a.sample_rate, offset) length = file.frames / float(file.rate) print "Loaded" if fullscreen: display = graphics.Display(1920, 1200, fullscreen, aspect) else: display = graphics.Display(1280, 720, fullscreen, aspect) print display.width, display.height renderer = layout.Renderer(display) layout = layout.SongLayout(s, s.variants.keys()[variant], renderer) song_time = 0 speed_i = 0 pitch_i = 0 vocals_i = 10 t = time.time() def render():
def draw(self, time, layout): gl.glActiveTexture(gl.GL_TEXTURE0) gl.glBindTexture(gl.GL_TEXTURE_2D, self.atlas.texid) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) with self.shader: gl.glUniform1i(self.l_tex, 0) gl.glUniform1f(self.l_time, time) layout.draw(time, self) def reset(self): self.atlas = texture_font.TextureAtlas(depth=3) if __name__ == "__main__": import sys, song, graphics s = song.Song(sys.argv[1]) display = graphics.Display(1280,720) renderer = Renderer(display) layout = SongLayout(s, s.variants.keys()[-1], renderer) def render(): song_time = 1 while True: gl.glClearColor(0, 0.3, 0, 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glLoadIdentity() renderer.draw(song_time, layout) song_time += 1/70.0 yield None display.set_render_gen(render) display.main_loop()
import controller import console import player_controller #wrap this stuff up probably import basic_net_controller from ai_controllers import * import sys import traceback import time running = True try: pygame.init() console = console.Console(RULES["CONSOLE"]) console.cprint("Starting") world = actor.World(console.cprint, console.cset, RULES) display = graphics.Display(RULES["GRAPHICS"], world, console) def graphics_create_projectile(projectile): p = graphics.ProjectileSprite(projectile, display.screen) display.projectile_spts.append(p) world.g_proj = graphics_create_projectile controllers = [DodgeAimBot(a) for a in world.actors[1:]] #controllers = [] #controllers.append(player_controller.PlayerController(world.actors[0])) controllers.append(MobileBot(world.actors[0])) #controllers.append( VolleyBot(world.actors[0]) ) except: traceback.print_exc() running = False