<?xml version="1.0" encoding="UTF-8"?>
<otrunk id="a84064af-4585-49ae-8c97-2f79db987d63">
  <imports>
    <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.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.OTChoice" />
    <import class="org.concord.framework.otrunk.view.OTFrame" />
  </imports>
  <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" />
      </includes>
      <root>
        <OTCompoundDoc local_id="mountain-model">
          <bodyText>
            <table>
              <tr>
                <td>
                  <object refid="${env-holder}" />
                </td>
                <td>
                  <table>
                    <tr>
                      <td valign="top" align="right">Mountain height:</td>
                      <td align="center">
                        High
                        <br />
                        <object refid="${mountain-height-radio}" />
                        <br />
                        Low
                        <br />
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <object refid="${slider-script}" />
          </bodyText>
          <documentRefs>
            <OTEnvironmentHolder local_id="env-holder" toolbar="run,info,reset" useSpeedSlider="true" width="590" height="460" logAddAgents="false">
              <environment>
                <OTEnvironment local_id="environment" environmentWidth="15" environmentHeight="15" showRunButton="false" winterLength="2" summerLength="80" orgSizeMultiplier="1.5" backgroundImageSrc="images/mountains1.jpg">
                  <world>
                    <OTWorld local_id="peasimple_world" speciesPath="org/concord/biologica/worlds/peasimple.xml" />
                  </world>
                  <barriers>
                    <OTPlacement x="68" y="0" width="43" height="9" />
                    <OTPlacement x="69" y="9" width="38" height="9" />
                    <OTPlacement x="66" y="18" width="42" height="11" />
                    <OTPlacement x="64" y="29" width="43" height="7" />
                    <OTPlacement x="64" y="36" width="42" height="4" />
                    <OTPlacement x="59" y="40" width="48" height="5" />
                    <OTPlacement x="56" y="45" width="46" height="6" />
                    <OTPlacement x="56" y="52" width="48" height="5" />
                    <OTPlacement x="57" y="57" width="43" height="8" />
                    <OTPlacement x="57" y="65" width="45" height="6" />
                    <OTPlacement x="54" y="71" width="43" height="5" />
                    <OTPlacement x="51" y="76" width="47" height="5" />
                    <OTPlacement x="48" y="81" width="48" height="12" />
                    <OTPlacement x="45" y="93" width="46" height="9" />
                    <OTPlacement x="47" y="102" width="45" height="10" />
                    <OTPlacement x="44" y="111" width="45" height="27" />
                    <OTPlacement x="36" y="137" width="47" height="13" />
                    <OTPlacement x="56" y="51" width="46" height="1" />
                    <OTPlacement x="140" y="0" width="11" height="150" />
                    <OTPlacement x="0" y="0" width="10" height="150" />
                  </barriers>
                  <rules>
                    <OTRule description="Health depends on leaves and sunlight">
                      <conditions>
                        <OTRuleCondition always="true" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Health" ruleScript="var diff = Math.abs((11 - size_of_leaves) - (sunlight*10)); return 1 - (diff /  20)">
                          <propertyVariables>
                            <string>size of leaves</string>
                            <string>sunlight</string>
                          </propertyVariables>
                        </OTRuleConsequence>
                        <OTRuleConsequence property="Seed mid-Fall" newValueBoolean="true" />
                        <OTRuleConsequence property="min offspring distance" newValueFloat="5" />
                        <OTRuleConsequence property="max offspring distance" newValueFloat="25" />
                        <OTRuleConsequence property="Min offspring" newValueFloat="3.0" />
                        <OTRuleConsequence property="Max offspring" newValueFloat="5.0" />
                      </consequences>
                    </OTRule>
                    <OTRule description="No flowers on withered plants!">
                      <conditions>
                        <OTRuleCondition property="Health" minValue="0.0" maxValue="0.99" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Chance of flowering" newValueFloat="0.0" />
                      </consequences>
                    </OTRule>
                    <OTRule description="Healthy plants live through summer and flower">
                      <conditions>
                        <OTRuleCondition property="Season" equals="summer" />
                        <OTRuleCondition property="Health" minValue="0.99"/>
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Is immortal" newValueBoolean="true" />
                        <OTRuleConsequence property="chance of flowering" newValueFloat="0.2" />
                      </consequences>
                    </OTRule>
                    <OTRule description="Flowering plants live until they seed">
                      <conditions>
                        <OTRuleCondition property="Has flower" equals="true" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Is immortal" newValueBoolean="true" />
                      </consequences>
                    </OTRule>
                    <OTRule description="Plants die in fall">
                      <conditions>
                        <OTRuleCondition property="Season" equals="fall" />
                        <OTRuleCondition property="Has flower" equals="false" />
                        <OTRuleCondition property="Is seed" equals="false" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Is immortal" newValueBoolean="false" />
                        <OTRuleConsequence property="use default survival calculation" newValueBoolean="false" />
                        <OTRuleConsequence property="chance of survival" newValueFloat="0.8"/>
                      </consequences>
                    </OTRule>
                    <OTRule description="All plants die in winter">
                      <conditions>
                        <OTRuleCondition property="Season" equals="winter" />
                        <OTRuleCondition property="Is seed" equals="false" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="use default survival calculation" newValueBoolean="false" />
                        <OTRuleConsequence property="chance of survival" newValueFloat="0"/>
                      </consequences>
                    </OTRule>
                    <OTRule description="If resources low, lower reproduction rate">
                      <conditions>
                        <OTRuleCondition property="food" maxValue="50" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Min offspring" newValueFloat="1.0" />
                          <OTRuleConsequence property="MAx offspring" newValueFloat="2.0" />
                      </consequences>
                    </OTRule>
                    <OTRule description="If resources low, lower reproduction rate">
                      <conditions>
                        <OTRuleCondition property="food" maxValue="5" />
                      </conditions>
                      <consequences>
                        <OTRuleConsequence property="Min offspring" newValueFloat="0.0" />
                          <OTRuleConsequence property="MAx offspring" newValueFloat="1.0" />
                      </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() {
              env.removeAllAgents()
              env.setStepCount(0)
              envHolder.pauseAction()
              var world = env.getWorld();
              env.setWrapNorthSouth(false);
              env.setWrapEastWest(false);
              for (var i = 0; i &lt; 15; i++) {
                    for (var j = 0; j &lt; 15; j++) {
                      var envUnit = new EnvironmentUnit(env, null, i, j)
                      env.setEnvironmentUnit(envUnit, i, j)
                      envUnit.setProperty("sunlight", new Float(0.6))
                      var color = new Color(0.3, 0.2, 0.1)
                      var terrain = new Terrain(world, "terrain", color)
                      envUnit.setTerrain(terrain)
                      }
                  }
            return true;
            }
          
          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>
                  </variables>
                  <scriptState />
                </OTScriptObject>
                <OTScriptObject local_id="setup-species-script" name="Setup species">
                  <script>
                    <OTJavascript>
                      <script>function init()
                  {
                    species.setMutationChance(0.21)
                  }</script>
                    </OTJavascript>
                  </script>
                  <variables>
                    <OTScriptVariableRealObject name="species">
                      <reference>
                        <object refid="f5732706-c9c2-4e29-8c99-4c668dda89b0" />
                      </reference>
                    </OTScriptVariableRealObject>
                  </variables>
                  <scriptState />
                </OTScriptObject>
                <OTScriptObject local_id="runtime-script" name="Runtime">
                  <script>
                    <OTJavascript src="scripts/gradated-sunlight/setup.js" id="a845d044-bb0c-4784-8a5f-61807f514d25">
                      <script>importPackage(Packages.java.lang);
            importPackage(Packages.java.awt);
            importPackage(Packages.org.concord.biologica.environment);
            importClass(Packages.javax.swing.JOptionPane);
            
            var userAddedAgents
            var extinctionCount = 0   // this does NOT reset between runs
            var successful = false    // this does NOT reset between runs
            var yearsSuccessful   // don't win until final plants liev at least one year
            var allAgents
            var shownMessage
                    
            function init() {
              setup()
              env.addChangeListener(changeListener)
              env.addStepListener(stepListener)
              env.addChangeListener(resetListener)
              return true;
            }
            
            function setup() {
              userAddedAgents = false
              shownMessage = false
              yearsSuccessful = 0
            }
            
            var changeHandler = {
              environmentChanged: function(evt){  
                if (evt.getType() == EnvironmentChangeEvent.USER_ADDED_AGENTS){
                  userAddedAgents = true
                } else if (evt.getType() == EnvironmentChangeEvent.SEASON_CHANGE &amp;&amp; !shownMessage){
                  if (evt.getValue().equalsIgnoreCase("winter") || evt.getValue().equalsIgnoreCase("spring"))
                    return            // don't check on winter or spring, because it's hard for user to see what's happening
                  allAgents = env.getAllAgents()
                  var allExtinct = false
                  var halfExtinct = false
                  var willAnyoneSurvive = false     // if half extinct but no one will survive (all wilted) wait until all are extinct
                  if (allAgents.size() == 0){
                    allExtinct = true
                  } else {
                    var sunlightTopLeft = parseInt((env.getEnvironmentUnit(0,0).getProperty("sunlight") * 10)+0.5)   // stupid javascript, Float(0.7)*10 != 6.999...
                    var mountainHeight = sunlightTopLeft - 6
                    if (mountainHeight == 0)
                      return;
                      
                    halfExtinct = getSideIsExtinct()
                    if (halfExtinct)
                      willAnyoneSurvive = getWillAnyoneSurvive()
                    }
                    
                    var extinction = allExtinct || halfExtinct
                    
                    if (extinction){
                      if (successful &amp;&amp; (allExtinct || willAnyoneSurvive)){
                        // case 2
                        logSuccess(otEnvHolder)
                        showMessageAndLog("Las plantas se extinguieron. ¿Por qué las plantas\nse extinguieron cuando las montañas cambiaron rápidamente?\nAvanza a la siguiente página para responder esta pregunta.", env, envHolder, otEnvHolder)
                        envHolder.pauseAction()
                        extinctionCount++
                      } else if (extinctionCount == 0){
                        // case 1, first time
                        if (allExtinct) {
                          showMessageAndLog("Tus plantas se extinguieron. Haz clic en Reset e intenta de nuevo.", env, envHolder, otEnvHolder)
                          envHolder.pauseAction()
                          extinctionCount++
                        } else if (willAnyoneSurvive) {
                          showMessageAndLog("Tus plantas se extinguieron en un lado. Recuerda, el desafío es obtener plantas que den flores\nque crezcan en ambos lados de las montañas. Haz clic en Reset e intenta de nuevo.", env, envHolder, otEnvHolder)
                          envHolder.pauseAction()
                          extinctionCount++
                        }
                      } else {
                        // case 1, next times
                        if (allExtinct) {
                          showMessageAndLog("Tus plantas se volvieron a extinguir. El medio ambiente cambió demasiado rápido.\nEspera unas cuantas estaciones antes de que cambies la altura de la montaña.", env, envHolder, otEnvHolder)
                          envHolder.pauseAction()
                          extinctionCount++
                        } else if (willAnyoneSurvive) {
                          showMessageAndLog("La mitad de tus plantas se extinguieron de nuevo. El medio ambiente cambió demasiado rápido.\nEspera unas cuantas estaciones antes de que cambies la altura de la montaña.", env, envHolder, otEnvHolder)
                          envHolder.pauseAction()
                          extinctionCount++
                        }
                      }
                      shownMessage = true
                      return;
                    }
                    
                    // not extinct
                    if (mountainHeight == 4) {      // end
                      if (evt.getValue().equalsIgnoreCase("fall")) {      // only end on fall so we can see flowers
                        if (atLeastTenPlantsHealthyOnBothSides()) {
                          yearsSuccessful++
                          if (yearsSuccessful &gt; 1) {
                            successful = true
                            if (extinctionCount &gt; 0) {
                              // case 1 success
                              logSuccess(otEnvHolder)
                              showMessageAndLog("¡Gran trabajo Las montañas crecieron lo suficientemente lento como para que las plantas pudieran evolucionar.\nToma una foto y echale un vistazo a la gráfica.\nLuego continúa en la siguiente página.", env, envHolder, otEnvHolder)
                              envHolder.pauseAction()
                              shownMessage = true
                            } else {
                              // case 2 success
                              logSuccess(otEnvHolder)
                              showMessageAndLog("¡Felicidades! Las montañas crecieron lentamente y las plantas tuvieron tiempo de evolucionar.\n Toma una foto y echale un vistazo a la gráfica.\n Haz clic en Reset e intenta cambiar el medio ambiente rápidamente. ¿Qué crees que sucederá?", env, envHolder, otEnvHolder)
                              envHolder.pauseAction()
                              shownMessage = true
                            }
                          }
                        }
                      }
                    }
                  }
              }
            }
                    
            var changeListener = new EnvironmentChangeListener(changeHandler)
            
            function getSideIsExtinct(){
              var eastAlive = false
              var westAlive = false
              
              for (var i = 0; i &lt; allAgents.size(); i++) {
                var agent = allAgents.get(i)
                var x = agent.getLocation().x
                if (x &lt; (env.getColumns() / 2) * env.getUnitSize().getWidth()){
                  eastAlive = true
                } else {
                  westAlive = true
                }
            
                if (eastAlive &amp;&amp; westAlive){
                  return false
                }
              }
              
              return true
            }
            
            function getWillAnyoneSurvive(){
              for (var i = 0; i &lt; allAgents.size(); i++) {
                var agent = allAgents.get(i)
                var healthy = agent.getProperty("health") &gt; 0.99
                if (healthy){
                  return true
                }
              }
              return false
            }
            
            function atLeastTenPlantsHealthyOnBothSides(){
              var eastHealthyCount = 0
              var westHealthyCount = 0
              
              for (var i = 0; i &lt; allAgents.size(); i++) {
                var agent = allAgents.get(i)
                if (agent.getProperty("health") &gt; 0.99 &amp;&amp; !agent.getProperty("is seed").equals(true)) {
                  var x = agent.getLocation().x
                  if (x &lt; (env.getColumns() / 2) * env.getUnitSize().getWidth()){
                    eastHealthyCount++
                  } else {
                    westHealthyCount++
                  }
                }
                
                if (eastHealthyCount &gt;= 10 &amp;&amp; westHealthyCount &gt;= 10){
                  return true
                }
              }
              return false
            }
            
            var stepHandler = {
              environmentStepped: function(){
                if (!userAddedAgents){
                  env.setStepCount(0)   // don't start counting days until a seed is planted
                  return
                }
              }   
            }
                  
            var stepListener = new EnvironmentStepListener(stepHandler) 
            
            
            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>
                    <OTScriptVariable name="otEnvHolder">
                      <reference>
                        <object refid="${env-holder}" />
                      </reference>
                    </OTScriptVariable>
                  </variables>
                  <scriptState />
                </OTScriptObject>
              </scripts>
              <traitsToShow>
                <string>size of leaves</string>
              </traitsToShow>
              <addAgentsButtons>
                <OTAddAgentButton text="Add Plant A" quantity="8" click="false" limit="40">
                  <species>
                    <object refid="f5732706-c9c2-4e29-8c99-4c668dda89b0" />
                  </species>
                  <agentTraits>
                    <OTAgentTrait property="roots">
                      <defaultValues>
                        <float>5.0</float>
                      </defaultValues>
                    </OTAgentTrait>
                    <OTAgentTrait property="size of Leaves">
                      <defaultValues>
                        <float>5.0</float>
                      </defaultValues>
                    </OTAgentTrait>
                    <OTAgentTrait property="min offspring distance">
                      <defaultValues>
                        <int>5</int>
                      </defaultValues>
                    </OTAgentTrait>
                    <OTAgentTrait property="max offspring distance">
                      <defaultValues>
                        <int>20</int>
                      </defaultValues>
                    </OTAgentTrait>
                  </agentTraits>
                </OTAddAgentButton>
              </addAgentsButtons>
            </OTEnvironmentHolder>
            <OTScriptObject local_id="slider-script" name="Script object">
              <script>
                <OTJavascript local_id="script">
                  <script>importPackage(Packages.java.lang);
