コード例 #1
0
ファイル: Server.py プロジェクト: szwetsloot/WedstrijdView
def get_race_status():
    global Race;
    if (Race.get_race_status()):
        return jsonify(result=True);
    else:
        # Check when the next race is going to start
        return jsonify(time=Race.get_next_race());
コード例 #2
0
 def __init__(self, master=None):
     # create race
     self.race = Race()
     #gets all bugs in buglist document and adds to list
     self.race.add_bugs(get_bugs())
     tk.Frame.__init__(self, master)
     self.pack()
     self.addWidgets()
     self.zoomAmount = 4
コード例 #3
0
 def getEntity(self, paramDict):
     res_race = Race()
     query = 'SELECT RaceId, Date, Time, FromPlace, ToPlace, CrewId, PlaneId ' \
             'FROM Race ' \
             'WHERE '
     equal_substr = '{attr_name} = ?'
     counter = len(paramDict)
     args = []
     for param in paramDict:
         query += equal_substr.format(attr_name=param)
         args.append(paramDict[param])
         if counter == 1:
             query += ';'
         else:
             query += ' AND '
         counter -= 1
     connection = sqlite3.connect(self._dbname)
     result = connection.execute(query, args).fetchone()
     connection.close()
     res_race.raceId = result[0]
     res_race.date = result[1]
     res_race.time = result[2]
     res_race.fromPlace = result[3]
     res_race.toPlace = result[4]
     res_race.crewId = result[5]
     res_race.planeId = result[6]
     return res_race
コード例 #4
0
    def graph(self, myRaces=-1):
        if myRaces == -1:
            myRaces = [race.name for race in self.races]

        myRaces = [Race(race, True) for race in myRaces]

        for S in myRaces:
            data = [S.data[key] for key in S.data.keys()]
            for i in range(len(data)):
                num = data[i]
                num = num.split(":")
                num = float(num[0]) + float(num[1]) / 60
                data[i] = num

            data = sorted(data)

            points = []

            for i in range(len(data)):
                temp = 0
                temp += sum([1 for d in data if abs(d - data[i]) < .7])
                points += [[data[i], temp / S.size]]
            pylab.plot([p[0] for p in points], [p[1] for p in points],
                       linewidth=3.0,
                       label=S.name)

        pylab.xlabel('time (min)')
        pylab.ylabel('density of people')
        pylab.legend(loc='upper right')
        pylab.show()
コード例 #5
0
ファイル: RaceManager.py プロジェクト: francocruces/Bacto
    def read_files(self, sub_folder):
        """
        Loads race files.
        :param sub_folder: Sub folder where the data is
        :type sub_folder: str
        """
        for file in os.listdir(os.getcwd() + sub_folder):
            if file == INSTRUCTION_FILENAME:
                continue
            f = open(os.getcwd() + sub_folder + file)

            race_data = {}
            for line in f:
                line = line.strip("\n")
                elements = line.split("=")
                if len(elements) == 2:
                    race_data[elements[0]] = elements[1]
            try:
                self.races[race_data[RACE_ID_FIELD]] = Race(
                    race_data[RACE_ID_FIELD], race_data[RACE_NAME_FIELD],
                    race_data[RACE_STRENGTH_FIELD],
                    race_data[RACE_DEFENSE_FIELD],
                    int(race_data[RACE_SPEED_FIELD]) * GAME_SPEED_FACTOR,
                    int(race_data[RACE_REPRODUCTION_TIME_FIELD]) /
                    GAME_SPEED_FACTOR, race_data[RACE_ANIMATION_ID_FIELD],
                    race_data[RACE_COLOR_FIELD], race_data[RACE_N_SIDES_FIELD])

            except KeyError:
                print("Not enough information in file")
コード例 #6
0
 def __init__(self):
     super(Manager, self).__init__()
     self._crew = Crew()
     self._plane = Plane()
     self._planeType = PlaneType()
     self._position = Position()
     self._race = Race()
     self._ticket = Ticket()
     self._worker = Worker()
