Exemple #1
0
def main():
    filename = str(input("Filename (csv): "))
    if ".csv" not in filename:
        sys.exit("Input is not a csv file!")

    while True:
        try:
            timestep = int(
                input(
                    "Note: The time step should be small compared with the orbital"
                    " period of the bodies.\n"
                    "Time step (s): "))
            break
        except ValueError:
            print("Please insert an integer.")

    while True:
        try:
            total_frames = int(input("Total frames for the animation: "))
            break
        except ValueError:
            print("Please insert an integer")

    animation = Animate(filename, timestep)
    Animate.show(animation, total_frames)
 def crushed_death_animation(self):
     time = pygame.time.get_ticks()
     # Animate and keep on screen for half a second before killing sprite
     self.animator = Animate(self.crushed_images)
     if abs(time - self.last_frame) > 1000:
         self.player.score += 100
         self.kill()
 def __init__(self,
              x,
              y,
              image,
              speed,
              obstacles,
              floor,
              item_type,
              rise_from=None,
              animated=False):
     super(Item, self).__init__()
     if animated:
         self.animator = Animate(image)
         self.image = self.animator.get_image()
     else:
         self.animator = None
         self.image = image
     self.item_type = item_type
     self.rect = self.image.get_rect()
     self.rect.left, self.rect.top = x, y
     self.speed = speed
     self.jump_speed = 0
     self.obstacles = obstacles  # objects that the item may collide with
     self.floor = floor  # rects for the floor
     self.rise_from = rise_from
 def __init__(self, screen, x, y, player, floor, block, goombas, koopas):
     self.walk_images = [
         'images/GoombaLeftBoot.png', 'images/GoombaRightBoot.png'
     ]
     self.upside_down_images = [
         'images/GoombaUD1.png', 'images/GoombaUD2.png'
     ]
     self.crushed_images = ['images/GoombaCrushed.png']
     self.animator = Animate(self.walk_images)
     image = self.animator.get_image()
     super().__init__(screen, image, x, y, player, floor, block, goombas,
                      koopas)
Exemple #5
0
 def __init__(self, x, y, screen, points=100):
     super(Coin, self).__init__()
     images = [
         'images/Coin-1.png', 'images/Coin-2.png', 'images/Coin-3.png',
         'images/Coin-4.png'
     ]
     self.animator = Animate(images)
     self.image = self.animator.get_image()
     self.rect = self.image.get_rect()
     self.rect.left, self.rect.top = x, y
     self.screen = screen
     self.points = points
 def __init__(self,
              x,
              y,
              norm_images,
              explode_images,
              obstacles,
              floor,
              goomba,
              koopa,
              speed=5):
     self.norm_animator = Animate(norm_images)
     self.explode_animator = Animate(explode_images, repeat=False)
     self.image = self.norm_animator.get_image()
     self.rect = self.image.get_rect()
     self.rect.x, self.rect.y = x, y
     self.obstacles = obstacles
     self.floor = floor
     self.goomba, self.koopa = goomba, koopa
     self.speed_x = speed
     self.speed_y = speed
     self.active = True
     super(FireBall, self).__init__()
 def upside_down_death_animation(self):
     time = pygame.time.get_ticks()
     # Animate getting hit (Go up for two seconds)
     if self.death_animation_frame == 0:
         self.rect.y += (abs(self.ENEMY_DIRECTION) * self.ENEMY_SPEED)
     else:
         self.rect.y += (abs(self.ENEMY_DIRECTION) * self.ENEMY_SPEED * -1)
     # After two seconds fall down while upside down
     if self.death_animation_frame == 0 and abs(self.last_frame -
                                                time) > 2000:
         self.animator = Animate(self.UD_death_images)
         self.death_animation_frame += 1
     # Kill off after 10 seconds (Enough to be off screen)
     if abs(self.last_frame - time) > 10000:
         self.player.score += 100
         self.kill()
    def checkpoint(self, i, pop):
        init = self.initial_conditions()
        sim = self.simulate(pop[0], init)

        basename = self.checkpoint_basename.format(i)
        with open(basename + '.csv', 'w') as f:
            writer = csv.DictWriter(f, sim[0].keys())
            writer.writeheader()
            writer.writerows(sim)

        with open(basename + '.pickle', 'wb') as f:
            pickle.dump(pop, f)

        if self.checkpoint_animation:
            Animate(sim, init.l, 2 * init.dt * 1000, tight_layout=True).show()

        if self.checkpoint_summary:
            self.plot(sim)
