예제 #1
0
파일: GA.py 프로젝트: icfeavoir/place-me-ai
 def reproduce(self):
     for i in range(self.nb_reproduction):
         ' on prend une partie mère et une partie père pour reformer un plan'
         new_plan = Plan()
         mother = self.roulette_wheel_selection()
         father = self.roulette_wheel_selection()
         new_plan.create_from_parents(copy.deepcopy(mother), copy.deepcopy(father))
         new_plan.correct_placement()
         self.list_plans.append(new_plan)
예제 #2
0
    def macheMakroPlan(self):
        machbareBedarfe = []
        for stadt in self.spielfeld.staedte:
            for bedarf in stadt.bedarfe:
                if self.bedarfMachbar(bedarf):
                    machbareBedarfe.append(bedarf)

        plaene = []

        for bedarf in machbareBedarfe:
            # print(bedarf, "(machbar)")
            for route in self.moeglicheRouten(bedarf):
                plan = Plan.Plan(self.spielfeld, route)
                plaene.append(plan)

        plaene.sort(key=lambda plan: plan.heuristischeBewertung(),
                    reverse=True)

        if len(plaene) > 0:
            if self.debug:
                print("Makroplan für Spieler", self.spieler.name, ":",
                      plaene[0])
            return plaene[0]
        return None
예제 #3
0
 def _useAttributes( self, attributes ):
     if "avatar_url" in attributes: # pragma no branch
         assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ]
         self._avatar_url = attributes[ "avatar_url" ]
     if "bio" in attributes: # pragma no branch
         assert attributes[ "bio" ] is None or isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ]
         self._bio = attributes[ "bio" ]
     if "blog" in attributes: # pragma no branch
         assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ]
         self._blog = attributes[ "blog" ]
     if "collaborators" in attributes: # pragma no branch
         assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ]
         self._collaborators = attributes[ "collaborators" ]
     if "company" in attributes: # pragma no branch
         assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ]
         self._company = attributes[ "company" ]
     if "contributions" in attributes: # pragma no branch
         assert attributes[ "contributions" ] is None or isinstance( attributes[ "contributions" ], int ), attributes[ "contributions" ]
         self._contributions = attributes[ "contributions" ]
     if "created_at" in attributes: # pragma no branch
         assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
         self._created_at = None if attributes[ "created_at" ] is None else datetime.datetime.strptime( attributes[ "created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
     if "disk_usage" in attributes: # pragma no branch
         assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
         self._disk_usage = attributes[ "disk_usage" ]
     if "email" in attributes: # pragma no branch
         assert attributes[ "email" ] is None or isinstance( attributes[ "email" ], ( str, unicode ) ), attributes[ "email" ]
         self._email = attributes[ "email" ]
     if "followers" in attributes: # pragma no branch
         assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ]
         self._followers = attributes[ "followers" ]
     if "following" in attributes: # pragma no branch
         assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ]
         self._following = attributes[ "following" ]
     if "gravatar_id" in attributes: # pragma no branch
         assert attributes[ "gravatar_id" ] is None or isinstance( attributes[ "gravatar_id" ], ( str, unicode ) ), attributes[ "gravatar_id" ]
         self._gravatar_id = attributes[ "gravatar_id" ]
     if "hireable" in attributes: # pragma no branch
         assert attributes[ "hireable" ] is None or isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ]
         self._hireable = attributes[ "hireable" ]
     if "html_url" in attributes: # pragma no branch
         assert attributes[ "html_url" ] is None or isinstance( attributes[ "html_url" ], ( str, unicode ) ), attributes[ "html_url" ]
         self._html_url = attributes[ "html_url" ]
     if "id" in attributes: # pragma no branch
         assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
         self._id = attributes[ "id" ]
     if "location" in attributes: # pragma no branch
         assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ]
         self._location = attributes[ "location" ]
     if "login" in attributes: # pragma no branch
         assert attributes[ "login" ] is None or isinstance( attributes[ "login" ], ( str, unicode ) ), attributes[ "login" ]
         self._login = attributes[ "login" ]
     if "name" in attributes: # pragma no branch
         assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
         self._name = attributes[ "name" ]
     if "owned_private_repos" in attributes: # pragma no branch
         assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), attributes[ "owned_private_repos" ]
         self._owned_private_repos = attributes[ "owned_private_repos" ]
     if "plan" in attributes: # pragma no branch
         assert attributes[ "plan" ] is None or isinstance( attributes[ "plan" ], dict ), attributes[ "plan" ]
         self._plan = None if attributes[ "plan" ] is None else Plan.Plan( self._requester, attributes[ "plan" ], completed = False )
     if "private_gists" in attributes: # pragma no branch
         assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), attributes[ "private_gists" ]
         self._private_gists = attributes[ "private_gists" ]
     if "public_gists" in attributes: # pragma no branch
         assert attributes[ "public_gists" ] is None or isinstance( attributes[ "public_gists" ], int ), attributes[ "public_gists" ]
         self._public_gists = attributes[ "public_gists" ]
     if "public_repos" in attributes: # pragma no branch
         assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ]
         self._public_repos = attributes[ "public_repos" ]
     if "total_private_repos" in attributes: # pragma no branch
         assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), attributes[ "total_private_repos" ]
         self._total_private_repos = attributes[ "total_private_repos" ]
     if "type" in attributes: # pragma no branch
         assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ]
         self._type = attributes[ "type" ]
     if "url" in attributes: # pragma no branch
         assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
         self._url = attributes[ "url" ]
