Sephfox commited on
Commit
55aad04
1 Parent(s): f259ff8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,8 +1,9 @@
1
  import random
2
  import numpy as np
 
3
  import plotly.graph_objects as go
4
  from plotly.subplots import make_subplots
5
- import streamlit as st
6
 
7
  class Organelle:
8
  def __init__(self, type):
@@ -80,6 +81,12 @@ class Environment:
80
  self.light_level = 5 # Ambient light level
81
  self.cells = []
82
  self.time = 0
 
 
 
 
 
 
83
 
84
  def add_cell(self, cell):
85
  self.cells.append(cell)
@@ -131,10 +138,27 @@ class Environment:
131
  cell.color = "darkgreen"
132
  cell.size = 4
133
 
134
- def visualize(self):
135
- fig = make_subplots(rows=1, cols=2, subplot_titles=("Cell Distribution", "Population Over Time"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- def setup_figure(env):
138
  fig = make_subplots(rows=1, cols=2, subplot_titles=("Cell Distribution", "Population Over Time"))
139
 
140
  # Cell distribution
 
1
  import random
2
  import numpy as np
3
+ import streamlit as st
4
  import plotly.graph_objects as go
5
  from plotly.subplots import make_subplots
6
+ import time
7
 
8
  class Organelle:
9
  def __init__(self, type):
 
81
  self.light_level = 5 # Ambient light level
82
  self.cells = []
83
  self.time = 0
84
+ self.population_history = {
85
+ "prokaryote": [],
86
+ "early_eukaryote": [],
87
+ "advanced_eukaryote": [],
88
+ "plant_like": []
89
+ }
90
 
91
  def add_cell(self, cell):
92
  self.cells.append(cell)
 
138
  cell.color = "darkgreen"
139
  cell.size = 4
140
 
141
+ # Record population counts
142
+ for cell_type in self.population_history.keys():
143
+ count = len([cell for cell in self.cells if cell.cell_type == cell_type])
144
+ self.population_history[cell_type].append(count)
145
+
146
+ def get_visualization_data(self):
147
+ cell_data = {
148
+ "prokaryote": {"x": [], "y": [], "size": [], "color": "lightblue"},
149
+ "early_eukaryote": {"x": [], "y": [], "size": [], "color": "green"},
150
+ "advanced_eukaryote": {"x": [], "y": [], "size": [], "color": "red"},
151
+ "plant_like": {"x": [], "y": [], "size": [], "color": "darkgreen"}
152
+ }
153
+
154
+ for cell in self.cells:
155
+ cell_data[cell.cell_type]["x"].append(cell.x)
156
+ cell_data[cell.cell_type]["y"].append(cell.y)
157
+ cell_data[cell.cell_type]["size"].append(cell.size * 3)
158
+
159
+ return cell_data, self.population_history
160
 
161
+ def setup_figure(env):
162
  fig = make_subplots(rows=1, cols=2, subplot_titles=("Cell Distribution", "Population Over Time"))
163
 
164
  # Cell distribution