コード例 #7
0
ファイル: CarRacing.py プロジェクト: shadydealer/Python-101
def main():
    c1 = Car(brand="opel", model="astra", maxSpeed=22)
    c2 = Car()
    print(int(c1))
    print(c2)

    d1 = Driver()
    d2 = Driver("Ivan", c1)
    print(d1)
    print(d2)

    r1 = Race()
コード例 #8
0
class Main:
    while True:
        print("Bienvenido Al triatlon")
        print("1. Ingrese los participantes de los Equipos")
        print("2. Ver los Equipos")
        print("3. Inicio de la carrera")
        optionMenu = input("Inserte la opcion>> ")

        if optionMenu == "1":

            for y in range(2):
                print("==================================================================================")
                print("Ingreso del Equipo Numero " + str(y + 1))
                for x in range(3):
                    p = Person()
                    print("Especialidad en ", p.typeSpeed[x])
                    p.TeamList.append(p.registerRunner(input("Ingrese el nombre: "),
                                                         int(input("Ingrese su velocidad metros/seg: ")),
                                                         p.typeSpeed[x], y))
                print("==================================================================================")

        elif optionMenu == "2":
            p = Person()
            print("==================================================================================")
            print("=====                         Participantes de la carrera                    =====")
            print("Nombre: ".ljust(15, " "), end="")
            print("Velocidad: ".ljust(15, " "), end="")
            print("Zona: ".ljust(15, " "), end="")
            print("Equipo: ".ljust(15, " "))
            for x in p.TeamList:
                x.view()
                print("==================================================================================")




        elif optionMenu == "3":
            print("==================================================================================")
            r = Race()
            p = Person()
            ganador = r.stopWatch()
            print("El equipo ganador es: " + str(ganador))

            print("==================================================================================")



        elif optionMenu == "0":
            break
        else:
            print("")
            input("No has pulsado ninguna opción correcta...\npulsa una tecla para continuar")
コード例 #9
0
 def getAll(self):
     races = []
     query = 'SELECT RaceId, Date, Time, FromPlace, ToPlace, CrewId, PlaneId ' \
             'FROM Race'
     connection = sqlite3.connect(self._dbname)
     result = connection.execute(query).fetchall()
     for race in result:
         race = Race()
         race.raceId = user_data[0]
         race.date = user_data[1]
         race.time = user_data[2]
         race.fromPlace = user_data[3]
         race.toPlace = user_data[4]
         race.crewId = user_data[5]
         race.planeId = user_data[6]
         races.append(race)
     connection.close()
     return races
コード例 #10
0
ファイル: Server.py プロジェクト: szwetsloot/WedstrijdView
from datetime import datetime, date
from locale import setlocale, LC_ALL, locale_alias

from SerialCon import SerialCon
from MysqlCon import MysqlCon
from Race import Race

global q;
global Con;
global Serial;
global Race;

RegattaId = 1; #Damen Raceroei Regatta
Con = MysqlCon(RegattaId);
Serial = SerialCon();
Race = Race(Con);

app = Flask(__name__) # Start the web application.

@app.context_processor
def inject_regatta():
    global Con;
    return dict(regatta=Con.getRegattaInfo());
    

@app.route('/') # This is the main view which is shown to the onlookers.
def index():
    return render_template('index.html')

@app.route('/_start_serial/') # Start the serial connection with the arduino
def start_serial():
コード例 #11
0
from Car import Car
from Race import Race
""" A simple car racing program where several cars race against
    each other and print out the race's progress.
    
    @author Henri Boistel de Belloy
    @version 1.0 """

# Create the cars
cico = Car("Cico", "BMW", "Matte Black", 330)
henri = Car("Henri", "VW", "Red", 120)
william = Car("William", "Mercedes", "Grey", 300)
old_jaguar = Car("Vintage", "Jaguar", "Black", 100)

# Create a list of all the racers and put them in a race.
racers = [cico, henri, william, old_jaguar]
race = Race("Rio de Janeiro", 1000, racers)

