Skip to content
Snippets Groups Projects
Commit 8e99066b authored by Philip Maas's avatar Philip Maas
Browse files

Merge branch 'evaluations' into 'evo-neuro'

Evaluations

See merge request !1
parents 8c5bdea8 1841113a
Branches
No related tags found
2 merge requests!2Evo neuro,!1Evaluations
Showing
with 54 additions and 0 deletions
File added
12 1 50 0.1 0.01 300/12_1_50_0.1_0.01_300.png

28.9 KiB

File added
12 1 50 0.1 0.03 300/12_1_50_0.1_0.03_300.png

38.8 KiB

File added
File added
File added
File added
File added
12 1 50 0.1 0.1 300/12_1_50_0.1_0.1_300.png

50.3 KiB

File added
12 1 50 0.1 decaying 300/12_1_50_0.1_decaying_300.png

40.3 KiB

12 1 50 0.1 decaying 300/12_2_50_0.1_decaying_300.png

36.7 KiB

File added
File added
12 1 50 0.3 0.03 300/12_1_50_0.3_0.03_300.png

32.3 KiB

# Bipedal Walker Evo
Trying to solve the bipedal walker with an evolution algorithm
\ No newline at end of file
brain.py 0 → 100644
import numpy as np
import random
import copy
import pickle
class Brain:
def __init__(self, size, load_brain):
self.directions = []
self.step = 0
if load_brain:
self.load()
else:
self.increase_moves(size)
def get_move(self):
move = self.directions[self.step]
self.step += 1
return move
# we want different and random movements
def increase_moves(self, size):
for i in range(size):
self.directions.append(np.random.uniform(-1, 1, 4))
# returns a copy of the given brain
def clone(self):
clone = Brain(len(self.directions), False)
for i in range(len(self.directions)):
clone.directions[i] = copy.copy(self.directions[i])
return clone
def mutate(self, mutation_factor): # mutates the brain by setting some of the directions to random movements
for i in range(len(self.directions)):
if random.random() <= mutation_factor:
self.directions[i] = np.random.uniform(-1, 1, 4)
def save(self):
with open('best_brain', 'wb') as fp:
pickle.dump(self.directions, fp)
def load(self):
with open('best_brain', 'rb') as fp:
self.directions = pickle.load(fp)
if __name__ == '__main__': # for debugging
brain_inst = Brain(100, True)
print(brain_inst.directions)
print(len(brain_inst.directions))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment