from random import uniform

transport_speed = 1/3.

nbEntity = 10

min_level = 0.01
max_level = 10

sumauxin = 0

def txt(val):
	return str(round(val,2))[:5]

def Start():
	global sumauxin
	sumauxin = 0

Axiom: 
  global sumauxin
  nproduce _(2)
  for i in range(nbEntity):
   auxin = uniform(min_level,max_level)
   sumauxin += auxin
   nproduce I(auxin)

derivation length: 300
production:

I(a) < I(p) > I(b) :
	produce I(p + (a+b-2*p)*transport_speed)

I(p) > I(b):
	produce I(p + (b-p)*transport_speed)

I(a) < I(p) :
	produce I(p+ (a-p)*transport_speed)

interpretation:

I(a) :
	col = int(10*(a-min_level)/(max_level-min_level))
	a += 0.1
	produce ;(col)F(3)[-(90)f(5);(3)@L(txt(a-0.1))f(5);(col)F(a)]F(3)

E --> f(3)[+(90)f(3);(3)@L(txt(sumauxin))]

endlsystem


###### INITIALISATION ######

__lpy_code_version__ = 1.1

def __initialiseContext__(context):
	import openalea.plantgl.all as pgl
	Color_0 = pgl.Material("Color_0" , ambient = (39,0,0) , diffuse = 4.61538 , )
	Color_0.name = "Color_0"
	context.turtle.setMaterial(0,Color_0)
	Color_1 = pgl.Material("Color_1" , ambient = (40,5,0) , diffuse = 4.518 , )
	Color_1.name = "Color_1"
	context.turtle.setMaterial(1,Color_1)
	Color_2 = pgl.Material("Color_2" , ambient = (41,10,0) , diffuse = 4.42061 , )
	Color_2.name = "Color_2"
	context.turtle.setMaterial(2,Color_2)
	Color_3 = pgl.Material("Color_3" , ambient = (43,15,0) , diffuse = 4.32322 , )
	Color_3.name = "Color_3"
	context.turtle.setMaterial(3,Color_3)
	Color_4 = pgl.Material("Color_4" , ambient = (44,21,0) , diffuse = 4.22583 , )
	Color_4.name = "Color_4"
	context.turtle.setMaterial(4,Color_4)
	Color_5 = pgl.Material("Color_5" , ambient = (46,26,0) , diffuse = 4.12845 , )
	Color_5.name = "Color_5"
	context.turtle.setMaterial(5,Color_5)
	Color_6 = pgl.Material("Color_6" , ambient = (47,31,0) , diffuse = 4.03106 , )
	Color_6.name = "Color_6"
	context.turtle.setMaterial(6,Color_6)
	Color_7 = pgl.Material("Color_7" , ambient = (48,37,0) , diffuse = 3.93367 , )
	Color_7.name = "Color_7"
	context.turtle.setMaterial(7,Color_7)
	Color_8 = pgl.Material("Color_8" , ambient = (50,42,0) , diffuse = 3.83628 , )
	Color_8.name = "Color_8"
	context.turtle.setMaterial(8,Color_8)
	Color_9 = pgl.Material("Color_9" , ambient = (51,47,0) , diffuse = 3.7389 , )
	Color_9.name = "Color_9"
	context.turtle.setMaterial(9,Color_9)
	Color_10 = pgl.Material("Color_10" , ambient = (53,53,0) , diffuse = 3.64151 , )
	Color_10.name = "Color_10"
	context.turtle.setMaterial(10,Color_10)
__copyright__ = 'open-source GPL'
__description__ = '- Set the initial condition so that the leftmost entity only contains auxin'
__institutes__ = 'INRIA - CIRAD Virtual Plants'
__authors__ = 'F. Boudon, C. Godin'
