<?xml version="1.0" encoding="UTF-8"?>
<otrunk id="04cc5e49-6996-475a-9ce2-d557d9fd4208">
	<imports>
		<import class="org.concord.data.state.OTDataStore" />
		<import class="org.concord.data.state.OTDataChannelDescription" />
		<import class="org.concord.data.state.OTDataField" />
		<import class="org.concord.data.state.OTDataTable" />
		<import class="org.concord.datagraph.state.OTDataGraph" />
		<import class="org.concord.datagraph.state.OTDataAxis" />
		<import class="org.concord.datagraph.state.OTDataGraphable" />
		<import class="org.concord.datagraph.state.OTDataCollector" />
		<import class="org.concord.datagraph.state.OTMultiDataGraph" />
		<import class="org.concord.datagraph.state.OTPluginView" />
		<import class="org.concord.datagraph.state.OTDataBarGraphable" />
		<import class="org.concord.otrunk.OTIncludeRootObject" />
		<import class="org.concord.otrunk.OTInclude" />
		<import class="org.concord.otrunk.OTSystem" />
		<import class="org.concord.otrunk.biologica.OTOrganismPlacement" />
		<import class="org.concord.otrunk.biologica.OTEnvironment" />
		<import class="org.concord.otrunk.biologica.OTOrganism" />
		<import class="org.concord.otrunk.biologica.OTWorld" />
		<import class="org.concord.otrunk.biologica.agent.OTAgentSpecies" />
		<import class="org.concord.otrunk.biologica.agent.OTAgentTrait" />
		<import class="org.concord.otrunk.biologica.agent.OTAgentPropertyImageMap" />
		<import class="org.concord.otrunk.biologica.environment.OTAddAgentButton" />
		<import class="org.concord.otrunk.biologica.environment.OTEnvironmentHolder" />
		<import
			class="org.concord.otrunk.biologica.data.OTBiologicaModelDataProducer" />
		<import class="org.concord.otrunk.biologica.rules.OTRule" />
		<import class="org.concord.otrunk.biologica.rules.OTRuleCondition" />
		<import class="org.concord.otrunk.biologica.rules.OTRuleConsequence" />
		<import class="org.concord.otrunk.ui.OTCurriculumUnit" />
		<import class="org.concord.otrunk.ui.OTPlacement" />
		<import class="org.concord.otrunk.ui.snapshot.OTSnapshot" />
		<import class="org.concord.otrunk.ui.snapshot.OTSnapshotButton" />
		<import class="org.concord.otrunk.ui.snapshot.OTSnapshotAlbum" />
		<import class="org.concord.otrunk.ui.snapshot.OTSnapshotChooser" />
		<import class="org.concord.otrunk.view.OTViewEntry" />
		<import class="org.concord.otrunk.view.OTViewBundle" />
		<import class="org.concord.otrunk.view.OTViewMode" />
		<import class="org.concord.otrunk.view.document.OTCompoundDoc" />
		<import class="org.concord.otrunk.script.ui.OTScriptObject" />
		<import class="org.concord.otrunk.script.js.OTJavascript" />
		<import class="org.concord.otrunk.script.OTScriptEngineBundle" />
		<import class="org.concord.otrunk.script.OTScriptEngineEntry" />
		<import class="org.concord.otrunk.script.ui.OTScriptVariable" />
		<import class="org.concord.otrunk.script.ui.OTScriptVariableComponent" />
		<import class="org.concord.otrunk.script.ui.OTScriptVariableRealObject" />
		<import class="org.concord.otrunk.script.ui.OTScriptVariableView" />
		<import class="org.concord.otrunk.script.ui.OTScriptButton" />
		<import class="org.concord.otrunk.ui.OTSlider" />
		<import class="org.concord.otrunk.ui.OTText" />
		<import class="org.concord.framework.otrunk.view.OTFrame" />
		<import class="org.concord.framework.otrunk.wrapper.OTObjectSet" />
	</imports>
	<idMap>
		<idMapping local_id="rabbit-species" id="8b5a6e28-684f-4673-b1d2-19a0c9b044be" />
		<idMapping local_id="plant-species" id="6904840c-03f6-4f2d-b822-bc85aebe70db" />
	</idMap>
	<objects>
		<OTSystem>
			<bundles>
				<object refid="8d880970-c22a-11dc-95ff-0800200c9a66" />
				<OTViewBundle>
					<frame>
						<OTFrame useScrollPane="false" openMaximized="false"
							width="900" height="500" />
					</frame>
				</OTViewBundle>
				<OTScriptEngineBundle>
					<engines>
						<OTScriptEngineEntry objectClass="org.concord.otrunk.script.js.OTJavascript"
							engineClass="org.concord.otrunk.script.js.OTJavascriptEngine" />
					</engines>
				</OTScriptEngineBundle>
			</bundles>
			<includes>
				<OTInclude href="../global-imports/er-view-bundle.otml" />
				<OTInclude href="species/fast-plants-roots.otml" />
				<OTInclude href="species/varied-rabbits.otml" />
			</includes>
			<root>
				<OTCompoundDoc>
					<bodyText>
						<object refid="${env-holder}" />
					</bodyText>
					<documentRefs>
						<OTEnvironmentHolder local_id="env-holder"
							width="590" height="460" toolbar="run,info,reset" useSpeedSlider="false">
							<environment>
								<OTEnvironment local_id="environment"
									environmentWidth="4" environmentHeight="4" showRunButton="false"
									winterLength="5" summerLength="50" showWinterImage="false"
									orgSizeMultiplier="1.5" backgroundImageSrc="images/green2.png">
									<world>
										<OTWorld local_id="peasimple_world"
											speciesPath="org/concord/biologica/worlds/peasimple.xml" />
									</world>
									<rules>
		               <OTRule description="don't show food bubble normally">
		                  <conditions>
		                    <OTRuleCondition always="true"/>
		                  </conditions>
		                  <consequences>
		                    <OTRuleConsequence property="show food bubble" newValueBoolean="false" />
		                  </consequences>
		                </OTRule>
		                <OTRule description="show food bubble when hungry">
		                  <conditions>
		                    <OTRuleCondition property="species name" equals="Rabbits"/>
		                    <OTRuleCondition property="energy" maxValue="20" />
		                  </conditions>
		                  <consequences>
		                    <OTRuleConsequence property="show food bubble" newValueBoolean="true" />
		                  </consequences>
		                </OTRule>
		              </rules>
								</OTEnvironment>
							</environment>
							<scripts>
								<OTScriptObject local_id="setup-script" name="Setup script">
									<script>
										<OTJavascript src="scripts/gradated-sunlight-five-blocks/setup.js">
											<script>
												importPackage(Packages.java.lang);
												importPackage(Packages.java.awt);
												importPackage(Packages.org.concord.biologica.environment);

												function init() {
												  env.addChangeListener(resetListener)
	                        setup();
													return true;
												}
												
												function setup() {
                          env.removeAllAgents()
                          env.setStepCount(0)
                          envHolder.pauseAction()
                          env.setWrapNorthSouth(false)
                          env.setWrapEastWest(false)
  
                          var smallRabbit = createRabbit();
                          smallRabbit.setProperty("prey variety value", 1);
                          smallRabbit.setProperty("variety", "Small rabbit");
                          env.addAgent(smallRabbit)
  
                          var medRabbit = createRabbit();
                          medRabbit.setProperty("prey variety value", 2);
                          medRabbit.setProperty("variety", "Medium rabbit");
                          env.addAgent(medRabbit)
  
                          var bigRabbit = createRabbit();
                          bigRabbit.setProperty("prey variety value", 3);
                          bigRabbit.setProperty("variety", "Big rabbit");
                          env.addAgent(bigRabbit)
												}

												function createRabbit() {
													var newRabbit = rabbit_species.createAgent();
													newRabbit.setAge(50)
													newRabbit.setProperty("is immortal", true)
													newRabbit.setProperty("max offspring", 0)
													newRabbit.setProperty("mating bonus", -1000)
													newRabbit.setProperty("hunger bonus", 50)
													newRabbit.setProperty("is selected", 0)
													newRabbit.setProperty("eating distance", 2)
													newRabbit.setProperty("speed", 3)
													var loc = env.getRandomLocation()
													newRabbit.setEnvironment(env)
													newRabbit.setLocation(loc)
													return newRabbit;
												}
												
												var resetRunHandler= {
                                    environmentChanged: function(evt){
                                      if (evt.getType() == EnvironmentChangeEvent.RESET){
                                        setup();
                                      }
                                    }
                                  }    
                                var resetListener = new EnvironmentChangeListener(resetRunHandler)

												function save() {
												  return true;
												}
												</script>
										</OTJavascript>
									</script>
									<variables>
										<OTScriptVariableRealObject name="env">
											<reference>
												<object refid="${environment}" />
											</reference>
										</OTScriptVariableRealObject>
										<OTScriptVariableRealObject name="envHolder">
											<reference>
												<object refid="${env-holder}" />
											</reference>
										</OTScriptVariableRealObject>
										<OTScriptVariableRealObject name="holder">
											<reference>
												<object refid="${env-holder}" />
											</reference>
										</OTScriptVariableRealObject>
										<OTScriptVariableRealObject name="rabbit_species">
											<reference>
												<object refid="${rabbit-species}" />
											</reference>
										</OTScriptVariableRealObject>
									</variables>
									<scriptState />
								</OTScriptObject>
							</scripts>
							<addAgentsButtons>
								<OTAddAgentButton text="Add Plant A" limit="-1" annotation="A">
									<species>
										<object refid="${plant-species}" />
									</species>
									<agentTraits>
										<OTAgentTrait property="roots">
											<defaultValues>
												<int>1</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="growth rate">
											<defaultValues>
												<float>0</float>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="age of maturity">
											<defaultValues>
												<int>15</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="Variety">
										  <defaultValues>
										    <string>Short grass</string>
										  </defaultValues>
										</OTAgentTrait>
									</agentTraits>
								</OTAddAgentButton>
								<OTAddAgentButton text="Add Plant B" limit="-1" annotation="B">
									<species>
										<object refid="${plant-species}" />
									</species>
									<agentTraits>
										<OTAgentTrait property="roots">
											<defaultValues>
												<int>2</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="growth rate">
											<defaultValues>
												<float>0</float>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="age of maturity">
											<defaultValues>
												<int>15</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="Variety">
                      <defaultValues>
                        <string>Medium grass</string>
                      </defaultValues>
                    </OTAgentTrait>
									</agentTraits>
								</OTAddAgentButton>
								<OTAddAgentButton text="Add Plant C" limit="-1" annotation="C">
									<species>
										<object refid="${plant-species}" />
									</species>
									<agentTraits>
										<OTAgentTrait property="roots">
											<defaultValues>
												<int>3</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="growth rate">
											<defaultValues>
												<float>0</float>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="age of maturity">
											<defaultValues>
												<int>15</int>
											</defaultValues>
										</OTAgentTrait>
										<OTAgentTrait property="Variety">
                      <defaultValues>
                        <string>Big grass</string>
                      </defaultValues>
                    </OTAgentTrait>
									</agentTraits>
								</OTAddAgentButton>
							</addAgentsButtons>
							<traitsToShow>
								<string>variety</string>
							</traitsToShow>
						</OTEnvironmentHolder>
					</documentRefs>
				</OTCompoundDoc>
			</root>
		</OTSystem>
	</objects>
</otrunk>

