def initialize(): #creats grid on which cells are placed by chance if not threeD: ce = 0 for row in range(x): #grid saved in a dic# for col in range(x): pos[ce] = [x_c[col], y_c[row]] ce += 1 else: ce = 0 for wth in range(x): for row in range(x): #grid saved in a dic# for col in range(x): pos[ce] = [x_c[col], y_c[row],z_c[wth]] ce += 1 if not threeD: c_num = 0 start= 0 stop = len(pos)-1 step=1 print start,stop for cc in range(start,stop,step): #cells being placed# bla = rd.random() if cc==stop: #only one horizontal row used# break if bla >= n: continue if border(cc): #checks for outofbounds around edges# if checkneighbor(cc): #check if cell can be placed# put = rd.randint(0, 1) if put == 0: c_ary[c_num] = cl.Cell(c_num, 'alpha', radius, stategamble(), pos[cc][0], pos[cc][1], maxrad, seite) occupy(cc,c_num) c_num += 1 elif put == 1: c_ary[c_num] = cl.Cell(c_num, 'a', radius, stategamble(), pos[cc][0], pos[cc][1], maxrad, seite) occupy(cc, c_num) c_num += 1 else: setcells() cgrad = cl.C_grad(len(c_ary), x, n, place, K, feedback, c_ary, True) C_i, state = cgrad.ini_cell_c() C_t.append(list(C_i)) state_t.append(list(state)) global fx global fy global fz fx = np.zeros(len(c_ary)) fy = np.zeros(len(c_ary)) fz = np.zeros(len(c_ary))
def divide(p): #takes rd point and places new cell xn, yn, zn = rdspot() xn = max((xn + c_ary[p].xcor), radius) yn = max((yn + c_ary[p].ycor), radius) if threeD: zn = max((zn + c_ary[p].zcor), radius) else: zn = 2 c_num = max(c_ary.keys()) r_new = radius if c_ary[p].name == 'work': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'work', r_new, stategamble(), xn, yn, zn) elif c_ary[p].name == 'lone': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'lone', r_new, stategamble(), xn, yn, zn) elif c_ary[p].name == 'maybe': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'maybe', r_new, stategamble(), xn, yn, zn) c_ary[p].radius = r_new c_ary[p].status = True
def setcells(): c_num = 0 start=0 stop1=x**3 step1=x**2 stop2=x step2=1 for i in range(start, stop1, step1): # cells being placed# for j in range(start,stop2,step2): cor =radius*x cc=i+j+cor put = rd.random() if cc == stop1: # only one horizontal row used# break if border(cc): # checks for outofbounds around edges# if checkneighbor(cc): # check if cell can be placed# if put <= n: c_ary[c_num] = cl.Cell(c_num, 'work', radius, stategamble(), pos[cc][0], pos[cc][1], pos[cc][2]) occupy(cc, c_num) c_num += 1 else: c_ary[c_num] = cl.Cell(c_num, 'lazy', radius, stategamble(), pos[cc][0], pos[cc][1], pos[cc][2]) occupy(cc, c_num) c_num += 1
def divide(p): #takes rd point and places new cell xn,yn,zn=rdspot() xn = max((xn + c_ary[p].xcor),radius) yn = max((yn + c_ary[p].ycor),radius) if threeD: zn = max((zn + c_ary[p].zcor),radius) else: zn=2 c_num=max(c_ary.keys()) rnew=0.79370052598*c_ary[p].radius if c_ary[p].name=='alpha': side = c_ary[p].site c_ary[c_num+1] = cl.Cell(c_num+1, 'alpha', rnew, stategamble(), xn, yn, zn, side) elif c_ary[p].name=='a': side = c_ary[p].site c_ary[c_num+1] = cl.Cell(c_num+1, 'a', rnew, stategamble(), xn, yn, zn, side) elif c_ary[p].name == 'fusion': side = c_ary[p].site c_ary[c_num + 1] = cl.Cell(c_num + 1, 'fusion', rnew, stategamble(), xn, yn, zn, side) c_ary[p].site = not side c_ary[p].radius = rnew c_ary[p].status = c_ary[p].status
def setcells(): c_num = 0 start = 0 stop1 = x**3 step1 = x**2 stop2 = x step2 = 1 for i in range(start, stop1, step1): # cells being placed# for j in range(start, stop2, step2): cor = radius * x cc = i + j + cor if cc == stop1: # only one horizontal row used# break put = rd.randint(0, 2) if border(cc): # checks for outofbounds around edges# if checkneighbor(cc): # check if cell can be placed# if put == 0: c_ary[c_num] = cl.Cell(c_num, 'work', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1 elif put == 1: c_ary[c_num] = cl.Cell(c_num, 'toxic', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1 elif put == 2: c_ary[c_num] = cl.Cell(c_num, 'res', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1
def divide(p): #takes rd point and places new cell xn, yn, zn = rdspot() xn = max((xn + c_ary[p].xcor), radius) yn = max((yn + c_ary[p].ycor), radius) if threeD: zn = max((zn + c_ary[p].zcor), radius) else: zn = 2 c_num = max(c_ary.keys()) rnew = 0.79370052598 * c_ary[p].radius if c_ary[p].name == 'work': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'work', rnew, stategamble(), xn, yn, zn) elif c_ary[p].name == 'toxic': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'toxic', rnew, stategamble(), xn, yn, zn) elif c_ary[p].name == 'res': c_ary[c_num + 1] = cl.Cell(c_num + 1, 'res', rnew, stategamble(), xn, yn, zn) c_ary[p].radius = rnew c_ary[p].status = True
def divide(p): #takes rd point and places new cell xn, yn, zn = rdspot() xn = max((xn + c_ary[p].xcor), radius) yn = max((yn + c_ary[p].ycor), radius) if threeD: zn = max((zn + c_ary[p].zcor), radius) else: zn = 2 c_num = max(c_ary.keys()) c_ary[c_num + 1] = cl.Cell(c_num + 1, 'ecoli ', radius, stategamble(), xn, yn, zn) c_ary[p].radius = radius c_ary[p].status = True
def growth(p): if c_ary[p].status: if c_ary[p].name == 'work': c_ary[p].radius = c_ary[p].radius + g_rateon print('EPS-biatch') xn,yn,zn=rdspot() xn = max((xn + c_ary[p].xcor),0.4) yn = max((yn + c_ary[p].ycor),0.4) if threeD: zn = max((zn + c_ary[p].zcor),0.4) else: zn=2 c_num = max(c_ary.keys()) c_ary[c_num+1] = cl.Cell(c_num+1, 'EPS', 0.7, stategamble(), xn, yn, zn) elif c_ary[p].name == 'lazy': c_ary[p].radius = c_ary[p].radius + g_rate1 elif c_ary[p].name == 'work': c_ary[p].radius = c_ary[p].radius + g_rate3
def initialize(): #creats grid on which cells are placed by chance global c_ary if not threeD: ce = 0 for row in range(x): #grid saved in a dic# for col in range(x): pos[ce] = [x_c[col], y_c[row]] ce += 1 else: ce = 0 for wth in range(x): for row in range(x): #grid saved in a dic# for col in range(x): pos[ce] = [x_c[col], y_c[row], z_c[wth]] ce += 1 if not threeD: c_num = 0 start = 0 stop = (x) * (maxrad) step = 1 print start, stop for cc in range(start, stop, step): #cells being placed# put = rd.randint(0, ratio) if cc == stop: # only one horizontal row used# break if border(cc): # checks for outofbounds around edges# if checkneighbor(cc): # check if cell can be placed# if put > 0: putty = rd.randint(0, 1) if putty == 0: c_ary[c_num] = cl.Cell(c_num, 'work', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1 else: c_ary[c_num] = cl.Cell(c_num, 'res', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1 elif put == 0: c_ary[c_num] = cl.Cell(c_num, 'toxic', radius, stategamble(), pos[cc][0], min(pos[cc][1], radius), maxrad) occupy(cc, c_num) c_num += 1 else: setcells() #cgrad = cl.C_grad(len(c_ary), x, n, place, C_on, K, feedback, c_ary, threeD) #C_i, state = cgrad.ini_cell_c() #C_t.append(list(C_i)) #state_t.append(list(state)) global fx global fy global fz fx = np.zeros(len(c_ary)) fy = np.zeros(len(c_ary)) fz = np.zeros(len(c_ary))