Example #1
0
    def update(self, current_time, light):
        if self.next_update_time < current_time:

            #check for notice of player
            for p in self.players.sprites():
                if ruler.distance(self, p) < 150:
                    self.following = True
                else:
                    self.following = False

            #determine color
            if not light:
                bright = 50 - ruler.distance(self, p)
                if bright < 0: bright = 0
                self.image.fill([bright, bright, bright])

            #if following
            if self.following and self.acting == False:
                self.acting = True
                s = pygame.mixer.Sound("whisper3.ogg")
                s.set_volume(100 - ruler.distance(self, p))
                s.play()
                self.action = actions.WanderNearPlayer(current_time, self, p)

            #if light was turned on, then charge
            if self.following and light:
                if not isinstance(self.action, actions.ChargePlayer):
                    s = pygame.mixer.Sound("whisper2.ogg")
                    s.play()
                    self.action = actions.ChargePlayer(current_time, self, p)

            #if light was turned off, stop charging
            if isinstance(self.action, actions.ChargePlayer) and not light:
                self.action = actions.StandStillSilently(current_time, self)

            # if wandering
            if self.acting == False:
                if random.randint(1, 100) < 30:
                    self.acting = True
                    self.action = actions.StandStillSilently(
                        current_time, self)
                else:
                    self.acting = True
                    s = pygame.mixer.Sound("slowstep1.ogg")
                    if (100 - ruler.distance(self, p) / 2) >= 0:
                        s.set_volume(100 - ruler.distance(self, p))
                    else:
                        s.set_volume(0)
                    s.play()
                    self.action = actions.WanderRandomSlow(current_time, self)
            self.action.update(current_time)
            self.next_update_time = current_time + 30
Example #2
0
    def update(self, currentTime):

        #        print('x: ' +str(self.xmomentum))
        #        print('y: ' +str(self.ymomentum))
        if self.xmomentum > 10: self.xmomentum = 10
        if self.ymomentum > 10: self.ymomentum = 10
        if self.xmomentum < -10: self.xmomentum = -10
        if self.ymomentum < -10: self.ymomentum = -10

        if ruler.distance(self.player, self.actor) < 35:
            self.xmomentum = ruler.xdir(self.actor, self.player)
            self.ymomentum = ruler.ydir(self.actor, self.player)

        self.xmomentum += ruler.xdir(self.actor, self.player)
        self.ymomentum += ruler.ydir(self.actor, self.player)

        if self.xmomentum > 0: self.right = True
        else: self.right = False
        if self.ymomentum > 0: self.down = True
        else: self.down = False

        if self.down:
            self.actor.moveDown()
        if not self.down:
            self.actor.moveUp()
        if self.right:
            self.actor.moveRight()
        if not self.right:
            self.actor.moveLeft()
Example #3
0
    def update(self, currentTime):
        dist = ruler.distance(self.actor, self.player)
        xdir = ruler.xdir(self.actor, self.player)
        ydir = ruler.ydir(self.actor, self.player)

        if dist > 150:
            if random.randint(1, 1000) < 5:
                self.actor.acting = False

        if dist > 50:
            if xdir > 0: self.right = True
            else: self.right = False
            if ydir > 0: self.down = True
            else: self.down = False

        if dist < 35:
            s = pygame.mixer.Sound("whisper2.ogg")
            if (100 - ruler.distance(self.actor, self.player)) >= 0:
                s.set_volume(
                    100.0 /
                    (100 - ruler.distance(self.actor, self.player) / 2.0))
            else:
                s.set_volume(0)
            s.play()
            if xdir > 0: self.right = False
            else: self.right = True
            if ydir > 0: self.down = False
            else: self.down = True

        if random.randint(1, 100) < 3:
            self.down = not self.down

        if random.randint(1, 100) < 3:
            self.right = not self.right

        if currentTime % 2 == 0 or dist > 50:
            if self.down:
                self.actor.moveDown()
            if not self.down:
                self.actor.moveUp()
            if self.right:
                self.actor.moveRight()
            if not self.right:
                self.actor.moveLeft()
Example #4
0
    def update(self, currentTime):
        # check to see if we quit wandering
        if random.randint(1, 1000) < 20:
            self.actor.acting = False

        # check to see if we change direction
        if random.randint(1, 100) < 3:
            s = pygame.mixer.Sound("slowstep1.ogg")
            if (100 - ruler.distance(self.actor, self.player) / 2) >= 0:
                s.set_volume(
                    100.0 /
                    (100 - ruler.distance(self.actor, self.player) / 2.0))
            else:
                s.set_volume(0)
            s.play()
            self.down = not self.down
        if random.randint(1, 100) < 3:
            s = pygame.mixer.Sound("slowstep1.ogg")
            if (100 - ruler.distance(self.actor, self.player) / 2) >= 0:
                s.set_volume(
                    100.0 /
                    (100 - ruler.distance(self.actor, self.player) / 2.0))
            else:
                s.set_volume(0)
            s.play()
            self.right = not self.right

        #call movement
        if self.down:
            self.actor.moveDown()
        if not self.down:
            self.actor.moveUp()
        if self.right:
            self.actor.moveRight()
        if not self.right:
            self.actor.moveLeft()
Example #5
0
    def update(self, current_time, light):

        for p in self.players:
            self.p = p

        #determine color
        if not light:
            bright = 100 - ruler.distance(self, self.p)
            if bright < 0: bright = 0
            self.image.fill([bright, bright / 2, bright / 2])

        if self.light and not self.lit:
            self.lit = True
            self.image.fill([60, 60, 60])
        if not self.light and self.lit:
            self.lit = False
            self.image = pygame.image.load('wallblock.png').convert()
Example #6
0
import numpy as np
from colorama import Fore, Style
import os
os.chdir("C:/Users/Lenovo/Documents/GitHub/python-eval/needleman_wunsch")
mon_fichier = open("DATASET.txt", "r")
#on le lit avec read.
import ruler
from ruler import Ruler


contenu = mon_fichier.read()
contenu = contenu.split()
print(contenu)
i=0
while i < len(contenu) : 
    ruler = Ruler(contenu[i], contenu[i+1])
    print(ruler.distance(contenu[i], contenu[i+1],ruler.compute(contenu[i], contenu[i+1])))
    i +=2


#python3 bundle.py DATASET