importPackage(Packages.java.net);
importPackage(Packages.java.awt.geom);
importPackage(Packages.javax.swing);
importPackage(Packages.org.concord.framework.otrunk);
importPackage(Packages.org.concord.biologica.environment);

var barriers
var emptyBarriers
var env = envHolder.getEnvironment()
var emptyEnv = emptyEnvHolder.getEnvironment()
var baseUrl = otEnvHolder.getOTObjectService().getCodebase(otEnvHolder)
var otEnvHolderController
             
function init() {
  radio.getCurrentChoices().set(0, choice_0)
  radio.addOTChangeListener(radioChangeListener)
  barriers = env.getBarriers()
  emptyBarriers = emptyEnv.getBarriers()
  env.setBarriers(emptyBarriers)
  
  var url = new URL(baseUrl, "images/mountains1.png")
  envHolder.getEnvironmentView().addBackgroundImageUrl(url)
  url = new URL(baseUrl, "images/mountains2flipped.jpg")
  envHolder.getEnvironmentView().addBackgroundImageUrl(url)
  url = new URL(baseUrl, "images/mountains3flipped.jpg")
  envHolder.getEnvironmentView().addBackgroundImageUrl(url)
  url = new URL(baseUrl, "images/mountains4flipped.jpg")
  envHolder.getEnvironmentView().addBackgroundImageUrl(url)
  url = new URL(baseUrl, "images/mountains5flipped.jpg")
  envHolder.getEnvironmentView().addBackgroundImageUrl(url)
  
  otEnvHolderController = controllerService.getController(otEnvHolder)
  
  if (radio.getName().equalsIgnoreCase("Radio2")) {     // this is the 2nd instance of the model
        otEnvHolderController.log("Model instance",2,null,null)
  } else {
    otEnvHolderController.log("Model instance",1,null,null)
  }
  
  env.addChangeListener(resetListener)
}