Exemple #9
0
def cozmo_run(robot, position=None, deliver=None):
    global count

    if robot.is_ready:
        if not robot.has_in_progress_actions:
            if robot.is_on_charger:
                robot.drive_off_charger_contacts().wait_for_completed()

            print("Count: %s" % count)
            if position:
                reward_run(robot, position=position, deliver=deliver)
                count = 0
            else:
                if count == 90:
                    anim = Animate()
                    anim.anim_run(robot)
                    count = 0
                else:
                    count += 1
 def __init__(self, screen, x, y, player, floor, block, goombas, koopas):
     self.name_1, self.name_2 = None, None
     self.name_1 = Enemy.img_file('KoopaWalkLeft_1', 25, 40)
     self.name_2 = Enemy.img_file('KoopaWalkLeft_2', 25, 40)
     self.left_images = [self.name_1, self.name_2]
     self.name_1 = Enemy.img_file('KoopaWalkRight_1', 25, 40)
     self.name_2 = Enemy.img_file('KoopaWalkRight_2', 25, 40)
     self.right_images = [self.name_1, self.name_2]
     self.name_1 = Enemy.img_file('KoopaShell', 35, 30)
     self.death_images = [self.name_1]
     self.name_1 = Enemy.img_file('KoopaShellUD', 35, 30)
     self.UD_death_images = [self.name_1]
     self.name_1 = Enemy.img_file('KoopaLegs', 35, 30)
     self.feet_images = [self.name_1]
     self.animator = Animate(self.left_images)
     image = self.animator.get_image()
     super().__init__(screen, image, x, y, player, floor, block, goombas,
                      koopas)
     self.collision_flag = False
     self.feet_frame = 0
     self.counter = 0
Exemple #11
0
def plotPose(pose_list, dl):
    """
    Method for plotting a pose given a list of poses (in pca format).
    The PCA is trained on the training data, and we use the inverse
    transformation to translate the 10 learned factors back to real (normalized)
    coordinates.

    Keyword Arguments
    pose_list - one frame output of the decoder
    dl - dataloader object that contains our training data
    """
    # pose_list = dl.pca.inverse_transform(pose_list)
    # plt.plot(pose_list[0:10:2], pose_list[1:10:2])
    # plt.plot([pose_list[2], pose_list[10]], [pose_list[3], pose_list[11]])
    # plt.plot(pose_list[10::2], pose_list[11::2])
    # plt.show()

    pose_list = dl.pca.inverse_transform(pose_list)
    animation_object = Animate((-2, 2), (-2, 2))
    anim = animation_object.animate(pose_list, 500)
    anim.save('animation.html', writer='imagemick', fps=60)
Exemple #12
0
	def set_emotion(self, valence=None, arousal=None, r=None, phi=None, degrees=False, anim_time=0):
		self.isEmotion = True

		# TODO: Phi in deg or radians? Internally probably radians
		e = 0 + 0j
		if valence is not None and arousal is not None:
			e = valence + arousal*1j
		elif r is not None and phi is not None:
			if degrees:
				phi = phi * math.pi/180.0
			e = cmath.rect(r, phi)
		else:
			raise RuntimeError("Bad combination of parameters. Either valence and arousal or r and phi need to be provided.")

		# Make sure emotion is restricted to within unity circle.
		if abs(e) > 1.0:
			e = cmath.rect(1.0, cmath.phase(e))

		if anim_time > 0:
			self._anim = Animate([0, anim_time], [self._emotion, e])
		else:
			self._emotion = e
 def __init__(self,
              x,
              y,
              screen,
              map_group,
              game_objects,
              item=MUSHROOM,
              static_img=None):
     if not static_img:
         images = [
             'images/Question-Block-1.png', 'images/Question-Block-2.png',
             'images/Question-Block-3.png'
         ]
         self.animator = Animate(images)
         initial_image = self.animator.get_image()
     else:
         initial_image = static_img
         self.animator = None
     self.game_objects = game_objects
     if item in (QuestionBlock.MUSHROOM, QuestionBlock.FIRE_FLOWER,
                 QuestionBlock.STARMAN, QuestionBlock.ONE_UP):
         self.item = item
         coins = None
     else:
         self.item = None
         coins = 1
     super(QuestionBlock, self).__init__(x,
                                         y,
                                         initial_image,
                                         screen,
                                         map_group,
                                         coins=coins if coins else 0)
     if self.item:
         self.sound = mixer.Sound('audio/Powerup-Appear.wav')
     self.blank_img = image.load(
         'images/super-mario-empty-block.png')  # force blank image
     self.state['blank'] = False
