-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutate_vis.py
34 lines (23 loc) · 837 Bytes
/
mutate_vis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import win32pipe as wp
import win32file as wf
import matplotlib.pyplot as plt
import pyscreenshot as ImageGrab
import time, datetime, sys, os, argparse, copy, math
h,w = 96,64
mi = 0.05
mf = 0.001
decay = 450
def mutate(gen,h,w,mutate_initial_rate,mutate_final_rate, mutate_decay_factor):
segment_rows = 1024/w
segment_cols = 768/h
num_segments = int(segment_rows*segment_cols)
num_mutations = np.round(num_segments * ((mutate_initial_rate - mutate_final_rate)
* np.exp(-gen / mutate_decay_factor)
+ mutate_final_rate)).astype(np.int)
num_mutations[num_mutations < 1] = 1
return num_mutations
gens = np.arange(1500)
muts = mutate(gens,h,w,mi,mf,decay)
plt.plot(gens,muts)
plt.show()