var radioChangeHandler =
{
    stateChanged: function(evt)
    {
      if (radio.getCurrentChoices().size() &lt; 1)
        return;
      
        var currChoice = radio.getCurrentChoices().get(0)
        var height = currChoice.getName()
        var url
        if (height == "0"){
          url = new URL(baseUrl, "images/mountains1.jpg")
          setSunlight(0.6,0.6)
      env.setBarriers(emptyBarriers)
        } else if (height == "1"){
          url = new URL(baseUrl, "images/mountains2flipped.jpg")
          setSunlight(0.7,0.5)
          env.setBarriers(barriers)
        } else if (height == "2"){
          url = new URL(baseUrl, "images/mountains3flipped.jpg")
          setSunlight(0.8,0.4)
          env.setBarriers(barriers)
        } else if (height == "3"){
          url = new URL(baseUrl, "images/mountains4flipped.jpg")
          setSunlight(0.9,0.3)
          env.setBarriers(barriers)
        } else {
          url = new URL(baseUrl, "images/mountains5flipped.jpg")
          setSunlight(1.0,0.2)
          env.setBarriers(barriers)
        }
        envHolder.getEnvironmentView().setBackgroundImageUrl(url)
        
        var numAgents = env.getAllAgents().size()
        otEnvHolderController.log("Mountain height changed, Num agents alive",height,numAgents,null)
        
    }

}
var radioChangeListener = new OTChangeListener(radioChangeHandler)