Exemple #14
0
pygame.init()

settings = Settings()
screen_size = settings.screen_length, settings.screen_height
screen = pygame.display.set_mode(screen_size)
pygame.display.set_caption("Atom Land")

player = Player(screen, settings)
levels = LevelDesign(settings)

basic_enemies = Group()
game_functions.create_basic_enemies(screen, basic_enemies, levels, settings)

buttons = []
fight_enemies = Group()
question_box = []

animate_player = Animate("images/player_walk_down/player_walk", settings)
animate_player.start()

while True:
    game_functions.check_pygame_events(player, basic_enemies, fight_enemies,
                                       buttons, question_box, levels, screen,
                                       settings)
    game_functions.update_sprites(player, basic_enemies, fight_enemies,
                                  buttons, question_box, screen, levels,
                                  settings)

    game_functions.update_screen(player, basic_enemies, fight_enemies, buttons,
                                 question_box, screen, settings)
    def koopa_physics(self):
        self.check_boundary()

        if not self.check_floor() and self.start_movement:
            self.rect.y += (abs(self.ENEMY_DIRECTION) * self.ENEMY_GRAVITY)
            self.rect.x = self.rect.x + (self.ENEMY_DIRECTION *
                                         (self.ENEMY_SPEED - 1))
        if self.check_floor() and self.start_movement:
            self.rect.x = self.rect.x + (self.ENEMY_DIRECTION *
                                         self.ENEMY_SPEED)

        # If collision
        if self.check_collisions():
            # Gets stomped on -> stop
            # Collides with player when in shell -> Movement
            if self.enemy_player_collide_flag and self.shell_mode:
                time = pygame.time.get_ticks()
                # Only put in shell if needed
                if self.death_animation_frame == 0:
                    self.animator = Animate(self.death_images)
                    self.image = self.animator.get_image()
                    tempx, tempy = self.rect.x, self.rect.y
                    self.rect = self.image.get_rect()
                    self.rect.x = tempx
                    self.rect.y = tempy
                    self.death_animation_frame += 1
                # Collide with player in shell mode causes movement
                if self.check_player_shell_collision():
                    self.shell_movement = True
                # Move shell depending on which side was hit
                if self.shell_movement:
                    if self.death_animation_frame == 1:
                        # Left side was hit
                        if self.rect.x >= self.player.rect.x:
                            self.ENEMY_DIRECTION = abs(self.ENEMY_DIRECTION)
                        # Right side hit
                        else:
                            self.ENEMY_DIRECTION = abs(
                                self.ENEMY_DIRECTION) * -1
                        self.death_animation_frame += 1
                    if self.check_block_collision():
                        pass
                    self.rect.x += (self.ENEMY_DIRECTION * self.ENEMY_SPEED)
                # Not being hit by player again makes koopa pop out of shell
                if not self.check_player_shell_collision() and abs(self.last_frame - time) > 8000 and not\
                        self.shell_movement:
                    if self.counter == 0:
                        self.animator = Animate(self.feet_images)
                        self.feet_frame = pygame.time.get_ticks()
                        self.counter += 1
                    if abs(self.feet_frame - time) > 3000:
                        self.counter = 0
                        self.ENEMY_DIRECTION = abs(self.ENEMY_DIRECTION) * -1
                        self.animator = Animate(self.left_images)
                        self.enemy_player_collide_flag = False
                        self.shell_mode = False
            # Collision with map or block
            elif self.enemy_block_collide_flag:
                # Killed by player hitting block
                if self.block_enemy_kill:
                    self.dead = True
                    self.upside_down_death_animation()
                # If colliding with map (i.e. Pipe) change direction
                else:
                    self.rect.x += (self.ENEMY_DIRECTION * self.ENEMY_SPEED)
                    self.enemy_block_collide_flag = False
            # If colliding with goomba change direction
            elif self.enemy_goomba_collide_flag:
                self.rect.x += (self.ENEMY_DIRECTION * self.ENEMY_SPEED)
                self.enemy_goomba_collide_flag = False
            elif self.enemy_koopa_collide_flag:
                # Colliding with koopa shell thats moving
                if self.shell_enemy_kill:
                    self.dead = True
                    self.upside_down_death_animation()
                # Colliding with koopa enemy or shell
                else:
                    self.rect.x += (self.ENEMY_DIRECTION * self.ENEMY_SPEED)
                    self.enemy_koopa_collide_flag = False
