예제 #1
0
    def initialize_agent(self):
        # This runs once before the bot starts up
        self.controllerState = SimpleControllerState()
        self.stateMachine = StateMachine(self)
        self.spikeWatcher = SpikeWatcher()

        self.lastTime = 0
        self.realLastTime = 0
        self.doneTicks = 0
        self.skippedTicks = 0
        self.ticksThisPacket = 0
        self.FPS = 120
        self.lastQuickChatTime = 0
        self.secondMessage = None
        self.currentTick = 0
        self.firstTpsReport = True

        self.game = Game()
        self.game.set_mode("soccar")
        self.car = self.game.cars[self.index]
        self.reorientML = ReorientML(self.car)

        self.lastJumpTick = -math.inf
        self.maxDodgeTick = 0
        self.jumpReleased = True
        self.lastDodgeTick = -math.inf
        self.lastController = SimpleControllerState()
예제 #2
0
class Chatbot(object):

    SM = StateMachine()

    def run(self, chat_in):
        chat_out = self.SM.event(make_lower(chat_in))
        return chat_out
예제 #3
0
    def initialize_agent(self):
        # This runs once before the bot starts up
        self.controllerState = SimpleControllerState()
        self.stateMachine = StateMachine(self)

        self.lastTime = 0
        self.realLastTime = 0
        self.doneTicks = 0
        self.skippedTicks = 0
        self.ticksThisPacket = 0
        self.FPS = 120
        self.lastQuickChatTime = 0
        self.secondMessage = None
        self.tick = 0
        self.firstTpsReport = True
예제 #4
0
파일: ai.py 프로젝트: EdwardStables/STUART
 def _run(self):
     self.robot = StateMachine()
     t1 = time()
     self.status = "Idle()"
     self.last_state = "Idle()"
     while True:
         slp = self.loop_time - (time() - t1)
         if slp > 0:
             sleep(slp)
         t1 = time()
         self.check_messages()
         self.robot.event()
         new_state = self.robot.state
         if self.last_state != new_state:
             #print("state update:", new_state)
             self.last_state = new_state
             self.send_state_update(new_state)
예제 #5
0
def Run(host="0.0.0.0", port="99", config_path=None):
    '''
		Run the web server for the site specified by the routes in this module.

		:param config_path: Optional additional or alternate configuration file.
	'''
    Api.SetMyUri(":".join([host, port]))

    #Initialize the instance that the API supports.
    api.stateMachineInstance = StateMachine()
    try:
        with open("./state_graph.temp", "r") as f:
            api.stateMachineInstance.FromStateGraph(json.loads(f.read()))
    except (IOError, ValueError):
        pass

    webapp.run(host=host, port=port)

    with open("./state_graph.temp", "w") as f:
        f.write(json.dumps(api.stateMachineInstance.GetStateGraph()))
예제 #6
0
    def __init__(self):
        """
        Initialise finite state machine
        """
        RunExp.__init__(self)

        self.fsm = StateMachine()
        self.fsm.add_state('start', self.start_handler, end_state=False)
        self.fsm.add_state('habituation',
                           self.habituation_handler,
                           end_state=False)
        self.fsm.add_state('pause', self.pause_handler, end_state=False)
        self.fsm.add_state('init_trial',
                           self.init_trial_handler,
                           end_state=False)
        self.fsm.add_state('iti', self.iti_handler, end_state=False)
        self.fsm.add_state('pre_probe',
                           self.pre_probe_handler,
                           end_state=False)
        self.fsm.add_state('probe', self.probe_handler, end_state=False)
        self.fsm.add_state('response', self.response_handler, end_state=False)
        self.fsm.add_state('end', self.end_handler, end_state=True)
        self.fsm.set_start('start')
        self.go_next = False
예제 #7
0
          "               ",
          printCycle(cycle - 2),
          ": ",
          s(log[cycle + 5]),
          "\n                                      ",
          printCycle(cycle - 1),
          ": ",
          s(log[cycle + 6]),
          "\n   name       = ",
          flag.name,
          "\n   question   = ",
          flag.question,
          end="")


cuteRobot = StateMachine()

# Keep track of states
log = [" ", " ", " ", " ", " ", " ", " "]

for i in range(3000):

    cuteRobot.event("")

    t_end = time.time() + 2

    while time.time() < t_end:

        if keyboard.is_pressed('1'):
            flag.person = not flag.person
        if keyboard.is_pressed('2'):
예제 #8
0
# setup as a station

#battery.volts()
#print("Battery volts: {0:.2f}v".format(battery.volts()))
#if battery.alarm():
#    print('Battery Needs a charge')
#else:
#    print('Battery okay')

# roughly works ...
vin = Vin('P16', 'P10')
led = Led('P11')
battery = Battery(py)

# still need work
stateMachine = StateMachine()
bilgeSwitch = BilgeSwitch('P13')
temp = Temp('P9')
button = Button('P14')

check = Checks(led, vin, bilgeSwitch, battery, temp, stateMachine)
check.whichToDo()

# https://forum.pycom.io/topic/1626/pytrack-gps-api/12

# to sleep with GPS VBACKUP on
# should go down to 17ua
# https://forum.pycom.io/topic/2525/power-consumption/16
#
# py.go_to_sleep(True)
예제 #9
0
from states import flag
from stateMachine import StateMachine
import os

robot = StateMachine()

prompt = "\n> "
while True:

    os.system('clear')
    print("")

    robot.event("")

    print("\nCurrent State:", robot.state)
    flag.printFlags()

    x = input(prompt)

    if x == "person appears":
        flag.person = True
        prompt = "\n> person "
    elif x == "disappears" or x == "(person disappears)":
        flag.person = False
        prompt = "\n> "
    elif x == "asks question":
        flag.processing = True
        prompt = "\n> their question is "
    elif x == "invalid":
        flag.processing = False
        flag.question = -1
예제 #10
0
    GPIO.cleanup()

    try:
        logger.info('Terminated root process - PID: %s', os.getpid())
        unmountGluster()
    except Exception:
        logger.critical(traceback.format_exc())


def sigtermHandler(signum, stackFrame):
    excStopper.set()
    logger.info('Caught SIGTERM')
    raise SystemExit


if __name__ == '__main__':
    try:
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)

        signal.signal(signal.SIGTERM, sigtermHandler)

        with StateMachine() as stateMachine:
            excChildListener()

    except Exception:
        logger.critical(traceback.format_exc())

    finally:
        clean()