# Run the race
race.welcome_message()
race.start()
race.finish()
コード例 #12
0
class BugApp(tk.Frame):
    def __init__(self, master=None):
        # create race
        self.race = Race()
        #gets all bugs in buglist document and adds to list
        self.race.add_bugs(get_bugs())
        tk.Frame.__init__(self, master)
        self.pack()
        self.addWidgets()
        self.zoomAmount = 4

    def addWidgets(self):
        # create and zoom to map image
        self.create_img()
        self.zoom_image()
        # set up canvas size
        self.canvas = Canvas(self,
                             width=self.img.width(),
                             height=self.img.height(),
                             bg="#000000")
        # set up location of img on canvas
        self.canvas.create_image(
            (self.img.width() // 2, self.img.height() // 2),
            image=self.img,
            state="normal")
        # pack canvas into window
        self.canvas.pack()
        # initial time display
        self.bug_clock()

    def print_bugs(self):
        for i in range(0, len(self.race.bugLocs)):
            if i == 0:
                self.img.put(
                    "#00FF00",
                    (self.race.bugLocs[i][0] + 2, self.race.bugLocs[i][1] + 2))
            elif i == 1:
                self.img.put(
                    "#FF0000",
                    (self.race.bugLocs[i][0] + 2, self.race.bugLocs[i][1] + 2))
            elif i == 2:
                self.img.put(
                    "#0000FF",
                    (self.race.bugLocs[i][0] + 2, self.race.bugLocs[i][1] + 2))
            elif i == 3:
                self.img.put(
                    "#8000FF",
                    (self.race.bugLocs[i][0] + 2, self.race.bugLocs[i][1] + 2))

    def print_state(self):
        for i in range(0, self.race.mazy.xLen):
            for j in range(0, self.race.mazy.yLen):
                # if wall
                if self.race.mazy.grid[i][j] == 1:
                    self.img.put("#000000", (i + 2, j + 2))
                # if open space
                if self.race.mazy.grid[i][j] == 0:
                    self.img.put("#ffffff", (i + 2, j + 2))
                # if exit
                if self.race.mazy.grid[i][j] == 3:
                    self.img.put("#ffffff", (i + 2, j + 2))

    def bug_clock(self):
        print("bug clockin' time = ", self.race.timer)
        self.race.bug_actions()
        self.create_img()
        self.zoom_image()
        self.canvas.create_image(
            (self.img.width() // 2, self.img.height() // 2),
            image=self.img,
            state="normal")
        # increment race timer
        self.race.timer += 1
        self.after(500, self.bug_clock)

    def create_img(self):
        # set width and height of picture to make. add a row for black on each side
        width = self.race.mazy.xLen + 2
        height = self.race.mazy.yLen + 2
        # create photo image at width and height
        self.img = PhotoImage(width=width, height=height)
        self.print_state()
        self.print_bugs()

    def zoom_image(self):
        self.img = self.img.zoom(4, 4)  #self.zoomAmount, self.zoomAmount)
コード例 #13
0
from Horse import Horse
from Race import Race

name_horse1 = input("Nombre del primer caballo: ")
name_horse2 = input("Nombre del segundo caballo: ")

horse1 = Horse(name_horse1)
horse2 = Horse(name_horse2)

race = Race(horse1, horse2)

race.start()
コード例 #14
0
players += [
    Player("Milo", [
        "Quinn Koch", "William Fernholz", "Susana", "Milo Moses",
        "Beck Tompkins", "Kai Kumar", "Nick"
    ])
]

#Files for the data
files = []
files += [["Ed_Sias_Frosh-Soph_Boys", False]]
files += [["Ed_Sias_Frosh-Soph_Girls", False]]
files += [["Ed_Sias_Varsity_Girls", True]]
files += [["Ed_Sias_Varsity_Boys", True]]
files += [["Ed_Sias_Frosh_Boys", False]]

#Declaring league
L = League(players)

#Adding races to league
for file in files:
    race = Race(file[0], file[1])
    L.scoreAdd(race)

#Printing points
print(L)

#Graphing
L.graph(
    ["Ed_Sias_Frosh-Soph_Boys", "Ed_Sias_Varsity_Boys", "Ed_Sias_Frosh_Boys"])