This repository was archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Module step function
Derkje-J edited this page Apr 20, 2013
·
5 revisions
A module should have a step function with this header
step : ( t, substrates ) ->
where t
is the current time and substrates
is an object with all the substrates.
It should return an object with all the modified substrate deltas.
Let's say you have four substrates and three modules:
- enzym that breaks down food
- food outside
- food inside
- transporter enzym that transports food
test = new Cell()
test.add_substrate( 'enzym', 1 )
test.add_substrate( 'food_out', 100 )
test.add_substrate( 'food_in', 0 )
test.add_substrate( 'transp', 0 )
- module that creates transporters from nothing ( magix )
- module that transports food inside the cell
- module that breaks down food with enzym
create_transport = {
step : ( t, substrates ) ->
{ 'transp' : 1 }
}
transport_food = {
step : ( t, substrates ) ->
transp = substrates.transp
food_out = substrates.food_out
transport = Math.min( transp, Math.max( 0, food_out ) )
{ 'food_out' : -transport, 'food_in' : transport }
}
food_enzym = {
step : ( t, substrates ) ->
food_in = substrates.food_in
enzym = substrates.ezym
process = Math.min( enzym, Math.max( 0, food_in ) )
{ 'food_in' : -process }
}
test.add create_transport
test.add transport_food
test.add food_enzym