<?xml version="1.0" encoding="UTF-8"?>
<otrunk id="13d3fb4f-123a-425f-9d60-d84e145c0678">
  <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.rules.OTRule" />
    <import class="org.concord.otrunk.biologica.rules.OTRuleCondition" />
    <import class="org.concord.otrunk.biologica.rules.OTRuleConsequence" />
    <import class="org.concord.otrunk.biologica.data.OTBiologicaModelDataProducer" />
    <import class="org.concord.otrunk.ui.OTCardContainer" />
    <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.OTSliderLabel" />
    <import class="org.concord.framework.otrunk.view.OTFrame" />
  </imports>
  <idMap> 
    <idMapping local_id="rabbit-species" id="f05fc1b1-ea0e-4d6e-a21e-7d089860445a"/>
    <idMapping local_id="fox-species" id="c59a7a17-5585-4860-b6a5-803e74ea2dbd"/>
    <idMapping local_id="plant-species" id="f5732706-c9c2-4e29-8c99-4c668dda89b0"/>
    <idMapping local_id="holes" id="d670b7f4-2f3b-466a-90da-8a18e2862430"/>
  </idMap> 
  <objects>
    <OTSystem>
      <bundles>
        <object refid="8d880970-c22a-11dc-95ff-0800200c9a66" />
        <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/annual-varied-plants.otml" />
        <OTInclude href="species/white-rabbits.otml" />
        <OTInclude href="species/foxes.otml" />
        <OTInclude href="species/env-feature-holes.otml" />
      </includes>
      <root>
        <OTCardContainer contentsMayScroll="true">
          <cards>
            <OTCompoundDoc>
              <bodyText>
                <table width="100%">
                  <tr>
                    <td>
                      <object refid="${env-holder}"/>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <table width="70%" border="1">
                        <tr>
                          <th rowspan="2">
                            <b>Rabbit</b>
                          </th>
                          <th>
                            Hunger bonus:
                          </th>
                          <th>
                            Mating desire bonus:
                          </th>
                          <th>
                            Max energy:
                          </th>
                          <th>
                            Metabolism:
                          </th>
                          <th>
                            Chance of being seen:
                          </th>
                          <th>
                            Vision distance:
                          </th>
                          <th>
                            Max age:
                          </th>
                          <th>
                            Reproduce:
                          </th>
                          <th>
                            Min offspring
                          </th>
                          <th>
                            Max offspring
                          </th>
                        </tr>
                        <tr>
                          <td>
                            <object refid="${rabbit-hunger-bonus-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-mating-desire-bonus-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-max-energy-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-metabolism-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-chance-of-being-seen-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-vision-distance-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-max-age-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-reproduce-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-min-offspring-slider}"/>
                          </td>
                          <td>
                            <object refid="${rabbit-max-offspring-slider}"/>
                          </td>
                          <td>
                            <object refid="${slider-script}"/>
                          </td>
                        </tr>
                        <tr>
                          <td>
                            <b>Fox</b>
                          </td>
                          <td>
                            <object refid="${fox-hunger-bonus-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-mating-desire-bonus-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-max-energy-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-metabolism-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-chance-of-being-seen-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-vision-distance-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-max-age-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-reproduce-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-min-offspring-slider}"/>
                          </td>
                          <td>
                            <object refid="${fox-max-offspring-slider}"/>
                          </td>
                        </tr>
                        <tr>
                        </tr>
                      </table>
                      <table border="1">
                        <tr>
                          <th rowspan="2">Plant</th><th>Min offspring</th><th>Max offspring</th>
                        </tr>
                        <tr>
                          <td>
                            <object refid="${plant-min-offspring-slider}"/>
                          </td>
                          <td>
                            <object refid="${plant-max-offspring-slider}"/>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </bodyText>
              <documentRefs>
                <OTEnvironmentHolder local_id="env-holder" width="590" height="460" toolbar="run,cursor,reset" useSpeedSlider="true">
                  <environment>
                    <OTEnvironment local_id="environment" environmentWidth="20" environmentHeight="20" showRunButton="false" winterLength="15" summerLength="50" showWinterImage="false" orgSizeMultiplier="2" backgroundImageSrc="images/mountains1.png">
                      <world>
                        <OTWorld local_id="peasimple_world" speciesPath="org/concord/biologica/worlds/peasimple.xml" />
                      </world>
                      <barriers>
                        <OTPlacement x="0" y="0" width="10" height="150" />
                      </barriers>
                      <rules>
                        <OTRule description="All plants healthy">
                          <conditions>
                            <OTRuleCondition property="species name" equals="Plants" />
                          </conditions>
                          <consequences>
                            <OTRuleConsequence property="Health" newValueFloat="0.99" />
                          </consequences>
                        </OTRule>
                      </rules>
                    </OTEnvironment>
                  </environment>
                  <scripts>
                    <OTScriptObject local_id="setup-script" name="Setup world">
                      <script>
                        <OTJavascript src="scripts/gradated-sunlight/setup.js">
                          <script>importPackage(Packages.java.lang);
                  importPackage(Packages.java.awt);
                  importPackage(Packages.org.concord.biologica.environment);
                  importClass(Packages.javax.swing.JOptionPane);

                  function init() {
                      setup()
                      env.addChangeListener(resetListener)

                      return true;
                    }

                    function setup(){
                      env.removeAllAgents()
                      env.setStepCount(0)
                      envHolder.pauseAction()
                      var world = env.getWorld();
                      env.setWrapNorthSouth(false);
                      env.setWrapEastWest(false);
                      for (var i = 0; i &lt; 20; i++) {
                            for (var j = 0; j &lt; 20; j++) {
                              var envUnit = new EnvironmentUnit(env, null, i, j)
                              env.setEnvironmentUnit(envUnit, i, j)
                              var color = new Color(0.3, 0.2, 0.1)
                              var terrain = new Terrain(world, "terrain", color)
                              envUnit.setTerrain(terrain)
                              }
                          }

                          for (var i = 0; i &lt; 50; i++) {
                            var plant = plant_species.createAgent();
                        plant.setAge(i*2)
                        env.addAgent(plant)
                          }

                          env.step()
                    }

                    var resetHandler= {
                      environmentChanged: function(evt){
                        if (evt.getType() == EnvironmentChangeEvent.RESET){
                          setup()
                        }
                      }
                    }

                    var resetListener = new EnvironmentChangeListener(resetHandler)

                function save() {
                  return true;
                }</script>
                          <scripts>
                            <OTJavascript src="scripts/common/message.js" />
                          </scripts>
                        </OTJavascript>
                      </script>
                      <variables>
                        <OTScriptVariableRealObject name="env">
                          <reference>
                            <object refid="${environment}" />
                          </reference>
                        </OTScriptVariableRealObject>
                        <OTScriptVariableRealObject name="envHolder">
                          <reference>
                            <object refid="${env-holder}" />
                          </reference>
                        </OTScriptVariableRealObject>
                        <OTScriptVariableRealObject name="plant_species">
                          <reference>
                            <object refid="${plant-species}"/>
                          </reference>
                        </OTScriptVariableRealObject>
                      </variables>
                      <scriptState />
                    </OTScriptObject>
                    <OTScriptObject local_id="setup-species-script" name="Setup species">
                      <script>
                        <OTJavascript>
                          <script>function init()
                        {
                          species.setMutationChance(0)
                        }</script>
                        </OTJavascript>
                      </script>
                      <variables>
                        <OTScriptVariableRealObject name="species">
                          <reference>
                            <object refid="f5732706-c9c2-4e29-8c99-4c668dda89b0" />
                          </reference>
                        </OTScriptVariableRealObject>
                      </variables>
                      <scriptState />
                    </OTScriptObject>
                  </scripts>
                  <traitsToShow>
                    <string>size of leaves</string>
                  </traitsToShow>
                  <addAgentsButtons>
                    <OTAddAgentButton text="Add plants" quantity="20" click="false" limit="-1">
                        <species>
                          <object refid="${plant-species}" />
                        </species>
                      </OTAddAgentButton>
                    <OTAddAgentButton text="Add Rabbit" quantity="1" click="false" limit="-1">
                        <species>
                          <object refid="${rabbit-species}" />
                        </species>
                      </OTAddAgentButton>
                      <OTAddAgentButton text="Add fox" quantity="1" click="false" limit="-1">
                        <species>
                          <object refid="${fox-species}" />
                        </species>
                      </OTAddAgentButton>
                      <OTAddAgentButton text="Add holes" quantity="10" click="false" limit="-1">
                        <species>
                          <object refid="${holes}" />
                        </species>
                      </OTAddAgentButton>
                  </addAgentsButtons>
                </OTEnvironmentHolder>
                <OTDataCollector local_id="graph">
                </OTDataCollector>
                <OTSlider local_id="rabbit-hunger-bonus-slider" minimum="-100" maximum="100" value="0" numTicks="8" numMajorTicks="8" length="120"/>
                <OTSlider local_id="fox-hunger-bonus-slider" minimum="-100" maximum="100" value="0" numTicks="8" numMajorTicks="8" length="120"/>
                <OTSlider local_id="rabbit-mating-desire-bonus-slider" minimum="-50" maximum="50" value="0" numTicks="8" numMajorTicks="4" length="120"/>
                <OTSlider local_id="fox-mating-desire-bonus-slider" minimum="-50" maximum="50" value="0" numTicks="8" numMajorTicks="4" length="120"/>
                <OTSlider local_id="rabbit-max-energy-slider" minimum="0" maximum="500" value="100" numTicks="10" numMajorTicks="5" length="120"/>
                <OTSlider local_id="fox-max-energy-slider" minimum="0" maximum="500" value="300" numTicks="10" numMajorTicks="5" length="120"/>
                <OTSlider local_id="rabbit-metabolism-slider" minimum="0" maximum="15" value="3" numTicks="15" length="120"/>
                <OTSlider local_id="fox-metabolism-slider" minimum="0" maximum="15" value="3" numTicks="15" length="120"/>
                <OTSlider local_id="rabbit-chance-of-being-seen-slider" minimum="0" maximum="100" value="100" numTicks="20" length="120"/>
                <OTSlider local_id="fox-chance-of-being-seen-slider" minimum="0" maximum="100" value="90" numTicks="20" length="120"/>
                <OTSlider local_id="rabbit-vision-distance-slider" minimum="0" maximum="100" value="30" numTicks="20" length="120"/>
                <OTSlider local_id="fox-vision-distance-slider" minimum="0" maximum="100" value="35" numTicks="20" length="120"/>
                <OTSlider local_id="rabbit-max-age-slider" minimum="0" maximum="2000" value="1000" numTicks="20" length="120"/>
                <OTSlider local_id="fox-max-age-slider" minimum="0" maximum="2000" value="1000" numTicks="20" length="120"/>
                <OTSlider local_id="rabbit-reproduce-slider" minimum="0" maximum="1" value="1" numMajorTicks="1" snapToMarks="true" precision="1" length="60">
                  <labels>
                    <OTSliderLabel value="0" label="asexual" />
                    <OTSliderLabel value="1" label="sexual" />
                  </labels>
                </OTSlider>
                <OTSlider local_id="fox-reproduce-slider" minimum="0" maximum="1" value="1" numMajorTicks="1" snapToMarks="true" precision="1" length="60">
                  <labels>
                    <OTSliderLabel value="0" label="asexual" />
                    <OTSliderLabel value="1" label="sexual" />
                  </labels>
                </OTSlider>
                    <OTSlider local_id="rabbit-min-offspring-slider" minimum="0" maximum="10" value="1" numTicks="10" length="120" snapToMarks="true"/>
                    <OTSlider local_id="rabbit-max-offspring-slider" minimum="0" maximum="10" value="6" numTicks="10" length="120" snapToMarks="true"/>
                    <OTSlider local_id="fox-min-offspring-slider" minimum="0" maximum="10" value="1" numTicks="10" length="120" snapToMarks="true"/>
                    <OTSlider local_id="fox-max-offspring-slider" minimum="0" maximum="10" value="2" numTicks="10" length="120" snapToMarks="true"/>
                    <OTSlider local_id="plant-min-offspring-slider" minimum="0" maximum="10" value="4" numTicks="10" length="120" snapToMarks="true"/>
                    <OTSlider local_id="plant-max-offspring-slider" minimum="0" maximum="10" value="8" numTicks="10" length="120" snapToMarks="true"/>
                <OTScriptButton local_id="slider-script" name="Slider script" text="Update">
                    <script>
                      <OTJavascript>
                        <script>importPackage(Packages.java.lang);
                importPackage(Packages.java.awt);
                importPackage(Packages.org.concord.biologica.environment);
                importPackage(Packages.org.concord.biologica.agebt);

                function clicked() {
                    rabbit_species.setTrait("hunger bonus", rabbit_hunger_bonus_slider.getValue())
                    rabbit_species.setTrait("mating desire bonus", rabbit_mating_desire_bonus_slider.getValue())
                    rabbit_species.setTrait("max energy", rabbit_max_energy_slider.getValue())
                    rabbit_species.setTrait("metabolism", rabbit_metabolism_slider.getValue())
                    rabbit_species.setTrait("chance of being seen", rabbit_chance_of_being_seen_slider.getValue())
                    rabbit_species.setTrait("vision distance", rabbit_vision_distance_slider.getValue())
                                    rabbit_species.setTrait("age limit", rabbit_max_age_slider.getValue())
                    rabbit_species.setReproductiveStrategy(rabbit_reproduce_slider.getValue() == 0 ? "asexual" : "sexual")
                                    rabbit_species.setTrait("min offspring", rabbit_min_offspring_slider.getValue())
                                    rabbit_species.setTrait("max offspring", rabbit_max_offspring_slider.getValue())
                    fox_species.setTrait("hunger bonus", fox_hunger_bonus_slider.getValue())
                    fox_species.setTrait("mating desire bonus", fox_mating_desire_bonus_slider.getValue())
                    fox_species.setTrait("max energy", fox_max_energy_slider.getValue())
                    fox_species.setTrait("metabolism", fox_metabolism_slider.getValue())
                    fox_species.setTrait("chance of being seen", fox_chance_of_being_seen_slider.getValue())
                    fox_species.setTrait("vision distance", fox_vision_distance_slider.getValue())
                    fox_species.setTrait("age limit", fox_max_age_slider.getValue())
                    fox_species.setReproductiveStrategy(fox_reproduce_slider.getValue() == 0 ? "asexual" : "sexual")
                                    fox_species.setTrait("min offspring", fox_min_offspring_slider.getValue())
                                    fox_species.setTrait("max offspring", fox_max_offspring_slider.getValue())
                                    plant_species.setTrait("min offspring", plant_min_offspring_slider.getValue())
                                    plant_species.setTrait("max offspring", plant_max_offspring_slider.getValue())
                  }

                  </script>
                      </OTJavascript>
                    </script>
                    <scriptVariables>
                      <OTScriptVariableRealObject name="rabbit_species">
                        <reference>
                          <object refid="${rabbit-species}"/>
                        </reference>
                      </OTScriptVariableRealObject>
                      <OTScriptVariableRealObject name="fox_species">
                        <reference>
                          <object refid="${fox-species}"/>
                        </reference>
                      </OTScriptVariableRealObject>
                        <OTScriptVariableRealObject name="plant_species">
                            <reference>
                                <object refid="${plant-species}"/>
                            </reference>
                        </OTScriptVariableRealObject>
                      <OTScriptVariable name="rabbit_hunger_bonus_slider">
                        <reference>
                          <object refid="${rabbit-hunger-bonus-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_mating_desire_bonus_slider">
                        <reference>
                          <object refid="${rabbit-mating-desire-bonus-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_max_energy_slider">
                        <reference>
                          <object refid="${rabbit-max-energy-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_metabolism_slider">
                        <reference>
                          <object refid="${rabbit-metabolism-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_chance_of_being_seen_slider">
                        <reference>
                          <object refid="${rabbit-chance-of-being-seen-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_vision_distance_slider">
                        <reference>
                          <object refid="${rabbit-vision-distance-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_max_age_slider">
                        <reference>
                          <object refid="${rabbit-max-age-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_hunger_bonus_slider">
                        <reference>
                          <object refid="${fox-hunger-bonus-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_mating_desire_bonus_slider">
                        <reference>
                          <object refid="${fox-mating-desire-bonus-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_max_energy_slider">
                        <reference>
                          <object refid="${fox-max-energy-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_metabolism_slider">
                        <reference>
                          <object refid="${fox-metabolism-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_chance_of_being_seen_slider">
                        <reference>
                          <object refid="${fox-chance-of-being-seen-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_vision_distance_slider">
                        <reference>
                          <object refid="${fox-vision-distance-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_max_age_slider">
                        <reference>
                          <object refid="${fox-max-age-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="rabbit_reproduce_slider">
                        <reference>
                          <object refid="${rabbit-reproduce-slider}"/>
                        </reference>
                      </OTScriptVariable>
                      <OTScriptVariable name="fox_reproduce_slider">
                        <reference>
                          <object refid="${fox-reproduce-slider}"/>
                        </reference>
                      </OTScriptVariable>
                        <OTScriptVariable name="rabbit_min_offspring_slider">
                            <reference>
                                <object refid="${rabbit-min-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                        <OTScriptVariable name="rabbit_max_offspring_slider">
                            <reference>
                                <object refid="${rabbit-max-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                        <OTScriptVariable name="fox_min_offspring_slider">
                            <reference>
                                <object refid="${fox-min-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                        <OTScriptVariable name="fox_max_offspring_slider">
                            <reference>
                                <object refid="${fox-max-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                        <OTScriptVariable name="plant_min_offspring_slider">
                            <reference>
                                <object refid="${plant-min-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                        <OTScriptVariable name="plant_max_offspring_slider">
                            <reference>
                                <object refid="${plant-max-offspring-slider}"/>
                            </reference>
                        </OTScriptVariable>
                    </scriptVariables>
                  </OTScriptButton>
              </documentRefs>
            </OTCompoundDoc>
          </cards>
        </OTCardContainer>
      </root>
    </OTSystem>
  </objects>
</otrunk>