function setSunlight(left, right){
    for (var i = 0; i &lt; 15; i++) {
      var sunlight
      if (i &lt; 8)
        sunlight = left
      else
        sunlight = right
      for (var j = 0; j &lt; 15; j++) {
        env.getEnvironmentUnit(i,j).setProperty("sunlight", new Float(sunlight))
      }
    }
}

var resetHandler= {
  environmentChanged: function(evt){
    if (evt.getType() == EnvironmentChangeEvent.RESET){
      radio.getCurrentChoices().set(0, choice_0)
    }
  }
}
      
var resetListener = new EnvironmentChangeListener(resetHandler)

function save() {
  if (radio != null)
    radio.removeOTChangeListener(radioChangeListener)
  return true;
}

// by putting these urls after "src" we can ensure that the installer will cache
// the images:
// src="images/mountains2flipped.jpg"
// src="images/mountains3flipped.jpg"
// src="images/mountains4flipped.jpg"
// src="images/mountains5flipped.jpg"</script>
                  <scripts>
                    <OTJavascript src="scripts/common/message.js" />
                  </scripts>
                </OTJavascript>
              </script>
              <variables>
                <OTScriptVariable name="otEnvHolder">
                  <reference>
                    <object refid="${env-holder}" />
                  </reference>
                </OTScriptVariable>
                <OTScriptVariableRealObject name="envHolder">
                  <reference>
                    <object refid="${env-holder}" />
                  </reference>
                </OTScriptVariableRealObject>
                <OTScriptVariableRealObject name="emptyEnvHolder" local_id="empty-env-holder">
                  <reference>
                    <OTEnvironmentHolder width="1" height="1">
                      <environment>
                        <OTEnvironment environmentWidth="1" environmentHeight="1">
                          <world>
                            <object refid="${peasimple_world}"/>
                          </world>
                          <barriers>
                            <OTPlacement x="140" y="0" width="11" height="150" />
                            <OTPlacement x="0" y="0" width="10" height="150" />
                          </barriers>
                        </OTEnvironment>
                      </environment>
                    </OTEnvironmentHolder>
                  </reference>
                </OTScriptVariableRealObject>
                <OTScriptVariable name="radio">
                  <reference>
                    <object refid="${mountain-height-radio}" />
                  </reference>
                </OTScriptVariable>
                <OTScriptVariable name="choice_0">
                  <reference>
                    <object refid="f8f30d75-f5b3-4451-a1d8-76d660b77e8a" />
                  </reference>
                </OTScriptVariable>
              </variables>
            </OTScriptObject>
            <OTChoice local_id="mountain-height-radio" name="Multiple choice" horizontal="false" alignContent="0">
              <choices>
                <OTCompoundDoc name="4">
                  <bodyText />
                </OTCompoundDoc>
                <OTCompoundDoc name="3">
                  <bodyText />
                </OTCompoundDoc>
                <OTCompoundDoc name="2">
                  <bodyText />
                </OTCompoundDoc>
                <OTCompoundDoc name="1">
                  <bodyText />
                </OTCompoundDoc>
                <OTCompoundDoc id="f8f30d75-f5b3-4451-a1d8-76d660b77e8a" name="0">
                  <bodyText />
                </OTCompoundDoc>
              </choices>
              <currentChoices>
                <object refid="f8f30d75-f5b3-4451-a1d8-76d660b77e8a" />
              </currentChoices>
            </OTChoice>
          </documentRefs>
        </OTCompoundDoc>
      </root>
      <library>
        <OTChoice local_id="mountain-height-radio2" name="Radio2" horizontal="false" alignContent="0">
          <choices>
            <OTCompoundDoc name="4">
              <bodyText />
            </OTCompoundDoc>
            <OTCompoundDoc name="3">
              <bodyText />
            </OTCompoundDoc>
            <OTCompoundDoc name="2">
              <bodyText />
            </OTCompoundDoc>
            <OTCompoundDoc name="1">
              <bodyText />
            </OTCompoundDoc>
            <OTCompoundDoc id="a7f30d75-f5b3-4451-a1d8-76d660b77e8a" name="0">
              <bodyText />
            </OTCompoundDoc>
          </choices>
          <currentChoices>
            <object refid="a7f30d75-f5b3-4451-a1d8-76d660b77e8a" />
          </currentChoices>
        </OTChoice>
        <OTScriptObject local_id="slider-script2" name="Script object">
          <script>
            <object refid="${script}" />
          </script>
          <variables>
            <OTScriptVariable name="otEnvHolder">
              <reference>
                <object refid="${env-holder}" />
              </reference>
            </OTScriptVariable>
            <OTScriptVariableRealObject name="envHolder">
              <reference>
                <object refid="${env-holder}" />
              </reference>
            </OTScriptVariableRealObject>
            <OTScriptVariable name="radio">
              <reference>
                <object refid="${mountain-height-radio2}" />
              </reference>
            </OTScriptVariable>
            <OTScriptVariable name="choice_0">
              <reference>
                <object refid="a7f30d75-f5b3-4451-a1d8-76d660b77e8a" />
              </reference>
            </OTScriptVariable>
            <object refid="${empty-env-holder}"/>
          </variables>
        </OTScriptObject>
      </library>
    </OTSystem>
  </objects>
</otrunk>