def render(self,model): for i in range(0,model.size()): p = sim_helpers.safelog(redking.rk_real_getitem(model.get_parasites(),i)) h = sim_helpers.safelog(redking.rk_real_getitem(model.get_hosts(),i)) c = self.pixels[(model.size()-i)-1,int(self.pos)] # squash the log10 p=min(1,abs(p)) h=min(1,abs(h)) # screen blend mode col = [(1-self.parasite_col[0]*p)*(1-self.host_col[0]*h), (1-self.parasite_col[1]*p)*(1-self.host_col[1]*h), (1-self.parasite_col[2]*p)*(1-self.host_col[2]*h)] # convert to 8 bit c[0] = (1-col[0])*255 c[1] = (1-col[1])*255 c[2] = (1-col[2])*255 if c[0]>255: c[0]=255 if c[1]>255: c[1]=255 if c[2]>255: c[2]=255 self.pixels[(model.size()-i)-1,int(self.pos)]=c self.pos+=self.x_per_render
def combined_array(model): #return [safelog(redking.rk_real_getitem(m.get_hosts(),i) + # redking.rk_real_getitem(m.get_parasites(),i)) # for i in range(0,model.size())] return [redking.rk_real_getitem(model.get_hosts(),i) + redking.rk_real_getitem(model.get_parasites(),i) for i in range(0,model.size())]
def render(self, model): for i in range(0, model.size()): p = sim_helpers.safelog( redking.rk_real_getitem(model.get_parasites(), i)) h = sim_helpers.safelog( redking.rk_real_getitem(model.get_hosts(), i)) c = self.pixels[(model.size() - i) - 1, int(self.pos)] # squash the log10 p = min(1, abs(p)) h = min(1, abs(h)) # screen blend mode col = [(1 - self.parasite_col[0] * p) * (1 - self.host_col[0] * h), (1 - self.parasite_col[1] * p) * (1 - self.host_col[1] * h), (1 - self.parasite_col[2] * p) * (1 - self.host_col[2] * h)] # convert to 8 bit c[0] = (1 - col[0]) * 255 c[1] = (1 - col[1]) * 255 c[2] = (1 - col[2]) * 255 if c[0] > 255: c[0] = 255 if c[1] > 255: c[1] = 255 if c[2] > 255: c[2] = 255 self.pixels[(model.size() - i) - 1, int(self.pos)] = c self.pos += self.x_per_render
def parasite_matrix(model): ret = [] for i in range(0, model.size()): m = model.get_matrix_row(i) ret+=[redking.rk_real_getitem(m,j) for j in range(model.size())] return ret
def host_cost(model): return [ redking.rk_real_getitem(model.get_host_cost(), i) for i in range(0, model.size()) ]
def host_state_array(model): return [ redking.rk_real_getitem(model.get_hosts(), i) for i in range(0, model.size()) ]
def parasite_state_array(model): return [ redking.rk_real_getitem(model.get_parasites(), i) for i in range(0, model.size()) ]
def host_cost(model): return [redking.rk_real_getitem(model.get_host_cost(),i) for i in range(0,model.size())]
def host_state_array(model): return [redking.rk_real_getitem(model.get_hosts(),i) for i in range(0,model.size())]
def parasite_state_array(model): return [redking.rk_real_getitem(model.get_parasites(),i) for i in range(0,model.size())]