예제 #4
0
import Kompass
from Karte import *
from Plan import *
from Motor import *
from Grid import *
import sys
import atexit

count = 1
speed = 0
steer = 0
encoder = Encoder()
navigation = Navigation()
scanner = Scanner()
karte = Karte(encoder)
plan = Plan()
kreis = 0
motor = Motor()
grid = Grid(50, 50)

grid.setZielInGrid(15, 49)
grid.setStartInGrid(15, 1)
karte.setRoboPosZero(150, 150)


def cleaning():
    """Do cleanup at end, command are visVersa"""
    motor.setCommand(0, 0)


atexit.register(cleaning)
예제 #5
0
    def __init__(self, app=None, plan=None, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.plan = ResearchPlan.Plan()

        self._init_gui()
예제 #6
0
파일: Main.py 프로젝트: michaelze/Robina
#Robo Main

Robo = True

from Scanner import *
from Encoder import *
import Kompass
from Karte import *
from Plan import *
from Motor import *

karte = Karte()
navigation = Navigation()
scanner = Scanner()
plan = Plan(karte, navigation)
encoder = Encoder()
motor = Motor()

ThreadScanAllTime = Thread(target=scanner.runAllTime, args=(1, ))
ThreadScanAllTime.daemon = True
ThreadScanAllTime.start()

ThreadEncoder = Thread(target=encoder.runAllTime, args=())
ThreadEncoder.daemon = True
ThreadEncoder.start()

while Robo == True:
    obstacles = scanner.getNewDistValues()
    karte.updateObstacles(obstacles)

    deltaDist = encoder.getDistCounts()
예제 #7
0
파일: main.py 프로젝트: lazycrazyowl/nyose
        if sys.argv[1] == 'pull':
            while True:
                try:
                    print(">> git pull")
                    mess = puller.pull()
                    print(mess)
                    break
                except:
                    print("unsuccessful, retry")
                    sleep(5)
            sys.exit()
        debug = True

    wtab = wt.WeekTable()  # The template for planner
    jnal = jn.Journal()  # The Journal
    plan = pl.Plan()  # The planner
    time = tm.Time()  # Lazy time tracker
    tenw = tw.TenWeek()  # The long run
    print('wtab, jnal, plan, time, tenw: On')

    tick = cl.Clock(debug)  # The loop
    print('tick: On' + int(debug) * ' (debug mode)')

    while not tick.exit:
        # Mail receive a special treatment since it needs
        # to be destruct and re-construct when there is connection fault
        # thus it is initiate inside the scope of tick.run
        tick.run(ml, time, tenw, wtab, jnal, plan)
        if tick.update:
            # TODO: Run git synchorise here
            mess = str()
예제 #8
0
    def manage_utils(bot, text, author_id, thread_id):

        login = Utils.getLogin(author_id)
        password = Utils.getPassword(author_id)
        plan = Plan(login, password)
        news = News(login, password)
        avggrade = AvgGrade(login, password)

        # user data deletion

        if Utils.wantToDeleteData(text):
            Utils.delete_my_data(author_id)
            bot.send(Message(text='Kim Ty jesteś?'), thread_id=thread_id)

        # fun facts
        elif Utils.wantToHearFunFact(text):
            x = random.randint(0, 10)
            if x is 0:
                bot.send(Message(text='Jakie papierosy palą studenci EE?'),
                         thread_id=thread_id)
                bot.send(Message(text='Elektryczne!'), thread_id=thread_id)
            elif x is 1:
                bot.send(Message(
                    text=
                    'Na lekcji programowania obiektowego student łapie koleżankę obok za pierś. Na to ona: „To prywatne!!!”, a on odpowiada: „Myślałem że jesteśmy w tej samej klasie :D „'
                ),
                         thread_id=thread_id)
            elif x is 2:
                bot.send(Message(
                    text=
                    'Javoviec jakimś cudem spłodził dziecko. Miał wymyślić imię dla dziecka. Na wszelki wypadek przygotował 2, jakby urodziły się bliźniaki. Na nieszczęście urodziły się trojaczki i dostały imiona: Jaś, Staś, ArrayIndexOutOfBoundsException'
                ),
                         thread_id=thread_id)
            elif x is 3:
                bot.send(Message(
                    text=
                    'Spotyka się dwóch programistów:\n– Słyszałem, że straciłeś pracę. Jak to jest być bezrobotnym?\n– To było najgorsze pół godziny mojego życia!'
                ),
                         thread_id=thread_id)
            elif x is 4:
                bot.send(Message(
                    text=
                    'Doktorze, każdej nocy śni mi się jeden i ten sam koszmar. Jestem na Antarktydzie a wokół pełno pingwinów. I ciągle przybywają i przybywają. Zbliżają się do mnie, napierają na mnie, przepychają mnie do urwiska i za każdym razem spychają mnie do lodowatej wody.\n– Normalnie leczymy takie przypadki w jeden dzień. Ale z Panem możemy mieć większe problemy, Panie Gates…'
                ),
                         thread_id=thread_id)
            elif x is 5:
                bot.send(Message(
                    text=
                    'Jadą samochodem 3 koledzy i jeden z nich był programistą. Samochód się psuje, pasażerowie siedzą w środku i dywagują: świece, rozrusznik, benzyna, skończył sie olej… Nagle programista mówi: a może wyjdźmy z samochodu poczekajmy chwilę i potem wejdźmy :D'
                ),
                         thread_id=thread_id)
            elif x is 6:
                bot.send(Message(
                    text=
                    'Z programowaniem jak z budową katedry, budujesz,budujesz a potem się modlisz (żeby wszystko działało)'
                ),
                         thread_id=thread_id)
            elif x is 7:
                bot.send(Message(
                    text=
                    'Programista otwiera lodówkę, sięga po masło i patrząc na napis „82%” mówi:\n– a to jeszcze chwilka i będzie gotowe.'
                ),
                         thread_id=thread_id)
            elif x is 8:
                bot.send(Message(
                    text=
                    'Na świecie jest 10 rodzajów ludzi: ci, którzy rozumieją system binarny i ci, którzy go nie rozumieją.'
                ),
                         thread_id=thread_id)
            elif x is 9:
                bot.send(Message(
                    text=
                    'Żona do programisty: idź do sklepu kup 5 bułek, a jak będą jajka kup 10.\nProgramista będąc w sklepie: – Są jajka?\nSprzedawczyni: – Tak, są.\nProgramista: To poproszę 10 bułek.'
                ),
                         thread_id=thread_id)
            elif x is 10:
                bot.send(Message(
                    text=
                    'Dlaczego programiści mylą Boże Narodzenie z Halloween ?\nBo 25 Dec = 31 Oct'
                ),
                         thread_id=thread_id)
            else:
                return -1

        # helpdesk
        elif Utils.needHelp(text):
            bot.send(Message(
                text=
                'Oto lista dostępnych poleceń po wykonanej autoryzacji:\n średnia - podaje średnią na semestr\n następne zajęcia - podaje najbliższe chronologicznie zajęcia\n usuń - polecenie usuwa dane użytkownika z systemu.\n plan <dzień tygodnia> - polecenie wyświetli plan na podany dzień tygodnia.\n aktualności - polecenie wyświetla nagłówki 5 ostatnich aktualności.\n żart - polecenie wyświetla losowo wybrany z systemu żart.\n pomóż - polecenie wyświetla ten komunikat.'
            ),
                     thread_id=thread_id)

        # plan section

        elif Utils.wantToGetPlan(text) == 1:
            bot.send(Message(text=plan.get_plan_daily(1)), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 2:
            bot.send(Message(text=plan.get_plan_daily(2)), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 3:
            bot.send(Message(text=plan.get_plan_daily(3)), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 4:
            bot.send(Message(text=plan.get_plan_daily(4)), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 5:
            bot.send(Message(text=plan.get_plan_daily(5)), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 6:
            bot.send(Message(text='W weekend nie masz zajęć :)'),
                     thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 7:
            weekplan = plan.get_plan_weekly()
            for i in weekplan:
                bot.send(Message(text=i), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == 8:
            bot.send(Message(text=plan.get_next_class()), thread_id=thread_id)
        elif Utils.wantToGetPlan(text) == -1:
            bot.send(Message(
                text=
                'Może to ja niedomagam, ale nie wiem na kiedy chcesz ten plan. Wyrażaj się jaśniej proszę'
            ),
                     thread_id=thread_id)

        # News section

        elif Utils.wantToGetNews(text) == True:
            news_list = news.getlastnews()
            for obj in news_list:
                bot.send(Message(text=obj), thread_id=thread_id)

        elif Utils.wantToGetAvgGrade(text):
            grade = avggrade.getAvgGrade()
            bot.send(Message(text=grade.text), thread_id=thread_id)

        else:
            Utils.messageNotRecognized(bot, thread_id)