Ejemplo n.º 1
0
    def __init__(self, date, day, home_team_id, vis_team_id, time, league, db):
        self.date = date
        self.day = day
        self.vis_team_id = vis_team_id
        self.home_team_id = home_team_id
        self.time = time
        self.league = league

        self.vis_bat = Bat(vis_team_id, db)
        self.vis_pitch = Pitch(vis_team_id, db)
        self.vis_team = Team(vis_team_id, db, self.vis_bat, self.vis_pitch,
                             league)

        self.home_bat = Bat(home_team_id, db)
        self.home_pitch = Pitch(home_team_id, db)
        self.home_team = Team(home_team_id, db, self.home_bat, self.home_pitch,
                              league)

        self.h_pow_v_vs_pow, self.h_cont_v_vs_cont, \
        self.h_scor_v_vs_scor, self.h_b_over_b_p_over, \
        self.h_vs_pow_v_pow, self.h_vs_cont_v_cont, \
        self.h_vs_scor_v_scor, self.h_p_over_v_b_over = Utils.compare_teams(self.home_team, self.vis_team)
        self.total = Utils.compare_teams(self.home_team, self.vis_team)
        self.favorite, self.moneyline = Utils.get_moneyline(
            self.home_team, self.vis_team)
Ejemplo n.º 2
0
 def __init__(self,
              pitch4=Pitch("G"),
              pitch3=Pitch("C"),
              pitch2=Pitch("E"),
              pitch1=Pitch("A")):
     self.strings = {}
     self.strings[1] = String(pitch1, 19)
     self.strings[2] = String(pitch2, 19)
     self.strings[3] = String(pitch3, 19)
     self.strings[4] = String(pitch4, 19)
Ejemplo n.º 3
0
 def __init__(self,
              team: bool,
              initial_position: np.ndarray = np.asarray([0, 0]),
              pitch=Pitch()):
     self.pitch = pitch
     self.home_team = team
     self.position = initial_position
Ejemplo n.º 4
0
 def __init__(self):
     self.pitch = Pitch()
     self.home_team = Team(True, pitch=self.pitch)
     self.away_team = Team(False, pitch=self.pitch)
     self.current_frame_number = 0
     self.flip5050()
     self.store_frame()
     self.current_frame.print_frame()
Ejemplo n.º 5
0
 def __init__(self):
     self.pitch = Pitch()  # 20x10
     self.teams = [Team("A"), Team("B")]
     # set the starting coordinates
     self.teams[0].seeker.setRow(1)
     self.teams[0].seeker.setColumn(1)
     self.teams[1].seeker.setRow(18)
     self.teams[1].seeker.setColumn(1)
     self.goldenSnitch = GoldenSnitch(10, 4)
     self.points = [0, 0]
     self.charDict = {
         "seeker": "!",
         "goldenSnitch": "*",
         "border": "#",
         "emptySpace": " "
     }
     self.level = 0
     # place seeker and snitch on pitch
     self.updatePitchSeekers()
     self.updatePitchSnitch()
Ejemplo n.º 6
0
def team(name, rating):
    found = False
    for team in teams:
        if team == name:
            found = True
    if not found:
        click.echo('Team name is not valid.')
        return ''

    bat = Bat(name, db)
    pitch = Pitch(name, db)
    team = Team(name, db, bat, pitch, league)
    if rating:
        click.echo(team.get_ratings_str())
    else:
        click.echo(team.get_stats_str())
Ejemplo n.º 7
0
    def __init__(self, team: bool, pitch: Pitch = Pitch()):
        self.home_team = team
        self.pitch = pitch
        # generates starting positions
        random_positions_x: np.ndarray = np.multiply(
            np.subtract(np.random.rand(self.player_count), 0.5), pitch.pitch_x)
        random_positions_y: np.ndarray = np.multiply(
            np.subtract(np.random.rand(self.player_count), 0.5), pitch.pitch_y)
        random_positions = []

        for x, y in zip(random_positions_x, random_positions_y):
            random_positions.append(np.asarray([x, y]))

        # create players
        self.players = [
            Player(self.home_team, i_pos) for i_pos in random_positions
        ]