Exemple #16
0
from weather import Weather
from ranking import Ranking
from tictactoe import TicTacToe
from replit import db
import re

#############
# Ryan Tan, Timothy Wu
# For our own discord server.
# Requires repl to run this program, particular the database
#
################

#Load in the client from the discord api
client = discord.Client()
animate = Animate()
ranking = Ranking()
tictoe = TicTacToe()

emote = "⣿⣯⣿⣟⣟⡼⣿⡼⡿⣷⣿⣿⣿⠽⡟⢋⣿⣿⠘⣼⣷⡟⠻⡿⣷⡼⣝⡿⡾⣿\n⣿⣿⣿⣿⢁⣵⡇⡟⠀⣿⣿⣿⠇⠀⡇⣴⣿⣿⣧⣿⣿⡇⠀⢣⣿⣷⣀⡏⢻⣿\n⣿⣿⠿⣿⣿⣿⠷⠁⠀⠛⠛⠋⠀⠂⠹⠿⠿⠿⠿⠿⠉⠁⠀⠘⠛⠛⠛⠃⢸⣯\n⣿⡇⠀⣄⣀⣀⣈⣁⠈⠉⠃⠀⠀⠀⠀⠀⠀⠀⠀⠠⠎⠈⠀⣀⣁⣀⣀⡠⠈⠉\n⣿⣯⣽⡿⢟⡿⠿⠛⠛⠿⣶⣄⠀⠀⠀⠀⠀⠀⠈⢠⣴⣾⠛⠛⠿⠻⠛⠿⣷⣶\n⣿⣿⣿⠀⠀⠀⣿⡿⣶⣿⣫⠉⠀⠀⠀⠀⠀⠀⠀⠈⠰⣿⠿⠾⣿⡇⠀⠀⢺⣿\n⣿⣿⠻⡀⠀⠀⠙⠏⠒⡻⠃⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠐⡓⢚⠟⠁⠀⠀⡾⢫\n⣿⣿⠀⠀⡀⠀⠀⡈⣉⡀⡠⣐⣅⣽⣺⣿⣯⡡⣴⣴⣔⣠⣀⣀⡀⢀⡀⡀⠀⣸\n⣿⣿⣷⣿⣟⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⢾⣷⣿\n⣿⣿⣟⠫⡾⠟⠫⢾⠯⡻⢟⡽⢶⢿⣿⣿⡛⠕⠎⠻⠝⠪⢖⠝⠟⢫⠾⠜⢿⣿\n⣿⣿⣿⠉⠀⠀⠀⠀⠈⠀⠀⠀⠀⣰⣋⣀⣈⣢⠀⠀⠀⠀⠀⠀⠀⠀⠀⣐⢸⣿\n⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿\n⣿⣿⣿⣿⣦⡔⠀⠀⠀⠀⠀⠀⢻⣿⡿⣿⣿⢽⣿⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿\n⣿⣿⣿⣿⣿⣿⣶⣤⣀⠀⠀⠀⠘⠛⢅⣙⣙⠿⠉⠀⠀⠀⢀⣠⣴⣿⣿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣅⠀⠓⠀⠀⣀⣠⣴⣺⣿⣿⣿⣿⣿⣿⣿⣿\n"

