コード例 #1
0
ファイル: world.py プロジェクト: HLasse/hello-world
    def __init__(self, numPercepts, numActions):
        
        # Chromosome is a numActions X numPercepts matrix. Each element in the matrix acts a weight
        self.chromosome = np.random.normal(0, 1, size = (numActions, numPercepts))


        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #2
0
ファイル: world.py プロジェクト: cmclennan/COSC343
    def __init__(self, numPercepts, numActions, chrome=None):
        # Place your initialisation code here.  Ideally this should set up the creature's chromosome

        if chrome is None:
            self.chrome = np.random.uniform(0, 1, size=numActions)
        else:
            self.chrome = chrome

        # Do not remove this line at the end - it calls the constructors of the parent class.
        Creature.__init__(self)
コード例 #3
0
ファイル: world.py プロジェクト: vbreda/AI_GeneticAlgorithm
    def __init__(self, numPercepts, numActions):

        # Set up the creature's chromosome to be a 9 (percepts) x 11 (possible actions) matrix,
        # initialized to a random state.
        self.chromosome = np.random.uniform(low=0, high=1, size=(numPercepts, numActions))
        self.fitness = 0

        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #4
0
    def __init__(self, numPercepts, numActions):

        # Place your initialisation code here.  Ideally this should set up the creature's chromosome
        # and set it to some random state.
        self.chromosome = np.random.uniform(0, 1, (numActions, numPercepts * 4))
        self.totalPercepts = numPercepts
        self.score = 0

        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #5
0
    def __init__(self, numPercepts, numActions):
        self.numP = numPercepts
        self.numA = numActions

        # Place your initialisation code here.  Ideally this should set up the creature's chromosome
        # and set it to some random state.
        self.chromosome = Chromosome()
        #self.chromosome.printAll()
        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #6
0
    def __init__(self, numPercepts, numActions):

        # Place your initialisation code here.  Ideally this should set up the creature's chromosome
        # and set it to some random state.
        ##################
        ##################
        # OSCARS CODE FOR GENERATING RANDOM FIRST STATS
        ##################
        ##################

        self.chromoList = []
        self.actionList = []
        # 0 - Chance to do thing if energized
        # 1 - Chance to do thing if un-energized
        # 2-9 - What to do if Monster on [x]
        # 10-17 - What to do if Food on [x]
        # 18-What to do if currently on Red apple
        # 19- What to do if currently on Green Apple
        # 20-27 action to do if friend on [x]
        # 28 - Run away form monster weight
        # 29 Run away from friend weight
        # 30- Chance to do somthing if hungry
        # 31 Action and weight if multiple mosnters
        # 32 Action and weight if multiple food
        #33 weight if food
        i = 0
        weight = .8
        while (i < 34):
            self.chromoList.append(
                [random.randint(0, 10),
                 random.uniform(0, weight)])
            i += 1
        i = 0
        while (i < 11):
            self.actionList.append(random.uniform(0, .2))
            i += 1
        #THE BELOW IS LEGACY 'PARAMETERS X OBJECTS' CHROMOSNES
        """
        i = 0
        while (i < 9):
            self.chromoList.append([[(random.randint(0, 10)) , random.uniform(0, .8)]])
            f = 0
            while (f < 2):
                self.chromoList[i].append([(random.randint(0, 10)), random.uniform(0, .8)])
                f += 1
            i += 1
        """
        # ENDOFLEGACYODE
        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #7
0
ファイル: world.py プロジェクト: rawturtle/creatures
 def __init__(self, numPercepts, numActions):
     self.fitness = 0
     self.chromosome = np.random.random(8).tolist()
     self.mutate = 0.005
     '''
     Format
     -------------------------
     0. Monster move opposite
     1. Monster move closer
     2. Creature move opposite
     3. Creature move closer
     4. Food Move opposite
     5. Food Move closer
     6. Eat
     7. Random
     '''
     Creature.__init__(self)
コード例 #8
0
    def __init__(self, numPercepts, numActions):

        # Place your initialisation code here.  Ideally this should set up the creature's chromosome
        # and set it to some random state.

        # MMA | Monster move away
        # MMC | Monster move closer
        # CMA | Creature move away
        # CMC | Creature move closer
        # FMA | Food move away
        # FMC | Food move closer
        # EAT | Eat square
        # RND | Random move
        self.chromosome = []

        # How well the chromosome performed
        self.fitness = 0

        for weight in range(0, 8):
            self.chromosome.append(round(random.uniform(0.0, 0.9), 2))

        # Do not remove this line at the end.  It calls constructors
        # of the parent classes.
        Creature.__init__(self)
コード例 #9
0
ファイル: world.py プロジェクト: qjatj/COSC343
 def __init__(self, numPercepts, numActions):
     self.chromosome = np.random.uniform(0, 1, 11)
     Creature.__init__(self)