Ejemplo n.º 8
0
        pressure_calibration['rais_id'] = args.starting_port
    accelerometer_calibration = None
    if os.path.exists(args.accelerometer_calibration):
        with open(args.accelerometer_calibration, 'r') as yml:
            accelerometer_calibration = yaml.load(yml)
            yml.close()
        accelerometer_calibration['rais_id'] = args.starting_port

    service_objects = [
        PitchEstimate(accelerometer_calibration),
        GroundRoll(accelerometer_calibration),
        RollEstimate(),
        RollRateEstimate(),
        TurnRateComputed(),
        HeadingComputed(heading_calibration, args.starting_port),
        Pitch(args.gyro_correction, args.pitch_conf_mult),
        Roll(args.gyro_correction, args.roll_conf_mult),
        Yaw(accelerometer_calibration, args.yaw_multiplier),
        Heading(),
        RollRate(),
        HeadingTasEstimate(),
        WindEstimate(),
        PressureFactors(pressure_calibration),
        AirspeedComputed(airspeed_config),
        AirspeedEstimate(),
        AltitudeComputed(pressure_calibration),
        TrackRate(),
        TurnRate(),
        Airspeed(),
        Altitude(),
        ClimbRate(),
Ejemplo n.º 9
0
class Match():
    def __init__(self):
        self.pitch = Pitch()  # 20x10
        self.teams = [Team("A"), Team("B")]
        # set the starting coordinates
        self.teams[0].seeker.setRow(1)
        self.teams[0].seeker.setColumn(1)
        self.teams[1].seeker.setRow(18)
        self.teams[1].seeker.setColumn(1)
        self.goldenSnitch = GoldenSnitch(10, 4)
        self.points = [0, 0]
        self.charDict = {
            "seeker": "!",
            "goldenSnitch": "*",
            "border": "#",
            "emptySpace": " "
        }
        self.level = 0
        # place seeker and snitch on pitch
        self.updatePitchSeekers()
        self.updatePitchSnitch()

    def reset(self):
        # new map level
        self.newLevel()
        # set the starting coordinates
        self.teams[0].seeker.setRow(1)
        self.teams[0].seeker.setColumn(1)
        self.teams[1].seeker.setRow(18)
        self.teams[1].seeker.setColumn(1)
        self.goldenSnitch = GoldenSnitch(10, 4)
        # reset the counter for moves made
        self.teams[0].seeker.setMovesMade(0)
        self.teams[1].seeker.setMovesMade(0)

    def newLevel(self):
        maxLevel = self.pitch.getMaxLevel()
        if self.level < maxLevel:
            self.level += 1
            self.pitch.setLevel(self.level)
        else:
            print("Error no more levels")

    def noMoreLevels(self):
        if self.level == self.pitch.getMaxLevel():
            return True
        else:
            return False

    def gameEnd(self):
        print("game ends")

    def stillPlaying(self):
        if self.goldenSnitch.isFree():
            return True
        else:
            return False

    def awardPoints(self, team):
        team.addPoints(150)

    def moveSnitch(self):
        snitch = self.goldenSnitch
        if self.level > 0 and snitch.isFree():
            # if player next to then run away
            # check left
            if self.pitch.isPlayerOnPosition(snitch.getRow(),
                                             snitch.getColumn() - 1):
                # run away, right
                if self.newPosition(snitch, snitch.getRow(),
                                    snitch.getColumn() + 1):
                    self.pitch.clearPosition(snitch.getRow(),
                                             snitch.getColumn() - 1)
            # check right
            elif self.pitch.isPlayerOnPosition(snitch.getRow(),
                                               snitch.getColumn() + 1):
                # run away, left
                if self.newPosition(snitch, snitch.getRow(),
                                    snitch.getColumn() - 1):
                    self.pitch.clearPosition(snitch.getRow(),
                                             snitch.getColumn() + 1)
            # check up
            elif self.pitch.isPlayerOnPosition(snitch.getRow() - 1,
                                               snitch.getColumn()):
                # run away, down
                if self.newPosition(snitch,
                                    snitch.getRow() + 1, snitch.getColumn()):
                    self.pitch.clearPosition(snitch.getRow() - 1,
                                             snitch.getColumn())
            # check down
            elif self.pitch.isPlayerOnPosition(snitch.getRow() + 1,
                                               snitch.getColumn()):
                # run away, up
                if self.newPosition(snitch,
                                    snitch.getRow() - 1, snitch.getColumn()):
                    self.pitch.clearPosition(snitch.getRow() + 1,
                                             snitch.getColumn())
            else:
                # move random if no player next to
                randomNumber = random.randint(0, 3)
                if randomNumber == 0:  # left
                    if self.newPosition(snitch, snitch.getRow(),
                                        snitch.getColumn() - 1):
                        self.pitch.clearPosition(snitch.getRow(),
                                                 snitch.getColumn() + 1)
                elif randomNumber == 1:  # right
                    if self.newPosition(snitch, snitch.getRow(),
                                        snitch.getColumn() + 1):
                        self.pitch.clearPosition(snitch.getRow(),
                                                 snitch.getColumn() - 1)
                elif randomNumber == 2:  # up
                    if self.newPosition(snitch,
                                        snitch.getRow() - 1,
                                        snitch.getColumn()):
                        self.pitch.clearPosition(snitch.getRow() + 1,
                                                 snitch.getColumn())
                elif randomNumber == 3:  # down
                    if self.newPosition(snitch,
                                        snitch.getRow() + 1,
                                        snitch.getColumn()):
                        self.pitch.clearPosition(snitch.getRow() - 1,
                                                 snitch.getColumn())

    def update(self):
        self.checkSnitch()
        self.updatePitchSeekers()
        self.moveSnitch()
        self.updatePitchSnitch()

    def checkSnitch(self):
        snitch = self.goldenSnitch
        seeker1 = self.teams[0].seeker
        seeker2 = self.teams[1].seeker

        if snitch.getRow() == seeker1.getRow() and snitch.getColumn(
        ) == seeker1.getColumn():
            print("Snitch captured by team 1 ")
            self.awardPoints(self.teams[0])
            snitch.captured()
        elif snitch.getRow() == seeker2.getRow() and snitch.getColumn(
        ) == seeker2.getColumn():
            print("Snitch captured by team 2 ")
            self.awardPoints(self.teams[1])
            snitch.captured()

    def updatePitchSeekers(self):
        self.pitch.placeOnPitch(self.charDict["seeker"],
                                self.teams[0].seeker.getRow(),
                                self.teams[0].seeker.getColumn())
        self.pitch.placeOnPitch(self.charDict["seeker"],
                                self.teams[1].seeker.getRow(),
                                self.teams[1].seeker.getColumn())

    def updatePitchSnitch(self):
        if self.goldenSnitch.isFree():
            self.pitch.placeOnPitch(self.charDict["goldenSnitch"],
                                    self.goldenSnitch.getRow(),
                                    self.goldenSnitch.getColumn())

    def draw(self):
        return str(self.pitch)

    def printPoints(self):
        printMe = "Points: Team " + self.teams[0].name + \
            " " + str(self.teams[0].getPoints())
        printMe += " : " + \
            str(self.teams[1].getPoints()) + " Team " + self.teams[1].name
        return printMe

    def printMoves(self):
        printMe = "Moves: Team " + self.teams[0].name + \
            " " + str(self.teams[0].seeker.getMovesMade())
        printMe += " : " + \
            str(self.teams[1].seeker.getMovesMade()) + \
            " Team " + self.teams[1].name
        return printMe

    def printLevel(self):
        return "Level " + str(self.level + 1)

    def newPosition(self, object, newRow, newColumn):
        if self.pitch.isPositionFree(newRow, newColumn):
            object.move(newRow, newColumn)
            return True
        else:
            return False

    def recognizeInput(self, char):
        char = char.upper()
        if char == "A":
            # seeker1 left
            seeker = self.teams[0].seeker
            if self.newPosition(seeker, seeker.getRow(),
                                seeker.getColumn() - 1):
                self.pitch.clearPosition(seeker.getRow(),
                                         seeker.getColumn() + 1)
                seeker.addMovesMade()
        elif char == "D":
            # seeker1 right
            seeker = self.teams[0].seeker
            if self.newPosition(seeker, seeker.getRow(),
                                seeker.getColumn() + 1):
                self.pitch.clearPosition(seeker.getRow(),
                                         seeker.getColumn() - 1)
                seeker.addMovesMade()
        elif char == "W":
            # seeker1 up
            seeker = self.teams[0].seeker
            if self.newPosition(seeker,
                                seeker.getRow() - 1, seeker.getColumn()):
                self.pitch.clearPosition(seeker.getRow() + 1,
                                         seeker.getColumn())
                seeker.addMovesMade()
        elif char == "S":
            # seeker1 down
            seeker = self.teams[0].seeker
            if self.newPosition(seeker,
                                seeker.getRow() + 1, seeker.getColumn()):
                self.pitch.clearPosition(seeker.getRow() - 1,
                                         seeker.getColumn())
                seeker.addMovesMade()
        elif char == "J":
            # seeker2 left
            seeker = self.teams[1].seeker
            if self.newPosition(seeker, seeker.getRow(),
                                seeker.getColumn() - 1):
                self.pitch.clearPosition(seeker.getRow(),
                                         seeker.getColumn() + 1)
                seeker.addMovesMade()
        elif char == "L":
            # seeker2 right
            seeker = self.teams[1].seeker
            if self.newPosition(seeker, seeker.getRow(),
                                seeker.getColumn() + 1):
                self.pitch.clearPosition(seeker.getRow(),
                                         seeker.getColumn() - 1)
                seeker.addMovesMade()
        elif char == "I":
            # seeker2 up
            seeker = self.teams[1].seeker
            if self.newPosition(seeker,
                                seeker.getRow() - 1, seeker.getColumn()):
                self.pitch.clearPosition(seeker.getRow() + 1,
                                         seeker.getColumn())
                seeker.addMovesMade()
        elif char == "K":
            # seeker2 down
            seeker = self.teams[1].seeker
            if self.newPosition(seeker,
                                seeker.getRow() + 1, seeker.getColumn()):
                self.pitch.clearPosition(seeker.getRow() - 1,
                                         seeker.getColumn())
                seeker.addMovesMade()
        else:
            print("input fail")
Ejemplo n.º 10
0
from Pitch import Pitch
from Tonality import Tonality
from Tonality import Scale
from Chord import Interval
from Chord import *
from Ukulele import *


ukulele = Ukulele()
ukulele.dump()
ukulele.dump_chord(MajorTraid(Pitch("D")))

if __name__ == '__main__':
    while(True):
        print("##################################")
        pitchname = input("请输入主调:")
        print("0 大调")
        print("1 小调")
        scale = int(input("请选择调式:"))
        if(scale == 0):
            tonality = Tonality(Pitch(pitchname),Scale.Major)
            tonality.dump_detail()
        elif(scale == 1):
            tonality = Tonality(Pitch(pitchname),Scale.Minor)
            tonality.dump_detail()
        
        
Ejemplo n.º 11
0
    def __init__(self, pitch=Pitch()):
        self.pitch = pitch
        plt.ion()

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111)
Ejemplo n.º 12
0
            pressure_calibration = yaml.load(yml)
            yml.close()
    accelerometer_calibration = None
    if os.path.exists(args.accelerometer_calibration):
        with open(args.accelerometer_calibration, 'r') as yml:
            accelerometer_calibration = yaml.load(yml)
            yml.close()

    service_objects = [
        PitchEstimate(accelerometer_calibration),
        GroundRoll(accelerometer_calibration),
        RollEstimate(),
        RollRateEstimate(),
        TurnRateComputed(),
        HeadingComputed(heading_calibration),
        Pitch(),
        Roll(),
        Yaw(),
        Heading(),
        RollRate(),
        HeadingTasEstimate(),
        WindEstimate(),
        PressureFactors(pressure_calibration),
        AirspeedComputed(airspeed_config),
        AirspeedEstimate(),
        AltitudeComputed(pressure_calibration),
        TrackRate(),
        TurnRate(),
        Airspeed(),
        Altitude(),
        ClimbRate(),
Ejemplo n.º 13
0
 def __init__(self, num: int, pitch: Pitch = Pitch()):
     self.frame_number = num
     self.pitch = pitch