riebot_help_msg = "`animate <gif_number>(optional)` - Send out a random(or selected) gif from the collection.\n`animate delete <gif_number>` - Deletes a selected gif from the collection. \n`animate insert <tenor gif url>` - Inserts a gif into the collection.\n`test` - testing\n`weather <zip-code>` - Reports the weather from the zipcode.\n`whotao` - Whotao?"

#This is the response that the bot should have when it is ready/loaded.
@client.event
async def on_ready():
  await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="the Sounds of Rie"))
  print("We have logged in as {0.user}".format(client))

@client.event
#Check on the message and see how to process it.
Exemple #17
0
 def __init__(self, times, values):
     # Workaround to convert lua tables to lists
     self._a = Animate(list(times.values()), list(values.values()))
def main():
    """Test the simulation with Mars and its moons."""
    anim = Animate('marsandmoons.csv', 86)
    anim.show(300)
Exemple #19
0
def handleCommand(cmd, scr=True):
    global anim
    global curWorld
    global proofMode
    #strip any comments
    i = cmd.find("//")
    if i >= 0:
        cmd = cmd[:i].strip()

    if anim:
        if scr and cmd:
            print "a>" + cmd
        result = anim.dispatch(cmd)
        if result.startswith("_exit"):
            print " " + result[5:]
            anim = None
        elif result:
            print " " + result
        return 0

    if proofMode:
        if scr and cmd:
            print proofMode.prompt + ">" + cmd
        result = proofMode.dispatch(cmd)
        if result.startswith("_exit"):
            print " " + result[5:]
            proofMode = None
        elif result:
            print result
        return 0

    if cmd == "exit":
        return -1
    elif cmd == "animate":
        anim = Animate(curWorld)
    elif cmd == "proof":
        proofMode = curWorld.ProofMode(curWorld)
    elif cmd.startswith("load"):
        words = parseCommand(cmd)
        for f in words[1:]:
            loadFile(f)
    elif cmd.startswith("print"):
        words = parseCommand(cmd)
        if len(words) == 1:
            print pPrint(curWorld.top)
        else:
            fName = words[1]
            if "." not in fName:
                fName = fName + ".n.out"
            f = open(fName, "w")
            f.write(pPrint(curWorld.top))
            f.close()
            print "Success writing to: " + fName
    elif cmd.startswith("latex"):
        words = parseCommand(cmd)
        if len(words) == 1:
            print lPrint(curWorld.top)
        else:
            fName = words[1]
            if "." not in fName:
                fName = fName + ".tex"
            f = open(fName, "w")
            f.write(lPrint(curWorld.top))
            f.close()
            print "Success writing to: " + fName
    elif cmd.startswith("sh "):
        try:
            subprocess.call(cmd[3:], shell=True)
        except Exception as e:
            print "Error trying to execute '" + cmd[3:] + "': " + str(e)
        else:
            print "Executed " + cmd[3:]
    elif cmd == "**":
        curWorld.err = False
    elif cmd.startswith("*"):
        if curWorld.err:
            return handleCommand(cmd[1:])
    elif cmd == "help":
        print "N v0.09"
        print
        print "Supported commands:"
        print "  help                  print this message"
        print "  exit                  exit n"
        print "  load filenames        load the specified files"
        print "  latex [filename]      output the current formal system as latex"
        print "  print [filename]      output the current formal system in the source format"
        print "  proof                 switch to proof mode"
        print "  animate               switch to animation mode"
        print
        print "  * cmd                 execute cmd if an error has occured"
        print "  **                    reset the error flag"
        print
    elif cmd == "":
        pass
    else:
        print "Unknown command: ", cmd
        return 1

    return 0
Exemple #20
0
from animate import Animate
from painter import Painter
import numpy as np

#Paint a random painting
painting = Painter()
painting.generate_n_frames(300)
Animate(painting.frames)