extensions [profiler] breed [preys prey] breed [predators predator] preys-own [ my-rule-number fitness my-rule body-color ] predators-own [ aversion motivation former-vision novelty ] globals [ INTERNAL-RULE-LIST RULES-RANK RULE-ED-LIST MAJOR-RULE-LIST MAX-RATIO-LIST TIME-STEP INTERACTION-FRAME ] to setup clear-all __clear-all-and-reset-ticks generate-lists ifelse length INTERNAL-RULE-LIST = 0 [ user-message "You need at least 1 rule" ] [ real-setup ] reset-ticks end to real-setup set MAJOR-RULE-LIST (list) set MAX-RATIO-LIST (list) resize-world 0 WORLD-SIZE 0 WORLD-SIZE set-patch-size 400 / WORLD-SIZE ask patches [ set pcolor green ] set-default-shape preys "butterfly" let prey-index 0 create-preys PREY-FREQUENCY / 100 * WORLD-SIZE ^ 2 [ set fitness 1 while [count preys-here > 1] [ setxy random-pxcor random-pycor ] set heading 0 set color 0 set size 1 if prey-index >= length INTERNAL-RULE-LIST [ set prey-index 0 ] set my-rule-number prey-index set label-color white set label my-rule-number set my-rule item my-rule-number INTERNAL-RULE-LIST let the-rule item 0 my-rule apply-rule the-rule set prey-index prey-index + 1 ] create-predators PREDATOR-FREQUENCY / 100 * WORLD-SIZE ^ 2 [ while [count predators-here > 1] [ setxy random-pxcor random-pycor ] set heading 0 set color yellow set size 0.6 ] set-current-plot "Rules Histogram" set-current-plot-pen "default" histogram [my-rule-number] of preys end to move setxy random-pxcor random-pycor while [not (count predators-here = 1 and count preys-here = 1)] [ setxy random-pxcor random-pycor ] end to apply-rule [the-rule] let old-color body-color if the-rule = "N" [ set color 10 set body-color 0 ] if the-rule = "L" [ set color 13 set body-color L-COLOR ] if the-rule = "H" [ set color 16 set body-color H-COLOR ] if old-color != body-color [ set fitness fitness * (1 - SWITCHING-COST) ] end to observe apply-rule item 0 my-rule if count predators-here > 0 [ apply-rule item 1 my-rule ] end to detect set motivation 0 let bcolor [body-color] of one-of preys-here set former-vision bcolor let discovery-chance BASAL-DETECTABILITY + (1 - BASAL-DETECTABILITY) * bcolor if discovery-chance > random-float 1 [ set motivation 1 - aversion * (BASAL-COGNITIVE-CUE + bcolor * (1 - BASAL-COGNITIVE-CUE)) ] end to attack let target one-of preys-here ask target [ apply-rule item 2 my-rule set fitness fitness * (1 - ifelse-value (TIME-STEP < 4) [INITIAL-ATTACK-DAMAGE] [FINAL-ATTACK-DAMAGE]) ] let bcolor [body-color] of target let delta-aversion LEARNING-SPEED * BAD-TASTE * (BASAL-COGNITIVE-CUE + bcolor * (1 - BASAL-COGNITIVE-CUE)) set delta-aversion delta-aversion * (1 + abs(bcolor - former-vision) * LEARNING-AID-EFFECT) set aversion aversion + delta-aversion let post-attack-attractiveness (1 - BAD-TASTE) * (1 - aversion * (BASAL-COGNITIVE-CUE + bcolor * (1 - BASAL-COGNITIVE-CUE))) * (1 - STARTLE-EFFECT * (bcolor - former-vision) * novelty) set novelty novelty * (1 - abs (bcolor - former-vision) * HABITUATION-SPEED) set motivation motivation * post-attack-attractiveness end to expose set fitness fitness * (1 - body-color * time-step-signal-penalty) end to-report time-step-signal-penalty report (1 - (1 - SIGNAL-PENALTY) ^ (1 / 4)) end to-report explode [string] ifelse (1 = length string) [ report (list string) ] [ report sentence (list first string) explode but-first string ] end to pay-fixed if (length remove-duplicates explode my-rule) > 1 [ set fitness fitness * (1 - SWITCHABILITY-MAINTENANCE-COST) ] end to turnover if random-float 1 < (PREDATOR-TURNOVER / 100) [ set aversion 0 set novelty 1 ] end to go set TIME-STEP 1 ask predators [move] ask preys [observe] ask preys [expose] tick set TIME-STEP 2 ask predators [detect] ask preys [expose] tick set TIME-STEP 3 ask predators with [motivation > random-float 1] [attack] ask preys [expose] tick set TIME-STEP 4 ask predators with [motivation > random-float 1] [attack] ask preys [expose] tick set INTERACTION-FRAME INTERACTION-FRAME + 1 if INTERACTION-FRAME mod GENERATION-LENGTH = 0 [ ask predators [turnover] let popcap count preys ask preys [pay-fixed] ask preys [die-off] ask preys [set fitness 1] while [count preys < popcap] [ ask one-of preys [ hatch-preys 1 while [count preys-here > 1] [ setxy random-pxcor random-pycor ] ] ] ] if PLOT-ON [ set-current-plot "Rules Histogram" set-current-plot-pen "default" histogram [my-rule-number] of preys set-current-plot "Predator aversion" set-current-plot-pen "default" set-histogram-num-bars 250 histogram [aversion] of predators ] if false [ let rule-count-list (list) foreach INTERNAL-RULE-LIST [ let rule-count count preys with [my-rule = ?] set rule-count-list lput rule-count rule-count-list ] let maxcount max rule-count-list set MAX-RATIO-LIST lput (maxcount / count preys) MAX-RATIO-LIST set MAJOR-RULE-LIST lput position maxcount rule-count-list MAJOR-RULE-LIST ] end to-report result let rule-count-list (list) foreach INTERNAL-RULE-LIST [ let rule-count count preys with [my-rule = ?] set rule-count-list lput rule-count rule-count-list ] let maxcount max rule-count-list report position maxcount rule-count-list end to die-off if random-float 1 > fitness and count preys with [my-rule = [my-rule] of myself] > 1 [ die ] end to generate-lists set INTERNAL-RULE-LIST rules-internal if is-list? INTERNAL-RULE-LIST != TRUE [ set INTERNAL-RULE-LIST (list) ] if is-list? RULE-ED-LIST != TRUE [ set RULE-ED-LIST (list) ] end to-report rules-internal let final-list (list) set RULES-LIST remove " " RULES-LIST set RULES-LIST word RULES-LIST "\n" set RULES-LIST find-and-replace "\n\n" "\n" RULES-LIST let the-temp-string RULES-LIST while [length the-temp-string > 1] [ let index position "\n" the-temp-string let first-item substring the-temp-string 0 (index) ifelse grammar-test first-item [ set final-list lput first-item final-list ] [ if index > 0 [ user-message word first-item " is not a legal rule" set RULES-LIST find-and-replace (word "\n" first-item "\n") "\n" RULES-LIST ] ] set the-temp-string substring the-temp-string (index + 1) (length the-temp-string) ] set final-list remove-duplicates final-list let final-string "" foreach final-list [ set final-string word final-string position ? final-list set final-string word final-string " " set final-string word final-string ? set final-string word final-string "\n" ] set PARSED-RULES final-string report final-list end to-report find-and-replace [query value text] let new-text text while [position query new-text != FALSE] [ let index position query new-text let extent length query let text-head substring new-text 0 index let text-body value let text-tail substring new-text (index + extent) length new-text set new-text (word text-head text-body text-tail) ] report new-text end to-report grammar-test [first-item] let test-result FALSE if length first-item = 3 [ let remnant remove "N" first-item set remnant remove "L" remnant set remnant remove "H" remnant if length remnant = 0 [ set test-result TRUE ] ] report test-result end to update-output clear-output foreach INTERNAL-RULE-LIST [ output-type position ? INTERNAL-RULE-LIST output-type " " output-type ? output-type " " ; output-type item position ? INTERNAL-RULE-LIST RULE-ED-LIST output-print "" ] end @#$#@#$#@ GRAPHICS-WINDOW 785 10 1223 469 -1 -1 28.571428571428573 1 10 1 1 1 0 1 1 1 0 14 0 14 1 1 0 ticks 30.0 SLIDER 15 90 245 123 WORLD-SIZE WORLD-SIZE 0 100 14 1 1 ^2 squares HORIZONTAL TEXTBOX 25 75 175 93 World Parameters 12 0.0 1 TEXTBOX 50 10 640 56 ApoSim 2.3: Switchable Aposematism 20 0.0 1 SLIDER 15 180 245 213 GENERATION-LENGTH GENERATION-LENGTH 0 500 50 1 1 NIL HORIZONTAL SLIDER 15 330 245 363 PREDATOR-TURNOVER PREDATOR-TURNOVER 0 100 1 1 1 % HORIZONTAL TEXTBOX 485 70 705 96 Safe/Approached/Attacked 12 0.0 1 SLIDER 245 125 475 158 PREY-FREQUENCY PREY-FREQUENCY 0 100 92 1 1 % HORIZONTAL SLIDER 15 125 245 158 PREDATOR-FREQUENCY PREDATOR-FREQUENCY 0 100 23 1 1 % HORIZONTAL BUTTON 255 35 525 68 Apply Parameters and Generate World setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 115 35 257 68 One Frame Forward go NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 10 35 117 68 Play/Pause go T 1 T OBSERVER NIL NIL NIL NIL 1 PLOT 485 355 785 505 Rules Histogram Rules count 0.0 10.0 0.0 10.0 true false "" "" PENS "default" 1.0 1 -16777216 true "" "" MONITOR 620 90 730 135 Generation INTERACTION-FRAME / GENERATION-LENGTH 0 1 11 MONITOR 675 130 730 175 Preys count preys 0 1 11 INPUTBOX 485 90 620 150 RULES-LIST NNN\nNNL\nNNH\nNLL\nNHH\nLLL\nLLH\nLHH\nHHH\n 1 1 String INPUTBOX 485 130 620 355 PARSED-RULES 0 NNN\n1 NNL\n2 NNH\n3 NLL\n4 NHH\n5 LLL\n6 LLH\n7 LHH\n8 HHH\n 1 1 String MONITOR 485 115 620 160 Number of Rules length rules-internal 17 1 11 MONITOR 620 215 730 260 Average Aversion mean [aversion] of predators 3 1 11 PLOT 485 505 785 655 Predator Aversion NIL NIL 0.0 15.0 0.0 10.0 true false "" "" PENS "default" 1.0 1 -16777216 true "" "" MONITOR 620 130 675 175 Predators count predators 17 1 11 MONITOR 620 260 730 305 Time Step max(list 1 (TIME-STEP - 1)) 17 1 11 MONITOR 620 170 730 215 Frames INTERACTION-FRAME 17 1 11 SLIDER 245 220 475 253 L-COLOR L-COLOR 0 1 0.3 0.01 1 NIL HORIZONTAL SLIDER 245 255 475 288 H-COLOR H-COLOR 0 1 1 0.01 1 NIL HORIZONTAL SLIDER 245 330 475 363 LEARNING-SPEED LEARNING-SPEED 0 1000 0 0.001 1 NIL HORIZONTAL SLIDER 15 255 245 288 BASAL-DETECTABILITY BASAL-DETECTABILITY 0 1 0.05 0.01 1 NIL HORIZONTAL SLIDER 15 220 245 253 BASAL-COGNITIVE-CUE BASAL-COGNITIVE-CUE 0 1 0.1 0.01 1 NIL HORIZONTAL SLIDER 15 290 245 323 BAD-TASTE BAD-TASTE 0 1 0.1 0.01 1 NIL HORIZONTAL SLIDER 15 465 245 498 INITIAL-ATTACK-DAMAGE INITIAL-ATTACK-DAMAGE 0 1 0.1 0.01 1 NIL HORIZONTAL SLIDER 245 465 475 498 FINAL-ATTACK-DAMAGE FINAL-ATTACK-DAMAGE 0 1 0.4 0.01 1 NIL HORIZONTAL SLIDER 15 370 245 403 SIGNAL-PENALTY SIGNAL-PENALTY 0 0.04 0.13 0.0000000001 1 NIL HORIZONTAL SLIDER 245 370 475 403 SWITCHING-COST SWITCHING-COST 0 0.005 0.016 0.0000001 1 NIL HORIZONTAL SLIDER 15 405 245 438 SWITCHABILITY-MAINTENANCE-COST SWITCHABILITY-MAINTENANCE-COST 0 1 0.4 0.01 1 NIL HORIZONTAL SWITCH 620 35 725 68 PLOT-ON PLOT-ON 1 1 -1000 SLIDER 15 505 245 538 LEARNING-AID-EFFECT LEARNING-AID-EFFECT 0 5 0 0.01 1 NIL HORIZONTAL SLIDER 15 540 245 573 STARTLE-EFFECT STARTLE-EFFECT 0 1 0 0.01 1 NIL HORIZONTAL SLIDER 245 540 475 573 HABITUATION-SPEED HABITUATION-SPEED 0 1 0 0.01 1 NIL HORIZONTAL TEXTBOX 25 165 175 183 Run Parameters 12 0.0 1 MONITOR 245 405 475 450 Switchability Maintenace Cost Per Time Step 1 - (1 - SWITCHABILITY-MAINTENANCE-COST) ^ (1 / (GENERATION-LENGTH * 3)) 10 1 11 TEXTBOX 20 440 215 466 The value above is the lifetime cost 11 0.0 1 @#$#@#$#@ ## WHAT IS IT? This project models aposematism (anti-predatory warning signal), predator learning and memory, and prey evolutionary dynamics. This model's main strength lies in the modelling of switchable aposematic signals. Unlike permanently colored animals, some prey animals can manifest warning signals only when attacked. This ability to switch signals can provide unique advantages, because the highly detectable signal can be hidden when not necessary. The model’s approach involves setting up cognitive and ecological characteristics of predators and determining the prey’s evolutionarily stable (“winning”) strategy(-ies), from among a user-defined set of prey signaling strategies in the specific ecological conditions defined by several types of costs of signaling. ## HOW IT WORKS The accompanying article (Song et al. submitted) explains the internal rules the prey / predator individuals follow in detail. The following paragraphs summarize the paper's Method section briefly, but it is strongly recommended to read the full paper instead of this information tab. The prey individuals can have three states, resting, approached, or attacked. In the 'approached' state the prey can give pre-attack signal to the predator. In the 'attacked' state the prey can give post-attack signal. The prey signal intensity is expressed at three levels, none, low and high. Therefore, the prey behavioral strategy is modeled as a sequence of three input-output pairs like the following: [(resting: None), (approached: Low), (attacked: High)]. The above sequence can be further summarized as three-character notation, "NLH." This gives the user the opportunity to define a variety of possible behavioral strategies in the RULES-LIST window. For example NNN indicates non-signaling prey, and LLL or HHH indicates a typical fixed aposematism at a lower or higher level of signal intensity, and NNH indicates post-attack displays of high intensity, and NHH indicates pre-attack displays of high intensity, etc. The behavioral strategy must have 3 letters, and otherwise the program will give an error. Predators have two attack opportunities, 'initial attack' and 'final attack.' The prey's pre-attack signal is given before the initial attack, and it can subsequently influence the probability of later attacks. Likewise, the post-attack signal is given after the initial attack and before the final attack. The post-attack signal can subsequently influence the probability of the final attack. The basic time unit of the simulation is the 'interaction frame.' Each frame includes three 'time steps.' The Step 1 is when the prey shows a pre-attack signal if a predator is present in the same grid. The Step 2 is when the initial attack occurs and when the post-attack signal is given. The Step 3 is when the final attack occurs. Predators have 'aversive memory' that increases after initial- or final attack events. If a predator has high level of aversive memory, it has lower probability of attacking the prey. The speed of memory buildup and the efficacy of retrieval are affected by a number of factors, described in Song et al (submitted). The predator's ‘decision’ to attack or not affects the 'survival chance' of the prey, which in turn determines the prey’s success of reproduction. In the reproduction stage, prey individuals differentially reproduce based on their survival chance and the existing generation dies out. At the same time, the predator population is refreshed by the adjustable variable 'predator turnover.' During the interaction, the prey may pay a variety of costs that lower its survival chance. First, there is a 'switching cost' that is paid every time the signal intensity changes. Second, there is a 'switchability maintenance cost' that is continuously being paid if the prey has the ability to change the signal intensity. Third, 'signal penalty' is a cost paid during the presentation of the signal. Finally, the 'initial attack damage' and the 'final attack damage' are costs that are applied when the predator performs respective actions. From the prey's viewpoint, the main benefit of a stronger signal is that, combined with the adjustable variable ‘learning speed’, it amplifies the buildup and retrieval of the predators’ aversive memory. The main drawback of a stronger signal is that it can betray the prey's position to predators. The 'basal detectability' variable governs how the prey detectability changes depending on the signal intensity. The detailed algorithms of the outlined model mechanics are available in the paper (Song et al. submitted). ## HOW TO USE IT The model interface has three buttons, 'Play/Pause,' 'One Frame Forward,' and 'Apply Parameters and Generate World.' For the first-time users, it is recommended to click the 'Apply Parameters and Generate World,' wait for the world generation and then click the 'Play/Pause' button. This will help the users to become familiar with the workings of the model under the default parameter settings. It would be necessary to accelerate the model speed to actually visualize the evolutionary process. The most important reporting interface is the 'Rules Histogram' plot. Relative abundance of each behavioral strategy is displayed here, and the strategies are sorted by the order specified in the RULES-LIST. In the model view, prey individuals are represented by 'butterfly' shapes, and the predators are depicted as yellow 'default' shapes. Depending on the signal intensity (none, low or high), the color of the prey changes from black to dark red to bright red. The rest of the interface elements are outlined below. Number of Rules monitor displays the number of behavioral strategies specified via RULES-LIST editing interface. Generation monitor displays the number of prey generations that have passed. Predators monitor displays the number of predators present. Preys monitor displays the number of prey present. Frames monitor displays the number of interaction frames that have passed. Average Aversion monitor displays the current average value of the aversive memory of predators. Time Step monitor displays the current time step of the frame, 1, 2, or 3. Predator Aversion histogram displays the current distribution of predator aversive memory. The label displayed next to each prey individual in the world view represents the behavioral strategy of that prey, according to the order listed in the RULES-LIST. PLOT-ON toggle button is used to suspend plot updating when computation speed is preferred over visualization. As the model currently has 19 parameters that can be adjusted by the sliders, users are encouraged to test them one by one. The three 'World Parameters' need re-generation of the model world to take effect, but the other 16 should immediately affect the model. WORLD-SIZE The size of the world. Theoretically no limits. The larger the world the slower is the program running speed, but the outcomes will have better reproducibility. PREDATOR-FREQUENCY Number of predators divided by the number of all patches. This may be viewed as a degree of saturation of the habitat with the predators, or as a proxy for density of predators. PREY-FREQUENCY Number of prey individuals divided by the number of all patches. This may be viewed as a degree of saturation of the habitat with the prey, or as a proxy for density of prey. Their relative density can play an important role in aposemtism evolution, as the encounter rate can determine whether the learning can be achieved with an acceptable risk(Sword 1999) GENERATION-LENGTH Number of interaction frames per prey generation. As the effect of GENERATION-LENGTH is generally proxied by LEARNING-SPEED (whether the predators can completely learn during the lifetime), it is advisable to use this variable as a mean of computational optimization only (giving more time vs. a larger world) BASAL-COGNITIVE-CUE Signal-independent cue from prey to predators. It corresponds to prey phenotypic traits, except the signaling, that affect the predator learning and predator memory retrieval. If BASAL-COGNITIVE-CUE is 1, the predator learning and retrieval are not affected by signal intensity at all. If BASAL-COGNITIVE-CUE is 0, the predator learning and retrieval are entirely dependent on the signal (neither learning nor retrieval can occur if there is no signal). Predators are shown to learn to avoid non-conspicuous defended prey, albeit at the slower speed (Kang et al. 2016). Therefore, it is important to model diverse predator-prey systems with different ‘basal’ learning speed using this variable. L-COLOR Signal intensity between 0 and 1 at the 'low' level signal. H-COLOR Signal intensity between 0 and 1 at the 'high' level signal. BASAL-DETECTABILITY The chance of prey being discovered when no signal is present. If BASAL-DETECTABILITY is 1, the prey is always discoverable regardless of the signal. If BASAL-DETECTABILITY is 0, the prey is invisible when no signal is given. This variable is analyzed in detail in the accompanying article (Song et al. submitted). Users might be interested in other discussions related to the detectability of non-signaling prey (Broom et al. 2010; Umbers and Mappes 2015; Willink et al. 2013). BAD-TASTE The strength of the aversive unconditional stimulus felt by the predators. Currently this single parameter controls two separate mechanics. First, it determines the learning-independent motivation drop after the initial attack. When BAD-TASTE is 0, the predator motivation would be unaffected unless some other effects are present. If BAD-TASTE is 1, the predator motivation would drop to zero after initial attack regardless of any other effects. Second, it affects the aversive memory acquisition. If BAD-TASTE is 0, the predator would not be able to learn any aversion. If BAD-TASTE is 1, the predator learning is faster (how fast it is would be determined by a number of other factors). PREDATOR-TURNOVER The portion of predator population that are replaced with naive individuals per each prey generation. This variable is analyzed in detail in the accompanying article (Song et al. submitted). Predator turnover is one of the most prominent mechanisms that can result in a mix of naïve and experienced/educated predators (Endler and Mappes 2004), which may lead to diverse effects in the evolution of aposematism. LEARNING-SPEED The main coefficient that largely determines the speed of aversive memory buildup. If LEARNING-SPEED is 0.0, no aversion learning can occur. If LEARNING-SPEED is 1.0, then a single experience with a prey of BAD-TASTE 1.0 and signal intensity 1.0 will lead to 1.0 increase in aversive memory. LEARNING-SPEED does not have an upper bound, and an arbitrarily high value of LEARNING-SPEED will enable arbitrarily fast aversive memory buildup. For the detail of the processes regarding aversive memory and its implication in the evolution of switchable aposematism, reading the accompanying article (Song et al. 2019) is recommended. There are also pertinent empirical (Kang et al. 2016) and theoretical (Puurtinen and Kaitala 2006; Speed 2001) discussions of this variable. SIGNAL-PENALTY The cost (drop in survival chance) unconditionally paid by the prey due to the signal intensity. This variable summarizes all types of signal cost except the detectability cost. If SIGNAL-PENALTY is 0.0, there is no inherent cost in high-intensity signal except that it can draw predators' attention. If SIGNAL-PENALTY is 1.0, displaying an intensity=1.0 signal will instantly drop its survival chance to zero. The accompanying article (Song et al. submitted) discusses this variable in more detail. The costs of signal other than detectability can have a variety of effects (Blount et al. 2009) on the evolution of aposematism, including interactions outside of this model’s scope. SWITCHING-COST The cost (drop in survival chance) paid by the prey whenever its signal intensity changes. If SWITCHING-COST is 0.0, there is no cost in signal switching. If SWITCHING-COST is 1, altering from intensity=0.0 to intensity=1.0 or vice versa will instantly drop its survival chance to zero. Along with the SWITCHABILITY-MAINTENANCE-COST below, this variable has been explored in the accompanying article (Song et al. submitted). A previous theory (Broom et al. 2010), while not directly related to switchable signals, provide a good perspective about the potential of such cost affecting aposematism evolution. SWITCHABILITY-MAINTENANCE-COST The cost (drop in survival chance) unconditionally paid by the prey if the prey has a potential to change signal intensity. If SWITCHABILITY-MAINTENANCE-COST is 0.0, prey that does not actually switch signals would pay no cost even if they have the ability to do so. If SWITCHABILITY-MAINTENANCE-COST is 1.0, prey that are capable of switching signals will suffer instant elimination of any survival chance, regardless whether such switching behavior actually occurred or not. Along with the SWITCHING-COST above, this variable has been explored in the accompanying article (Song et al. submitted). A previous theory (Broom et al. 2010), while not directly related to switchable signals, provide a good perspective about the potential of such costs to affect evolution of aposematism. INITIAL-ATTACK-DAMAGE The cost (drop in survival chance) paid by the prey each time a predator conducts 'initial attack (the attack before seeing post-attack signal)' on it. If INITIAL-ATTACK-DAMAGE is 0.0, there is no damage from the attack. If INITIAL-ATTACK-DAMAGE is 1.0, a single attack event eliminates all survival chance. The survival rate after being attacked has long been regarded as a key factor in aposematism evolution (Wiklund and Jarvi 1982). The difference of this variable from the FINAL-ATTACK-DAMAGE below can arise from predator response to mimicry (Gamberale-Stille and Guilford 2004). FINAL-ATTACK-DAMAGE The cost (drop in survival chance) paid by the prey each time a predator conducts 'final attack (the attack after seeing post-attack signal)' on it. If FINAL-ATTACK-DAMAGE is 0.0, there is no damage from the attack. If FINAL-ATTACK-DAMAGE is 1.0, a single attack event eliminates all survival chance. The survival rate after being attacked has long been regarded as a key factor in aposematism evolution (Wiklund and Jarvi 1982). The difference of this variable from the INITIAL-ATTACK-DAMAGE above can arise from predator response to mimicry (Gamberale-Stille and Guilford 2004). LEARNING-AID-EFFECT Facilitation of aversive memory buildup due to change in signal intensity. If LEARNING-AID-EFFECT is 0.0, switched signals and permanent signals with the same intensity have same effect on predator learning. If LEARNING-AID-EFFECT is 1.0, a switched signal that had undergone intensity jump of 1.0 would have twice as great an effect as the equivalent permanent signal. This value has no upper bound, and infinitely high value of LEARNING-AID-EFFECT will have infinite advantage to switched signals compared to permanent signals. The effect of learning facilitation by switchable aposematism has been empirically tested (Kang et al. 2016). STARTLE-EFFECT Drop of prey attractiveness (chance to decide to attack) due to switching of the signal. If STARTLE-EFFECT is 0.0, signal switching itself does not decrease the attack frequency. If STARTLE-EFFECT is 1.0, prey that has changed the signal intensity by 1.0 would lose all attractiveness to predators that have seen such change for the first time. Note that the effect of startle can be attenuated by habituation as specified by the HABITUATION-SPEED variable below. The startle display (deimatism) and the warning signal (aposematism) often share critical components or are known to simultaneously govern predator psychology (Bates and Fenton 1990; Schlenoff 1985). HABITUATION-SPEED Speed of loss of effective STARTLE-EFFECT. The effective STARTLE-EFFECT approaches zero as the predator accumulates the observations of prey signal switching. If HABITUATION-SPEED is 0.0, the effective STARTLE-EFFECT never changes from the value specified with the interface slider. If HABITUATION-SPEED is 1.0, a single experience of jump of signal intensity by 1.0 will remove all effective STARTLE-EFFECT for the rest of the predator's lifetime. Different systems have been shown to have different habituation characteristics (Bates and Fenton 1990; Olofsson et al. 2012) ## WHAT TO DO WITH IT This model is built in NetLogo 5.3.1, which features a systematic parameter-sweeping tool called BehaviorSpace (https://ccl.northwestern.edu/netlogo/docs/behaviorspace.html). In order to explore a wide range of model parameters, the user may need to set up an ‘experiment’ as per the procedures outlined in the web manual. The accompanying article (Song et al. submitted) is also centered on four BehaviorSpace experiments, which created the Figure 2A, 2B, 2C and the Supplementary Figure 1 of the paper, respectively. The user can use these BehaviorSpace experiments (via Tools->BehaviorSpace) as starting examples to design their own ones. ## CREDITS AND REFERENCES Bates DL, Fenton MB. 1990. Aposematism or Startle - Predators Learn Their Responses to the Defenses of Prey. Canadian Journal of Zoology-Revue Canadienne De Zoologie. 68(1): 49-52. Blount JD, Speed MP, Ruxton GD, Stephens PA. 2009. Warning displays may function as honest signals of toxicity. P Roy Soc B-Biol Sci. 276(1658): 871-877. Broom M, Higginson AD, Ruxton GD. 2010. Optimal investment across different aspects of anti-predator defences. J Theor Biol. 263(4): 579-586. Endler JA, Mappes J. 2004. Predator mixes and the conspicuousness of aposematic signals. Am Nat. 163(4): 532-547. Gamberale-Stille G, Guilford T. 2004. Automimicry destabilizes aposematism: predator sample-and-reject behaviour may provide a solution. P Roy Soc B-Biol Sci. 271(1557): 2621-2625. Kang C, Cho HJ, Lee SI, Jablonski PG. 2016. Post-attack Aposematic Display in Prey Facilitates Predator Avoidance Learning. Frontiers in Ecology and Evolution. 4. Olofsson M, Eriksson S, Jakobsson S, Wiklund C. 2012. Deimatic Display in the European Swallowtail Butterfly as a Secondary Defence against Attacks from Great Tits. Plos One. 7(10). Puurtinen M, Kaitala V. 2006. Conditions for the spread of conspicuous warning signals: A numerical model with novel insights. Evolution. 60(11): 2246-2256. Schlenoff DH. 1985. The Startle Responses of Blue Jays to Catocala (Lepidoptera, Noctuidae) Prey Models. Anim Behav. 33(Nov): 1057-1067. Speed MP. 2001. Can receiver psychology explain the evolution of aposematism? Anim Behav. 61: 205-216. Sword GA. 1999. Density-dependent warning coloration. Nature. 397(6716): 217-217. Umbers KDL, Mappes J. 2015. Postattack deimatic display in the mountain katydid, Acripeza reticulata. Anim Behav. 100: 68-73. Wiklund C, Jarvi T. 1982. Survival of Distasteful Insects after Being Attacked by Naive Birds - a Reappraisal of the Theory of Aposematic Coloration Evolving through Individual Selection. Evolution. 36(5): 998-1002. Willink B, Brenes-Mora E, Bolanos F, Prohl H. 2013. Not Everything Is Black and White: Color and Behavioral Variation Reveal a Continuum between Cryptic and Aposematic Strategies in a Polymorphic Poison Frog. Evolution. 67(10): 2783-2794. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 0 Rectangle -7500403 true true 151 225 180 285 Rectangle -7500403 true true 47 225 75 285 Rectangle -7500403 true true 15 75 210 225 Circle -7500403 true true 135 75 150 Circle -16777216 true false 165 76 116 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 5.3.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result setup go result @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 1 @#$#@#$#@