Ejemplo n.º 1
0
    def Simulate_All_Original_Bots(self):
        s = pyrosim.Simulator(debug=False,
                              play_paused=False,
                              eval_time=c.evaluationTime)

        for r in range(0, c.popSize):
            self.Send_Bot_And_Environment(s, self.originalBots[r],
                                          c.swarmPositionOffsets[r],
                                          c.swarmDrawOffsets[r], c.noFade)

        self.Print_Preamble()

        print('These were the original bots...')
        print('')

        print('')
        print('')

        print('')
        print('')

        print('')

        s.start()

        self.Draw_Visualization(-1, -1)

        s.wait_to_finish()
Ejemplo n.º 2
0
    def __init__(self,simulationType,database,positionsOfRobotsBeingSimulated,robots, play_blind=False, silent_mode=True, oldRobotID=-1):

        self.simulationType = simulationType

        self.database = database

        self.robots = robots

        self.oldRobotID = oldRobotID

        self.positionsOfRobotsBeingSimulated = positionsOfRobotsBeingSimulated

        self.Determine_Speed()

        self.simulator = pyrosim.Simulator(play_blind=play_blind, play_paused=False, eval_time=c.evaluationTime * c.ACCURACY, dt = 0.05 / c.ACCURACY, silent_mode=silent_mode, window_size=(375, 250), speed=self.speed * c.ACCURACY , xyz = [0.8317*2,-0.9817*2,0.8000*2], hpr = [121,-27.5*0.75,0.0])

        self.environment = ENVIRONMENT( self.database , self.simulator )

        self.command = COMMAND( self.database, distribution="ranked" )

        self.visualization = VISUALIZATION( self.database , self.positionsOfRobotsBeingSimulated, self.robots, oldRobotID=self.oldRobotID )

        self.messageToCrowd = MESSAGE_TO_CROWD( self.simulationType , self.robots, self.positionsOfRobotsBeingSimulated , self.command.Get_String(), self.speed, self.database, self.environment.Get_Index() )

        if self.simulationType == c.SIMULATE_SURVIVAL:
 
            self.speech = SPEECH( self.command , self.positionsOfRobotsBeingSimulated )
        else:
            self.speech = None

        self.Initialize_Evaluations()
Ejemplo n.º 3
0
    def Simulate_All_Current_Bots(self):
        s = pyrosim.Simulator(debug=False,
                              play_paused=False,
                              eval_time=c.evaluationTime)

        for r in range(0, c.popSize):
            self.Send_Bot_And_Environment(s, self.robots[r],
                                          c.swarmPositionOffsets[r],
                                          c.swarmDrawOffsets[r], c.noFade)

        self.Print_Preamble()

        print('...and these are the current bots.')
        print('')

        print('Are they doing a better job at obeying the command !' +
              self.command + '?')
        print('')

        print('')
        print('')

        print('')

        s.start()

        self.Draw_Visualization(-1, -1)
        self.Perform_Housekeeping()

        s.wait_to_finish()
Ejemplo n.º 4
0
    def Simulate_Survival(self):

        s = pyrosim.Simulator(debug=False,
                              play_paused=False,
                              eval_time=c.evaluationTime)
        self.Store_Evaluation(self.aggressorPosition)
        self.Send_Bot_And_Environment(s, self.robots[self.aggressorPosition],
                                      [0, 0, 0], [0, 0, 0], c.noFade)
        self.Print_Preamble()

        botColorName = c.colorNames[self.aggressorPosition]

        print('This is the     ' + botColorName + ' bot.')
        print('')

        color = c.colors[self.aggressorPosition]
        self.Print_Info(color)
        self.Run_Sim(s, self.aggressorPosition, -1)
        s.wait_to_finish()
Ejemplo n.º 5
0
    def Simulate_Birth_De_Novo(self):
        self.Spawn_De_Novo(self.defenderPosition)
        s = pyrosim.Simulator(eval_time=c.evaluationTime)
        self.Store_Evaluation(self.defenderPosition)
        self.Send_Bot_And_Environment(s, self.robots[self.defenderPosition],
                                      [0, 0, 0], [0, 0, 0], c.fadeIn)
        self.Print_Preamble()

        colorOfNewBot = c.colorNames[self.defenderPosition]

        print('This is the new ' + colorOfNewBot +
              ' bot, just spawned from scratch.')
        print('')

        color = c.colors[self.defenderPosition]

        self.Print_Info(color)
        self.Run_Sim(s, self.defenderPosition, -1)

        s.wait_to_finish()
Ejemplo n.º 6
0
    def Simulate_Death(self):
        s = pyrosim.Simulator(eval_time=c.evaluationTime)
        self.Store_Evaluation(self.aggressorPosition)
        self.Send_Bot_And_Environment(s, self.robots[self.aggressorPosition],
                                      [0, 0, 0], [0, 0, 0], c.noFade)
        self.Send_Bot_And_Environment(s, self.robots[self.defenderPosition],
                                      [-100, +100, 0], [100 - 1, -100 + 1, 0],
                                      c.fadeOut)
        self.Print_Preamble()
        botColorName = c.colorNames[self.aggressorPosition]

        print('This is the     ' + botColorName +
              ' bot, which just killed the bot above.')
        print('')

        color = c.colors[self.aggressorPosition]

        self.Print_Info(color)
        self.Run_Sim(s, self.aggressorPosition, self.defenderPosition)

        s.wait_to_finish()

        self.database.Kill_Bot(self.defenderID)
Ejemplo n.º 7
0
    def Simulate_Birth_From_Aggressor(self):
        self.Spawn_From_Aggressor()
        s = pyrosim.Simulator(eval_time=c.evaluationTime)
        self.Store_Evaluation(self.defenderPosition)
        self.Send_Bot_And_Environment(s, self.robots[self.defenderPosition],
                                      [0, 0, 0], [0, 0, 0], c.fadeIn)
        self.Send_Bot_And_Environment(s, self.robots[self.aggressorPosition],
                                      [-100, +100, 0], [100 - 1, -100 + 1, 0],
                                      c.noFade)
        self.Print_Preamble()

        colorOfNewBot = c.colorNames[self.defenderPosition]

        print('This is the new ' + colorOfNewBot +
              ' bot, just spawned by the bot above.')
        print('')

        color = c.colors[self.defenderPosition]

        self.Print_Info(color)
        self.Run_Sim(s, self.defenderPosition, self.aggressorPosition)

        s.wait_to_finish()
Ejemplo n.º 8
0
 def Simulate_Empty_World(self):
     s = pyrosim.Simulator(debug=False,
                           play_paused=False,
                           eval_time=c.evaluationTime)
     s.start()
     s.wait_to_finish()
Ejemplo n.º 9
0
 def Start_Evaluation(self, playBlind, playPaused):
     self.s = pyrosim.Simulator(debug=False,
                                play_blind=playBlind,
                                play_paused=playPaused,
                                eval_time=c.evaluationTime)
     self.Send_To_Simulator()