Exemplo n.º 1
0
    def __init__(self, auto, debug):
        # initialize car object
        self.myCar = car()
        # initialize current state
        self.state = "f"
        # initialize map
        self.myMap = map()
        # initialize action counter
        self.actioncounter = 0
        # initialize camera
        self.myCamera = camera()
        # initialize global variables
        vars.init()
        # debug or not
        self.debug = debug

        # get ready
        time.sleep(1)

        print("myCar and myCamera startup completed")

        if auto:
            # auto drive
            print("autoDrive mode")
            self.autoDrive()

        else:
            # manual drive
            print("manualDrive mode")
            self.manualDrive()
Exemplo n.º 2
0
 def __init__(self, host, port, pw):
     self.host = host
     self.port = port
     self.sockets = []
     self.scontroller = SocketController()
     self.crypto = CryptoController()
     self.server = self.scontroller.connServer(self.host, self.port)
     vars.init()
     vars.keypair = self.crypto.genAsymKeys()
     vars.aeskey = self.crypto.genAesKey(pw)
     init(self.crypto)
     # Trap keyboard interrupts
     signal.signal(signal.SIGINT, self.sighandler)
    def __init__(self, auto=True):
        # initialize car object
        self.myCar = car()
        # initialize camera
        self.myCamera = camera()
        # initialize global variables
        vars.init()

        # get ready
        time.sleep(2)

        print("myCar and myCamera startup completed")

        if auto:
            # auto drive
            print("autoDrive mode")
            self.autoDrive()

        else:
            # manual drive
            print("manualDrive mode")
            self.manualDrive()
Exemplo n.º 4
0
import numpy as np
import random
import vars as v
v.init()


#players should assess their own fitness
class Layer:
    def __init__(self, nodes, past):
        self.weights = 2 * np.random.sample((nodes, past)) - 1
        self.bias = random.uniform(-1, 1)
        self.vals = np.zeros((nodes, past))

    def calc(self, inputs):
        rows = len(self.weights)
        input_mat = np.matrix(np.tile(inputs, (rows, 1)))
        res = np.sum(np.multiply(self.weights, input_mat), axis=1) + self.bias
        self.vals = self.sigmoid(np.array(res).flatten())
        return self.vals

    def sigmoid(self, row):
        return 1 / (1 + np.exp(-1 * row))

    def mutate(self):
        for r in range(len(self.weights)):
            for c in range(len(self.weights[0])):
                rand = random.uniform(0, 1)
                if rand < v.mutate_range:
                    rand = random.uniform(.9, 1.1)
                    self.weights[r][c] *= rand
Exemplo n.º 5
0
from mullvadaccount import startMullvad
from utils import loadconfig
from telegram.ext import Updater
from utils import log
from handlerproxy import handlerproxy
import vars
import i18n
import os

name = "mullvadbot"
vars.init()
config = loadconfig()
log('starting...', 'info')
i18n.load_path.append('..' + os.sep + 'translations')
i18n.set('fallback', 'en')
vars.locale = config['TelegramBot']['Locale']
if vars.locale == '':
    i18n.set('fallback', 'en')
    vars.locale = 'en'
else:
    i18n.set('locale', vars.locale)
log('Locale loaded', 'info')

if config['Mullvad']['Active'] == '1':
    vars.vpn = startMullvad(config)

updater = Updater(token=config['TelegramBot']['Token'])
dispatcher = updater.dispatcher
handlerproxy(dispatcher)

if config['TelegramBot']['Enabled'] == '1':
Exemplo n.º 6
0
Arquivo: redo.py Projeto: reckbo/redo
try:
    from main import mains
    do_init, jobs, redo_flavour, targets = read_opts()
    
    if do_init:
        init(targets, redo_flavour, mains.keys())
        from log import err, debug
        import jwack

        if not redo_flavour.startswith("redo"):
            redo_flavour = "redo-%s" % redo_flavour
        if redo_flavour not in mains:
            err("invalid redo: %s\n", redo_flavour)
            sys.exit(1)

        set_main(redo_flavour)
        
        if jobs < 1 or jobs > 1000:
            err('invalid --jobs value: %r\n', opt.jobs)
        jwack.setup(jobs)
    
        debug("%s %r\n", redo_flavour, targets)

        import vars
        vars.init()

    sys.exit(mains[redo_flavour](redo_flavour, targets) or 0)
except KeyboardInterrupt:
    sys.exit(200)