Silly Bug Game

Silly Bug Game preview image

1 collaborator

Default-person Israel Alderete (Author)

Tags

bug 

Tagged by Israel Alderete almost 4 years ago

game 

Tagged by Israel Alderete almost 4 years ago

game simulation 

Tagged by Israel Alderete almost 4 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 455 times • Downloaded 31 times • Run 0 times
Download the 'Silly Bug Game' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


If you have any concerns, contact me at ialderete@sodacharter.com

HOW TO PLAY!

GAME FUNCTIONS AND GAMEMODE 0: FREE FOR ALL

First, press Setup to create the map. Press it as many times as you want to get a color you like.

If you want, you can toggle decorative leaves.

The Blue player should start, by choosing what bugs they want with the bottom buttons, paying attention to their costs. After a bug is chosen, use the middle buttons (or respective keys), to place the bugs on their tiles. The tiles have labels to match the buttons.

When Blue is ready, press the "Hide Blue Bugs" button. Red shall do the same thing, and when they're ready, press "Hide Blue Bugs" again.

If any mistakes are made, Red can press "R Reset", or blue can press "B Reset".

Press Start and watch the bugs fight!

When you're ready to play again, press "Reset"

GAMEMODE 1: NEST DESTROYER

When switching to Gamemode 1, you'll have to reset the field, and then from there, Blue's nest will spawn. They place their nest, then press "Red's Nest", and let Red place their nest. From there, same instructions as in Free For All.

In Nest Destroyer, you have less of a budget, but if one of your bugs is defeated, it will be sent back to it's home nest to heal! If another bug dies while one is healing, the bug will be dead permanently. Destroy the enemy's nest to win!

GAMEMODE 2: ENERGY BUGS

Switch to Gamemode 2, reset after picking the amount of Energy Bugs you want with the "pointamt" slider. Place the Energy Bugs, and press "Red's Energy Bugs". Then, use your budgets to place your bugs.

When the game starts, your Energy Bugs will begin to generate energy. While you're playing, you can place bugs down! Though, this will work differently; choose the number where you want your bug, and THEN choose the bug. You cannot put bugs down on Special Spawnpoints.

Bugs will try and stand over the Energy Bugs. As they stand on the Energy Bugs, the timer on the Energy Bugs will go down, if they reach zero, they will die. The goal is to destroy all of the enemy's Energy Bugs. As their Energy Bugs die, they will generate less energy.

BUG OVERVIEW

BUGS

These are classic bugs, they target the nearest enemy bug and attack.

Cost: 1

Health: 4

Damage: 1

Speed: 1/3 Tile

BEES

Bees are fierce and fast fighters; doing massive damage. Every time they attack, though, they lose health!

Cost: 2

Health: 2

Damage: 4, 1 damage to self

Speed: 1 Tile

ANTS

Ants are bugs centered around teamwork, when they're together, they are nearly unstoppable!

Cost: 3

Health: 5

Damage: 1

Speed: 1/3 Tile

Special Ability- Queen's Squadron: Around other Ants, Ants will gain +0.5 attack damage. This ability stacks!

CATERPILLARS

Caterpillars are much like normal bugs, just weaker. Friendly Butterflies love to help them out, though!

Cost: 1

Health: 3

Damage: 1

Speed: 1/3 Tile

BUTTERFLIES

Butterflies have some good stats, and are good fighters; though, they prioritize healing friendly Caterpillars over battle.

Cost: 4

Health: 5

Damage: 1.5

Speed: 1/2 Tile

Special Ability- Species Preservation: Butterflies will fly to weakened Caterpillars, and heal them for 0.5 health every Tick.

MOTHS

Moths have always been overshadowed by the Butterflies, but not today. These dusty creatures target Butterflies over any other enemy bug!

Cost: 3

Health: 5

Damage: 1.5

Speed: 1/2 Tile

Special Ability- Dusty Death: If a Moth falls in battle, any enemies around it will be covered in dust. This dust cuts attack damage and speed in half!

SPIDERS

Spiders are powerful creatures with a poisonous bite. They attack the nearest enemy and trap the furthest in a web!

Cost: 6

Health: 6

Damage: 2.5 + 0.25/tick

Speed: 1/3 Tile

Special Ability- Web Shooter: Spiders have a chance to trap the furthest enemy from them in a web! This web will slow them down by 4 times! They can shoot multiple webs each match.

DRAGONFLY

Dragonflies are incredibly fast bugs, whose speed alone is enough to help motivate their team!

Cost: 3

Health: 4

Damage: 2

Speed: 2 Tiles

Special Ability- Wings of Influence: Other friendly bugs near the Dragonfly will have their speed doubled!

BEETLE

Beetles are absolute mountains of power. They begin slow, but the longer they charge, the harder they'll hit! The durable bugs inflict area damage.

Cost: 10

Health: 10

Damage: 0.25 + 0.25/tick

Speed: 0.25 + 0.25/tick

Special Ability- Tough Shell: Beetles are immune to most status debuffs: Poison, Dust, and even the slowing of webs!

VENOM SPITTER

Venom Spitters only like to attack weaker bugs, so they shoot poison at the nearest bug until that bug is poisoned! After that, they'll move forward and attack as usual.

Cost: 5

Health: 5.5

Damage: 1.5

Speed: 1/2 Tile

Special Ability- Venom Spit: What a surprise, the Venom Spitter spits venom! It'll poison the bugs it hits, it has a very long range.

GRASSHOPPER

Grasshoppers jump incredible distances to get to their enemies. Once they reach them, they'll attack as normal.

Cost: 3

Health: 5

Damage: 1.5

Speed: 1/3 Tile, or 3 Tiles when far from enemies

THORN BUG

Thorn Bugs are tiny creatures that do little damage. Worry not, though. Thorn Bugs return most of the damage they are dealt!

Cost: 3

Health: 3

Damage: 1

Speed: 1/3 Tile

Special Ability- Counterattack: Any time the Thorn Bug takes damage, the attacker takes 75% of that damage.

PRAYING MANTIS

The Mantis is a stealthy bug, who waits for the perfect time to strike with a powerful attack. It stays still near it's enemy, before launching quickly.

Cost: 8

Health: 6

Damage: 0.5 + 1/tick while it waits to strike it's enemy

Speed: 1/3 Tile

Special Ability- Bug Eat Bug: Whenever a Mantis gets a kill, it'll heal itself and teammates for the max health of the bug it killed!

PILL BUG

Pill Bugs are little guys that do little damage. But, they can give shields to their teammates.

Cost: 4

Health: 2

Damage: 1

Speed: 1/3 Tile

Special Ability- Shared Shell: Friendly bugs in a small radius around the Pill Bug will recieve a 50% shield.

CICADAS

Cicadas are loud bugs with a motivating noise, that causes their teammates to extend their own ability radius!

Cost: 5

Health: 5

Damage: 1.5

Speed: 1/2 Tile

Special Ability- War Cry: Friendly bugs with special abilities that are near Cicadas will have their own ability radius increased: This includes abilities like Queen's Squadron, Species Preservation, Dusty Death, Web Shooter, Wings of Influence, Venom Spit, Shared Shell, War Cry, Rage, Wind Down, Blinding Spit and even the area damage of Beetles!

WASPS

Wasps are aggresive bugs much like bees, who boost their teammates attack!

Cost: 5

Health: 3

Damage: 4

Speed: 1 Tile

Special Ability- Rage: Friendly bugs in a small radius around the Wasp will recieve a 1.5x damage multiplier! This works on other wasps!

BED BUGS

Bed Bugs enjoy their comfort, and that's how they feel all bugs should live.

Cost: 4

Health : 4

Damage: 1

Speed: 1/3 Tile

Special Ability- Wind Down: The Bed Bug calms it's faster friendly bugs down, making their speed match the Bed Bug. Faster bugs whose abilities would eventually be out of reach of the slower bugs will now keep their ability radius where others can reach!

WALKING STICKS

The Walking Stick is a special bug who sprays disorientating poisons in the face of it's enemies!

Cost: 5

Health : 4.5

Damage: 2

Speed: 1/2 Tile

Special Ability- Blinding Spit: The Walking Stick has a 1/15 chance to spit a venom at the enemy bug with the strongest damage, blinding them. They won't be able to target correctly or attack!

TARANTULA HAWKS

The Tarantula Hawk is a force to be reckoned with; it's one of the most venomous bugs in the world. And in game, this monster is no different.

Cost: 9

Health: 5

Damage: 4

Speed: 1 Tile

Special Ability- Ultimate Poison: The Tarantula Hawk's sting and bite are incredibly powerful. They poison the enemy AND paralyze them, and whoever is bit will permanently lose their support Special Ability! (See Cicada's description for abilities affected.)

SCREWWORM FLIES

Screwworm flies are disgusting bugs who have decided the best way to care for their young is to let it feed off the insides of it's enemies.

Cost: 7

Health: 4

Damage: 1.5

Speed: 1/2 Tile

Special Ability- Parasite: Whenever the Screwworm Fly attacks, the bug it hits becomes a host for the Screwworm's larvae. When that bug dies, the Larvae emerges!

Larvae Health: 1.5

Larvae Damage: 1

Larvae Speed: 1/3 Tile

Larvae Special Ability- Phase Two: After 20 movements from emerging, the Larvae will grow into another Screwworm Fly, starting the cycle again!

TERMITES

The Termite is well known for it's enjoyment of consuming wood, and does not mind a little snack on/of the battlefield, creating pitfalls on the map!

Cost: 4

Health: 4.5

Damage: 1

Speed: 1/3 Tile

Special Ability- Snack Break: Termites will eat the ground in front of them if there are enemy bugs on that ground. If these bugs don't avoid the ground, they'll fall through and die! Of course, only non-flying bugs are potential victims.

BUILDINGS

BUG'S NEST

The Bug's Nest spawns tiny baby bugs from it every ten ticks. It can spawn up to 5 bugs before being destroyed!

Resource Cost: 4

Health: 10

Health Decay: -2 Health/per 10 ticks

Bug's Health: 1

Bug's Damage: 1

Bug's Speed: 1/3 Tile

POLLEN FLOWER

The Pollen Flower produces a thick cloud of pollen that blinds any enemy bugs around it until they can escape!

Resource Cost: 6

Health: 8

Health Decay: -1 Health/per 10 ticks

Radius of Effect: 1.5 Tiles

BUG DECOY

Literally a decoy bug.

Resource Cost: 2

Health: 8

Health Decay: -1 Health/per 10 ticks

THE OLE HEALER

The Ole Healer is a retired bug who still wants to help the battle. They sacrifice their own health by healing closeby teammates.

Resource Cost: 4

Health: 10

Radius of Effect: 2 Tiles

Health Decay: -0.5 Health for every 0.5 Health healed.

THE CHEMICAL SWAPPER

The Chemical Swapper is what remains of an Ant Queen's abdomen, releasing chemicals that can switch enemy bugs to be friendly bugs!

Resource Cost: 6

Health: 5

Radius of Effect: 3 Tiles

SPECIAL TILES

NESTS

Nests are one-time tiles, that when stepped on by a friendly bug, will cause that bug to hatch a baby! The Baby Bugs have only a quarter of the health of their parents, but share the same damage!

ANT LION'S TRAP

Ant Lions watch and wait for a bug to land on their tile. If they do, the Ant Lion grabs the bug and pulls it underground! Flying bugs are unaffected!

SPECIAL SPAWN TILE

A simple tile that allows you to use the "S" key to spawn a bug on it! Works just like the default spawn tiles, just anywhere on the map.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;Silly Bug Game
;Israel Alderete
;Start Date: 8/19/21
;Most Recent Update: 10/22/21

globals [mapgentype colora colorb rbudget bbudget rresources bresources rgen bgen]
patches-own [sspawntime center? colormemory blueweb redweb rednest bluenest antlionn antlionsp rs1spawn rs2spawn rs3spawn bs1spawn bs2spawn bs3spawn bselected?? rselected?? bselect rselect]
turtles-own [bx by building? switching? spawntime speed damage dmemory health selected? poisoned? dusted? speedmemory ramming facememory labelmemory rival blindtime paralyzetime maxhealth thorns shield flying? effectiverange ermemory hitradius nestnumber recovering? rhost? bhost?]
breed [lleaves lleaf]
;=========Gamemode Breeds=========
breed [nests nest];finished
breed [points point]
;=========Building Breeds==========
breed [bugs_nests bugs_nest];finished
breed [health_givers health_giver];finished
breed [bug_decoys bug_decoy];finished
breed [chemical_swaps chemical_swap];finished
breed [pollen_flowers pollen_flower];finished
;===========Bug Breeds==============
breed [ants ant];finished
breed [bees bee];finished
breed [spiders spider];finished
breed [butterflies butterfly];finished
breed [moths moth];finished
breed [bugs bug];finished
breed [caterpillars caterpillar];finished
breed [dragonflies dragonfly];finished
breed [beetles beetle];finished
breed [venomspitters venomspitter] breed [poisons poison];finished
breed [grasshoppers grasshopper];finished
breed [thornbugs thornbug];finished
breed [mantises mantis];finished
breed [pillbugs pillbug];finished
breed [antlions antlion];finished
breed [cicadas cicada];finished
breed [wasps wasp];finished
breed [bedbugs bedbug];finished
breed [stickbug stickbugs] breed [blinds blind];finished
breed [tarantulahawks tarantulahawk];finished'
breed [screwworms screwworm] breed [larvaes larvae];finished
breed [termites termite];finished
;============Other Breeds=============
breed [leaves leaf]

to setup
  __change-topology true true
  ca
  set mapgentype 1 + (random 7)
  set colora 30.5 + ((random 7) / 2)
  set colorb (colora + 2)
  if mapgentype = 1
  [
  create-turtles 1
  [
    setxy 0 0
    set heading 90
    forward 2
    repeat 8
    [
    repeat 3
    [
    repeat 6
    [
      repeat 3
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
      repeat 3
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
    repeat 3
    [
    repeat 6
    [
      repeat 3
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
      repeat 3
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
  ]
  ]
  ask turtles [die]
  ]
  if mapgentype = 2
  [
  create-turtles 48
  [
    setxy (0) (0 - who)
    set heading 90
    repeat 6
    [
      repeat 3
      [
        ask patch-here [set pcolor colora]
        forward 1
      ]
      repeat 3
      [
        ask patch-here [set pcolor colorb]
        forward 1
      ]
    ]
  ]
  ask turtles [die]
  ]
  if mapgentype = 3
  [
  create-turtles 48
  [
    setxy (0) (0 - who)
    set heading 90
    repeat 3
    [
      repeat 6
      [
        ask patch-here [set pcolor colora]
        forward 1
      ]
      repeat 6
      [
        ask patch-here [set pcolor colorb]
        forward 1
      ]
    ]
  ]
  ask turtles [die]
  ]
  if mapgentype = 4
  [
  create-turtles 48
  [
    setxy (0) (0 - who)
    set heading 90
    repeat 2
    [
      repeat 9
      [
        ask patch-here [set pcolor colora]
        forward 1
      ]
      repeat 9
      [
        ask patch-here [set pcolor colorb]
        forward 1
      ]
    ]
  ]
  ask turtles [die]
  ]
  if mapgentype = 5
  [
  create-turtles 1
  [
    setxy 0 0
    set heading 90
    forward 8
    repeat 8
    [
    repeat 3
    [
    repeat 2
    [
      repeat 9
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
      repeat 9
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
    repeat 3
    [
    repeat 2
    [
      repeat 9
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
      repeat 9
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
  ]
  ]
  ask turtles [die]
  ]
if mapgentype = 6
  [
  create-turtles 1
  [
    setxy 0 0
    set heading 90
    forward -1
    repeat 8
    [
    repeat 3
    [
    repeat 1
    [
      repeat 36
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
repeat 3
    [
    repeat 1
    [
      repeat 36
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
  ]
  ]
  ask turtles [die]
  ]
if mapgentype = 7
  [
  create-turtles 1
  [
    setxy 0 0
    set heading 90
    forward -1
    repeat 2
    [
    repeat 12
    [
    repeat 1
    [
      repeat 36
      [
        forward 1
        ask patch-here
        [
          set pcolor colora
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
repeat 12
    [
    repeat 1
    [
      repeat 36
      [
        forward 1
        ask patch-here
        [
          set pcolor colorb
        ]
      ]
    ]
    right 90
    forward 1
    left 90
    ]
  ]
  ]
  ask turtles [die]
  ]
  center
  ask patches
  [
    set colormemory [pcolor] of self
    set blueweb false
    set redweb false
    set rednest false
    set bluenest false
    set antlionn false
    set antlionsp false
  ]
  if Nests? = true
  [
  symmetrytest
  ]
  if AntLions? = true
  [
    antlionsnest
  ]
  if SpecialSpawn? = true
  [
    specialspawn
  ]
  if leaves? = true
  [
    create-leaves 10 * 1 + (random 3)
    [
    set shape "leaf 2"
    set size 15 + (random 6)
    set color (colorb + 20 + ((random 2) * 10))
    set health 1
    while [any? other leaves-on patch-here]
    [
    setxy min-pxcor (random-pycor * 3)
    ]
    set heading 45 + (random 135)
    ]
    ask n-of ((count leaves) / 2) leaves
    [
    setxy max-pxcor (random-pycor * 3)
    while [any? other leaves-on patch-here]
    [
    setxy max-pxcor (random-pycor * 3)
    ]
    set heading 225 + (random 135)
    ]
    ask leaves [set hidden? true]
    if random 20 = 1
    [
      ask leaves
      [
      set color (colora - 10 + (random 3))
      set shape "leaf"
      ]
      create-lleaves 25 + (random 6)
      [
      set shape one-of ["leaf 2" "leaf"]
      set color ((colora - 10 + (random 3)) - 1)
      set size 1.5 + (0.5 * (random 3))
      set health 1
      setxy random-pxcor random-pycor
      set hidden? true
      ]
    ]
  ]
  __change-topology false false
  set rbudget 40 - (gamemode * 10)
  if gamemode = 2
  [
    set rbudget 15
  ]
  set bbudget 40 - (gamemode * 10)
  if gamemode = 2
  [
    set bbudget 15
  ]
  set rresources 8 - (gamemode * 2)
  set bresources 8 - (gamemode * 2)
  ask patch 1 -1 [set plabel 1 set rselected?? true set rselect true]
  ask patch 4 -1 [set plabel 2 set rselected?? true set rselect true]
  ask patch 7 -1 [set plabel 3 set rselected?? true set rselect true]
  ask patch 10 -1 [set plabel 4 set rselected?? true set rselect true]
  ask patch 13 -1 [set plabel 5 set rselected?? true set rselect true]
  ask patch 16 -1 [set plabel 6 set rselected?? true set rselect true]
  ask patch 19 -1 [set plabel 7 set rselected?? true set rselect true]
  ask patch 22 -1 [set plabel 8 set rselected?? true set rselect true]
  ask patch 25 -1 [set plabel 9 set rselected?? true set rselect true]
  ask patch 28 -1 [set plabel 0 set rselected?? true set rselect true]
  ask patch 31 -1 [set plabel "-" set rselected?? true set rselect true]
  ask patch 34 -1 [set plabel "=" set rselected?? true set rselect true]
  ask patch 1 -46 [set plabel 1 set bselected?? true set bselect true]
  ask patch 4 -46 [set plabel 2 set bselected?? true set bselect true]
  ask patch 7 -46 [set plabel 3 set bselected?? true set bselect true]
  ask patch 10 -46 [set plabel 4 set bselected?? true set bselect true]
  ask patch 13 -46 [set plabel 5 set bselected?? true set bselect true]
  ask patch 16 -46 [set plabel 6 set bselected?? true set bselect true]
  ask patch 19 -46 [set plabel 7 set bselected?? true set bselect true]
  ask patch 22 -46 [set plabel 8 set bselected?? true set bselect true]
  ask patch 25 -46 [set plabel 9 set bselected?? true set bselect true]
  ask patch 28 -46 [set plabel 0 set bselected?? true set bselect true]
  ask patch 31 -46 [set plabel "-" set bselected?? true set bselect true]
  ask patch 34 -46 [set plabel "=" set bselected?? true set bselect true]
  ask patch 1 -4 [set plabel "!" set rselected?? true set rselect true]
  ask patch 4 -4 [set plabel "@" set rselected?? true set rselect true]
  ask patch 7 -4 [set plabel "#" set rselected?? true set rselect true]
  ask patch 10 -4 [set plabel "$" set rselected?? true set rselect true]
  ask patch 13 -4 [set plabel "%" set rselected?? true set rselect true]
  ask patch 16 -4 [set plabel "^" set rselected?? true set rselect true]
  ask patch 19 -4 [set plabel "&" set rselected?? true set rselect true]
  ask patch 22 -4 [set plabel "*" set rselected?? true set rselect true]
  ask patch 25 -4 [set plabel "(" set rselected?? true set rselect true]
  ask patch 28 -4 [set plabel ")" set rselected?? true set rselect true]
  ask patch 31 -4 [set plabel "_" set rselected?? true set rselect true]
  ask patch 34 -4 [set plabel "+" set rselected?? true set rselect true]
  ask patch 1 -43 [set plabel "!" set bselected?? true set bselect true]
  ask patch 4 -43 [set plabel "@" set bselected?? true set bselect true]
  ask patch 7 -43 [set plabel "#" set bselected?? true set bselect true]
  ask patch 10 -43 [set plabel "$" set bselected?? true set bselect true]
  ask patch 13 -43 [set plabel "%" set bselected?? true set bselect true]
  ask patch 16 -43 [set plabel "^" set bselected?? true set bselect true]
  ask patch 19 -43 [set plabel "&" set bselected?? true set bselect true]
  ask patch 22 -43 [set plabel "*" set bselected?? true set bselect true]
  ask patch 25 -43 [set plabel "(" set bselected?? true set bselect true]
  ask patch 28 -43 [set plabel ")" set bselected?? true set bselect true]
  ask patch 31 -43 [set plabel "_" set bselected?? true set bselect true]
  ask patch 34 -43 [set plabel "+" set bselected?? true set bselect true]
  if gamemode = 2
  [
    ask patches
    [
      set rselected?? false
      set bselected?? false
    ]
    set rgen 12
    set bgen 12
  ]
  reset-ticks

  if gamemode = 1
  [
    create-nests 1
    [
      setxy 18 -24
      set shape "nest"
      set nestnumber 1
      set color blue
      set size 6
      set health 50
      set selected? true
      set shield 1
    ]
    next_nest
  ]
  if gamemode = 2
  [
    create-points pointamt
    [
      setxy 18 -24
      set shape "energybug"
      set color blue
      set size 2
      set health 1
      set shield 1
      set spawntime (96 / pointamt)
      set selected? true
    ]
  ]
  tick
end 

to next_nest
  if count nests with [selected? = false] = 1
  [
    create-nests 1
    [
      setxy 18 -24
      set shape "nest"
      set nestnumber 2
      set color red
      set size 6
      set health 50
      set selected? true
      set shield 1
    ]
  ]
end 

to next_bugs
  if count points with [selected? = false] = pointamt
  [
    create-points pointamt
    [
      setxy 18 -24
      set shape "energybug"
      set color red
      set size 2
      set health 1
      set shield 1
      set spawntime ([spawntime] of one-of points with [color = blue])
      set selected? true
    ]
  ]
end 

to center
  let y -1
  repeat 16
  [
    create-turtles 1
    [
      setxy 1 y
      repeat 12
      [
        set heading 90
        forward 3
        ask patch-here [set center? true]
      ]
      set y (y - 3)
    ]
  ]
  ask turtles [die]
end 

to symmetrytest
  repeat Special_Tile_Amount
  [
  ask patch (1 + (3 * (random 12))) (-7 - (3 * (random 6)))
    [
      set pcolor 12
      sprout 1
      [
      setxy (max-pxcor - ([pxcor] of patch-here)) (max-pycor - (([pycor] of patch-here) - 1))
      ask patch-here
      [
        set pcolor 102
      ]
      die
      ]
    ]
  ]
  ask patches with [pcolor != colormemory]
  [
    ask patches in-radius 1.5
    [
      set pcolor [pcolor] of myself

    ]
    ask patches with [pcolor = 12]
    [
      set rednest true
    ]
    ask patches with [pcolor = 102]
    [
      set bluenest true
    ]
  ]
end 

to antlionsnest
  repeat Special_Tile_Amount
  [
    ask patch (1 + (3 * (random 12))) (-7 - (3 * (random 6)))
    [
      set pcolor 47.5
      set antlionsp true
      sprout-antlions 1
    [
      set shape "ant"
      set size 4
      set health 1
      set color black
    ]
      sprout 1
      [
      setxy (max-pxcor - ([pxcor] of patch-here)) (max-pycor - (([pycor] of patch-here) - 1))
      ask patch-here
      [
        set pcolor 47.5
        set antlionsp true
        sprout-antlions 1
        [
          set shape "ant"
          set size 4
          set health 1
          set color black
        ]
      ]
      die
      ]
    ]
  ]
ask patches with [pcolor = 47.5]
  [
    ask patches in-radius 1.5
    [
      set pcolor [pcolor] of myself
      set antlionn true
    ]
  ]
end 

to specialspawn
  ask patch (1 + (3 * (random 12))) (-16 - (3 * (random 3)))
    [
      set plabel "S1"
      set rs1spawn true
      set plabel-color white
      sprout 1
      [
      setxy (max-pxcor - ([pxcor] of patch-here)) (max-pycor - (([pycor] of patch-here) - 1))
      ask patch-here
      [
        set plabel "S1"
        set bs1spawn true
        set plabel-color white
      ]
      die
      ]
    ]
  if Special_Tile_Amount >= 2
  [
      ask patch (1 + (3 * (random 12))) (-16 - (3 * (random 3)))
    [
      set plabel "S2"
      set rs2spawn true
      set plabel-color white
      sprout 1
      [
      setxy (max-pxcor - ([pxcor] of patch-here)) (max-pycor - (([pycor] of patch-here) - 1))
      ask patch-here
      [
        set plabel "S2"
        set bs2spawn true
        set plabel-color white
      ]
      die
      ]
    ]
  ]
  if Special_Tile_Amount = 3
  [
  ask patch (1 + (3 * (random 12))) (-16 - (3 * (random 3)))
    [
      set plabel "S3"
      set rs3spawn true
      set plabel-color white
      sprout 1
      [
      setxy (max-pxcor - ([pxcor] of patch-here)) (max-pycor - (([pycor] of patch-here) - 1))
      ask patch-here
      [
        set plabel "S3"
        set bs3spawn true
        set plabel-color white
      ]
      die
      ]
    ]
  ]
end 
;===================================================================
;===========================BUILDINGS===============================
;===================================================================

to rbugs_nest
  if rresources > 3 and (ticks = 1)
  [
    create-bugs_nests 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 10
      set shape "nest"
      set size 5
      setxy 18 -24
      set color red
      set rresources (rresources - 4)
    ]
  ]
end 

to bbugs_nest
  if bresources > 3 and (ticks = 1)
  [
    create-bugs_nests 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 10
      set shape "nest"
      set size 5
      setxy 18 -24
      set color blue
      set bresources (bresources - 4)
    ]
  ]
end 

to rpollen_flowers
  if rresources > 5 and (ticks = 1)
  [
    create-pollen_flowers 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 8
      set shape "flower"
      set size 5
      setxy 18 -24
      set color red
      set rresources (rresources - 6)
    ]
  ]
end 

to bpollen_flowers
  if bresources > 5 and (ticks = 1)
  [
    create-pollen_flowers 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 8
      set shape "flower"
      set size 5
      setxy 18 -24
      set color blue
      set bresources (bresources - 6)
    ]
  ]
end 

to bbug_decoys
  if bresources > 1 and (ticks = 1)
  [
    create-bug_decoys 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 8
      set shape "bugdecoy"
      set size 5
      setxy 18 -24
      set color blue
      set bresources (bresources - 2)
    ]
  ]
end 

to rbug_decoys
  if rresources > 1 and (ticks = 1)
  [
    create-bug_decoys 1
    [
      set building? true
      set selected? true
      set spawntime 10
      set shield 1
      set health 8
      set shape "bugdecoy"
      set size 5
      setxy 18 -24
      set color red
      set rresources (rresources - 2)
    ]
  ]
end 

to bhealth_givers
  if bresources > 3 and (ticks = 1)
  [
    create-health_givers 1
    [
      set building? true
      set selected? true
      set shield 1
      set health 15
      set shape "healthgiver"
      set size 5
      setxy 18 -24
      set color blue
      set bresources (bresources - 4)
    ]
  ]
end 

to rhealth_givers
  if rresources > 3 and (ticks = 1)
  [
    create-health_givers 1
    [
      set building? true
      set selected? true
      set shield 1
      set health 15
      set shape "healthgiver"
      set size 5
      setxy 18 -24
      set color red
      set rresources (rresources - 4)
    ]
  ]
end 

to bchemical_swaps
  if bresources > 5 and (ticks = 1)
  [
    create-chemical_swaps 1
    [
      set building? true
      set selected? true
      set shield 1
      set health 5
      set shape "chemicalswap"
      set size 5
      setxy 18 -24
      set color blue
      set bresources (bresources - 6)
    ]
  ]
end 

to rchemical_swaps
    if rresources > 5 and (ticks = 1)
  [
    create-chemical_swaps 1
    [
      set building? true
      set selected? true
      set shield 1
      set health 5
      set shape "chemicalswap"
      set size 5
      setxy 18 -24
      set color red
      set rresources (rresources - 6)
    ]
  ]
end 
;===================================================================
;==============================BUGS=================================
;===================================================================

to rbugstuff
  if rbudget > 0
  [
    create-bugs 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 1)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 1) die]
      ]
    ]
  ]
end 

to bbugstuff
  if bbudget > 0
  [
    create-bugs 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 1)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 1) die]
      ]
    ]
  ]
end 

to rbeestuff
  if rbudget > 1
  [
    create-bees 1
    [
      set shield 1
      set health 2
      set maxhealth health
      set speed 3
      set speedmemory 3
      set damage 4
      set dmemory damage
      set shape "bee 2"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 2)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 2) die]
      ]
    ]
  ]
end 

to bbeestuff
  if bbudget > 1
  [
    create-bees 1
    [
      set shield 1
      set health 2
      set maxhealth health
      set speed 3
      set speedmemory 3
      set damage 4
      set dmemory damage
      set shape "bee 2"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 2)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 2) die]
      ]
    ]
  ]
end 

to rantstuff
  if rbudget > 2
  [
    create-ants 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "ant 2"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      set effectiverange 5
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 3) die]
      ]
    ]
  ]
end 

to bantstuff
    if bbudget > 2
  [
    create-ants 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "ant 2"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      set effectiverange 5
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 3) die]
      ]
    ]
  ]
end 

to rcaterpillars
  if rbudget > 0
  [
    create-caterpillars 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "caterpillar"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 1)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 1) die]
      ]
    ]
  ]
end 

to bcaterpillars
    if bbudget > 0
  [
    create-caterpillars 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "caterpillar"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 1)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 1) die]
      ]
    ]
  ]
end 

to rbutterflies
  if rbudget > 3
  [
    create-butterflies 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "butterfly"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 4)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 4) die]
      ]
    ]
  ]
end 

to bbutterflies
  if bbudget > 3
  [
    create-butterflies 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "butterfly"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 4)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 4) die]
      ]
    ]
  ]
end 

to bspiders
  if bbudget > 5
  [
    create-spiders 1
    [
      set shield 1
      set health 5.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 2.5
      set dmemory damage
      set shape "spider"
      set size 3.5
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 6)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 6) die]
      ]
    ]
  ]
end 

to rspiders
  if rbudget > 5
  [
    create-spiders 1
    [
      set shield 1
      set health 5.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 2.5
      set dmemory damage
      set shape "spider"
      set size 3.5
      setxy 18 -24
      set color red
      set rbudget (rbudget - 6)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 6) die]
      ]
    ]
  ]
end 

to bmoths
    if bbudget > 2
  [
    create-moths 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "butterfly 2"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 3) die]
      ]
    ]
  ]
end 

to rmoths
  if rbudget > 2
  [
    create-moths 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "butterfly 2"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 3) die]
      ]
    ]
  ]
end 

to bdragonflies
  if bbudget > 2
  [
    create-dragonflies 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 6
      set speedmemory 6
      set damage 2
      set dmemory damage
      set shape "dragonfly"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 6
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 3) die]
      ]
    ]
  ]
end 

to rdragonflies
  if rbudget > 2
  [
    create-dragonflies 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 6
      set speedmemory 6
      set damage 2
      set dmemory damage
      set shape "dragonfly"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 6
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 3) die]
      ]
    ]
  ]
end 

to bbeetles
  if bbudget > 9
  [
    create-beetles 1
    [
      set shield 1
      set health 10
      set maxhealth health
      set speed 0.25
      set speedmemory 0.5
      set damage 0.25
      set dmemory damage
      set shape "beetle"
      set size 4
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 10)
      set selected? true
      set labelmemory white
      set effectiverange 2
      set ermemory 2
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 10) die]
      ]
    ]
  ]
end 

to rbeetles
  if rbudget > 9
  [
    create-beetles 1
    [
      set shield 1
      set health 10
      set maxhealth health
      set speed 0.25
      set speedmemory 0.25
      set damage 0.25
      set dmemory damage
      set shape "beetle"
      set size 4
      setxy 18 -24
      set color red
      set rbudget (rbudget - 10)
      set selected? true
      set labelmemory white
      set effectiverange 2
      set ermemory 2
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 10) die]
      ]
    ]
  ]
end 

to bvenomspitters
  if bbudget > 4
  [
    create-venomspitters 1
    [
      set shield 1
      set health 5.5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "venomspitter"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory 1.5
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 6) die]
      ]
    ]
  ]
end 

to rvenomspitters
  if rbudget > 4
  [
    create-venomspitters 1
    [
      set shield 1
      set health 5.5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "venomspitter"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory 1.5
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 6) die]
      ]
    ]
  ]
end 

to bgrasshoppers
    if bbudget > 2
  [
    create-grasshoppers 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1.5
      set dmemory damage
      set shape "grasshopper"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 3) die]
      ]
    ]
  ]
end 

to rgrasshoppers
    if rbudget > 2
  [
    create-grasshoppers 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1.5
      set dmemory damage
      set shape "grasshopper"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 3) die]
      ]
    ]
  ]
end 

to bthornbugs
      if bbudget > 2
  [
    create-thornbugs 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set thorns true
      set shape "thornbug"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 2) die]
      ]
    ]
  ]
end 

to rthornbugs
      if rbudget > 2
  [
    create-thornbugs 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set thorns true
      set shape "thornbug"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 2) die]
      ]
    ]
  ]
end 

to bmantis
      if bbudget > 7
  [
    create-mantises 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 2
      set speedmemory 2
      set damage 0.5
      set dmemory damage
      set shape "mantis"
      set size 4
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 8)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 8) die]
      ]
    ]
  ]
end 

to rmantis
      if rbudget > 7
  [
    create-mantises 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 2
      set speedmemory 2
      set damage 0.5
      set dmemory damage
      set shape "mantis"
      set size 4
      setxy 18 -24
      set color red
      set rbudget (rbudget - 8)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 8) die]
      ]
    ]
  ]
end 

to bpillbug
    if bbudget > 3
  [
    create-pillbugs 1
    [
      set shield 1
      set health 2
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "pillbug"
      set size 2.5
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 4)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 4) die]
      ]
    ]
  ]
end 

to rpillbug
    if rbudget > 3
  [
    create-pillbugs 1
    [
      set shield 1
      set health 2
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "pillbug"
      set size 2.5
      setxy 18 -24
      set color red
      set rbudget (rbudget - 4)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 4) die]
      ]
    ]
  ]
end 

to bcicada
    if bbudget > 4
  [
    create-cicadas 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 2
      set dmemory damage
      set shape "cicada"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 5) die]
      ]
    ]
  ]
end 

to rcicada
    if rbudget > 4
  [
    create-cicadas 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 2
      set dmemory damage
      set shape "cicada"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 5) die]
      ]
    ]
  ]
end 

to bwasp
  if bbudget > 4
  [
    create-wasps 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 3
      set speedmemory 3
      set damage 4
      set dmemory damage
      set shape "wasp"
      set size 3
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 5)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 2
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 5) die]
      ]
    ]
  ]
end 

to rwasp
  if rbudget > 4
  [
    create-wasps 1
    [
      set shield 1
      set health 3
      set maxhealth health
      set speed 3
      set speedmemory 3
      set damage 4
      set dmemory damage
      set shape "wasp"
      set size 3
      setxy 18 -24
      set color red
      set rbudget (rbudget - 5)
      set selected? true
      set labelmemory white
      set flying? true
      set effectiverange 2
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 5) die]
      ]
    ]
  ]
end 

to bbedbug
  if bbudget > 2
  [
    create-bedbugs 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bedbug"
      set size 2
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 3)
      set selected? true
      set labelmemory white
      set flying? false
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 3) die]
      ]
    ]
  ]
end 

to rbedbug
  if rbudget > 2
  [
    create-bedbugs 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bedbug"
      set size 2
      setxy 18 -24
      set color red
      set rbudget (rbudget - 3)
      set selected? true
      set labelmemory white
      set flying? false
      set effectiverange 3
      set ermemory effectiverange
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 3) die]
      ]
    ]
  ]
end 

to bstickbug
  if bbudget > 4
  [
    create-stickbug 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 2
      set dmemory damage
      set shape "walkingstick"
      set size 3.5
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory 1.5
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 5) die]
      ]
    ]
  ]
end 

to rstickbug
  if rbudget > 4
  [
    create-stickbug 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 2
      set dmemory damage
      set shape "walkingstick"
      set size 3.5
      setxy 18 -24
      set color red
      set rbudget (rbudget - 5)
      set selected? true
      set labelmemory white
      set effectiverange 1.5
      set ermemory 1.5
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 5) die]
      ]
    ]
  ]
end 

to btarantulahawk
  if bbudget > 8
  [
    create-tarantulahawks 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 4
      set speedmemory 4
      set damage 4
      set dmemory damage
      set shape "tarantulahawk"
      set size 4
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 9)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 9) die]
      ]
    ]
  ]
end 

to rtarantulahawk
  if rbudget > 8
  [
    create-tarantulahawks 1
    [
      set shield 1
      set health 5
      set maxhealth health
      set speed 4
      set speedmemory 4
      set damage 4
      set dmemory damage
      set shape "tarantulahawk"
      set size 4
      setxy 18 -24
      set color red
      set rbudget (rbudget - 9)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 9) die]
      ]
    ]
  ]
end 

to bscrewworms
  if bbudget > 6
  [
    create-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 7)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 7) die]
      ]
    ]
  ]
end 

to rscrewworms
  if rbudget > 6
  [
    create-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      setxy 18 -24
      set color red
      set rbudget (rbudget - 7)
      set selected? true
      set labelmemory white
      set flying? true
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [rselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [rselected?? = true]) ([pycor] of one-of patches with [rselected?? = true]) set selected? false ask patch-here [set rselected?? false]] [set rbudget (rbudget + 7) die]
      ]
    ]
  ]
end 

to btermites
  if bbudget > 3
  [
    create-termites 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "termite"
      set size 2.5
      setxy 18 -24
      set color blue
      set bbudget (bbudget - 4)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 7) die]
      ]
    ]
  ]
end 

to rtermites
  if rbudget > 3
  [
    create-termites 1
    [
      set shield 1
      set health 4.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "termite"
      set size 2.5
      setxy 18 -24
      set color red
      set rbudget (rbudget - 4)
      set selected? true
      set labelmemory white
      if gamemode = 2 and (ticks != 1)
      [
        ifelse (count patches with [bselected?? = true]) = 1 [setxy ([pxcor] of one-of patches with [bselected?? = true]) ([pycor] of one-of patches with [bselected?? = true]) set selected? false ask patch-here [set bselected?? false]] [set bbudget (bbudget + 7) die]
      ]
    ]
  ]
end 
;===========================================================================================

to start
if ticks = 1
[
ask turtles with [color = blue]
[
set heading 0
]
ask turtles with [color = red]
[
set heading 180
]
]
every 0.5
  [
    ask leaves [set hidden? false]
    ask lleaves [set hidden? false]
    ask turtles with [building? != true and shape != "energybug" and shape != "leaf 2" and shape != "leaf"]
    [
      set label precision health 2
    ]
    ask patches
    [
      if redweb = true
      [
        set pcolor 19.5
      ]
      if blueweb = true
      [
        set pcolor 109
      ]
      if redweb = true and blueweb = true
      [
        set pcolor 118.5
      ]
    ]
    ask patches with [redweb = true or blueweb = true]
    [
    set sspawntime (sspawntime - 1)
    if sspawntime <= 0
    [
    set redweb false
    set blueweb false
    set pcolor colormemory
    ]
    ]
;Building Stuff--------------------------------------------------------------------
  ask turtles with [building? = true and shape != "chemicalswap"]
  [
    set label health
  ]
  ask turtles with [shape = "chemicalswap"]
  [
    set label spawntime
  ]
  ask turtles with [building? != true and (not any? (pollen_flowers with [shade-of? color ([color] of self)]) in-radius 6)]
  [
    ask my-links with [shape = "pollon"]
    [
      die
    ]
  ]
  ask turtles with [building? != true and (not any? (health_givers with [shade-of? color ([color] of self)]) in-radius 6)]
  [
    ask my-links with [shape = "healing"]
    [
      die
    ]
  ]
 ;Special Tiles----------------------------------------------------------------------
    ask turtles with [flying? = 0]
    [
      set flying? false
    ]
    ask antlions
    [
      face min-one-of other turtles [distance myself]
    ]
    ask turtles with [shape != "ant"]
    [
      if [color] of self = red and [pcolor] of patch-here = 12
      [
        hatch 1
        [
        set size (size / 2)
        set maxhealth (maxhealth / 4)
        set health maxhealth
        right 90
        forward 3
        left 90
        set poisoned? false
        set label ""
        ]
        ask  min-one-of patches with [rednest = true and ((count patches with [rednest = true] in-radius 1.5) = 9)] [distance myself]
        [
          ask patches in-radius 1.5
          [
          set pcolor colormemory
          ]
        ]
      ]
      if [color] of self = blue and [pcolor] of patch-here = 102
      [
        hatch 1
        [
        set size (size / 2)
        set maxhealth (maxhealth / 4)
        set health maxhealth
        right 90
        forward 3
        left 90
        set poisoned? false
        set label ""
        ]
        ask  min-one-of patches with [bluenest = true and ((count patches with [bluenest = true] in-radius 1.5) = 9)] [distance myself]
        [
          ask patches in-radius 1.5
          [
          set pcolor colormemory
          ]
        ]
      ]
      if any? antlions in-radius 1.5 and [flying?] of self = false
      [
        ask patches in-radius 3 with [pcolor = 47.5]
        [
          set pcolor colormemory
        ]
        ask antlions in-radius 1.5
        [
          die
        ]
        die
      ]
 ;Status Effects----------------------------------------------------------------------
      if poisoned? = true and [shape] of self != "beetle" [set health (health - 0.25) set label-color green set labelmemory green]
      ;Cicada Ability==============================================
      ifelse count other cicadas with [color = [color] of myself] > 0
      [
      ifelse any? other cicadas with [color = ([color] of myself)] in-radius ([effectiverange] of min-one-of other cicadas [distance myself])
      [
        set effectiverange (ermemory * 2)
      ]
      [
        set effectiverange ermemory
      ]
      ]
      [
        set effectiverange ermemory
      ]
      ;Pillbug Ability=============================================
      ifelse count other pillbugs with [color = [color] of myself] > 0
      [
      ifelse any? other (pillbugs in-radius ([effectiverange] of min-one-of other pillbugs [distance myself])) with [color = ([color] of myself)]
      [
        set shield 2
        set label-color black
      ]
      [
        set shield 1
        set label-color [labelmemory] of self
      ]
      ]
      [
        set shield 1
        set label-color [labelmemory] of self
      ]
      ;Wasp Ability===============================================
      ifelse count other wasps with [color = [color] of myself] > 0
      [
      ifelse any? other (wasps in-radius ([effectiverange] of min-one-of other wasps [distance myself])) with [color = ([color] of myself)]
      [
        set damage (dmemory * 1.5)
        set label-color (red - 2)
      ]
      [
        set damage dmemory
        set label-color [labelmemory] of self
      ]
      ]
      [
        set damage dmemory
        set label-color [labelmemory] of self
      ]
      ;Dragonfly Ability==================================================
      ifelse count other dragonflies with [color = [color] of myself] > 0
      [
      ifelse any? (dragonflies in-radius ([effectiverange] of min-one-of other dragonflies [distance myself])) with [color = [color] of myself] and ([shape] of self != "dragonfly")
      [
        set speed (speedmemory * 2)
        set label-color yellow
      ]
      [
        set speed speedmemory
        set label-color [labelmemory] of self
      ]
      ]
      [
        set speed speedmemory
        set label-color [labelmemory] of self
      ]
      ;Bedbug Ability======================================================
      ifelse count other bedbugs with [color = [color] of myself] > 0
      [
      ifelse any? other (bedbugs in-radius ([effectiverange] of min-one-of other bedbugs [distance myself])) with [color = ([color] of myself)]
      [
        set speed [speed] of one-of (bedbugs in-radius ([effectiverange] of min-one-of other bedbugs [distance myself])) with [color = ([color] of myself)]
        set label-color grey
      ]
      [
        set speed speedmemory
        set label-color [labelmemory] of self
      ]
      ]
      [
        set speed speedmemory
        set label-color [labelmemory] of self
      ]
      ;============================Termite Burrows========================================
      if size = 1.256
      [
      die
      ]
      if [pcolor] of patch-here = black and flying? = false
      [
        set size 1.256
        set speed 0
        set speed speedmemory
      ]
    ]
    ask poisons
    [
    set label ""
      repeat 45
      [
        forward 1
        if any? turtles with [color = [rival] of myself] in-radius effectiverange
        [
          ask turtles with [color = [rival] of myself] in-radius effectiverange
        [
          set poisoned? true
        ]
          die
        ]
      ]
      die
    ]
    ask blinds
    [
    set label ""
      repeat 45
      [
        forward 1
        if any? turtles with [color = [rival] of myself] in-radius effectiverange
        [
          ask turtles with [color = [rival] of myself] in-radius effectiverange
        [
          set blindtime (blindtime + 7)
        ]
          die
        ]
      ]
      die
    ]

;==========================================================================================
;======================================FREE FOR ALL========================================
;==========================================================================================
if gamemode = 0
[
ifelse count turtles with [color = red] > 0 and count turtles with [color = blue] > 0 and gamemode = 0
[
  if gamemode = 0
  [
  ;Bugs Nest==============================================
        ask bugs_nests with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color blue
      set labelmemory white
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
        ask bugs_nests with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color red
      set labelmemory white
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
  ;Pollen Flowers=============================================================
   ask pollen_flowers with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = red] in-radius 4.5
            [
              set shape "pollon"
              set color yellow
            ]
            ask turtles with [color = red] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
   ask pollen_flowers with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = blue] in-radius 4.5
            [
              set shape "pollon"
              set color yellow
            ]
            ask turtles with [color = blue] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
  ;Bug Decoys===============================================
   ask bug_decoys with [shade-of? color blue]
        [
          set color 104
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
   ask bug_decoys with [shade-of? color red]
        [
          set color 14
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
  ;Health Givers==============================================
   ask health_givers with [shade-of? color blue]
        [
          face min-one-of turtles with [color = blue] [distance myself]
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
              ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]
            ]
          ]
          setxy bx by
        ]
   ask health_givers with [shade-of? color red]
        [
          face min-one-of turtles with [color = red] [distance myself]
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = red and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = red and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
              ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]
            ]
          ]
          setxy bx by
        ]
  ;Chemical Swappers==============================================================================
   ask chemical_swaps with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = red and switching? = true] != 1
          [
              if any? turtles with [color = red] in-radius 9
              [
            ask min-one-of turtles with [color = red] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = red and switching? = true]
              [
                set color blue
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = red and switching? = true] * 2)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = red and switching? = true] in-radius 9
            [
             set color blue
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
   ask chemical_swaps with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = blue and switching? = true] != 1
          [
              if any? turtles with [color = blue] in-radius 9
              [
            ask min-one-of turtles with [color = blue] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = blue and switching? = true]
              [
                set color red
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = blue and switching? = true] * 2)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = blue and switching? = true] in-radius 9
            [
             set color red
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
  ;Bugs---------------------------------------------------
          ask bugs with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))


            forward -2
     forward -1

  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
      ask bugs with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
   if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  ;Bees-------------------------------------------------------------------
ask bees with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
  ask bees with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
                set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
                forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Ants--------------------------------------------------------------------------
ask ants with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = blue]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
ask ants with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = red]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Caterpillars--------------------------------------------------------------------------------
  ask caterpillars with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  ask caterpillars with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius 1) with [color = blue]
     [
                set health (health - ([damage] of myself))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Butterflies-----------------------------------------------------------------------
      ask butterflies with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = blue and health < maxhealth]
        [
          face min-one-of caterpillars with [color = blue and health < maxhealth] [distance myself]
          ifelse [redweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = blue] in-radius effectiverange
          [
            ask caterpillars with [color = blue] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
      ask butterflies with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = red and health < 3]
        [
          face min-one-of caterpillars with [color = red and health < 3] [distance myself]
          ifelse [blueweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = red] in-radius effectiverange
          [
            ask caterpillars with [color = red] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
    ;Spiders----------------------------------------------------------------------------
  ask spiders with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        if random 20 = 1 and count (turtles-on patches with [pcolor != 109]) with [color = red] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 109]) with [color = red] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 109
          set blueweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  ask spiders with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    if random 20 = 1 and count (turtles-on patches with [pcolor != 19.5]) with [color = blue] > 0
    [
          ask max-one-of (turtles-on patches with [pcolor != 19.5]) with [color = blue] [distance myself]
      [
            ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 19.5
          set redweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Moths-------------------------------------------------------------------------------
      ask moths with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = red]
        [
          face min-one-of butterflies with [color = red] [distance myself]
          ifelse [redweb] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = red]
    [
      ask one-of (butterflies in-radius 1) with [color = red]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
          forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = red and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set dmemory damage set speed (speed / 2) set speedmemory speed set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]
      ask moths with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = blue]
        [
          face min-one-of butterflies with [color = blue] [distance myself]
          ifelse [BLUEWEB] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = blue]
    [
      ask one-of (butterflies in-radius 1) with [color = blue]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [BLUEWEB] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = blue and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set dmemory damage set speed (speed / 2) set speedmemory speed set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]

    ;Dragonflies-------------------------------------------------------------------------
    ask dragonflies with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ask dragonflies with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
             if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
     ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Beetles-----------------------------------------------------------------------------
        ask beetles with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
          forward 0 - [damage] of self
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
            forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
ask beetles with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
        forward -2
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
      forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
    ;Venom Spitters------------------------------------------------------------------------------------
  ask venomspitters with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red and poisoned? = true]
        [
    face min-one-of turtles with [color = red and poisoned? = true] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = red and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = red and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color red] [distance myself]
          hatch-poisons 1
          [
            set label ""
            set rival red
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color red] [distance myself]
          ]
        ]

    ]
  ]
  ask venomspitters with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue and poisoned? = true]
        [
    face min-one-of turtles with [color = blue and poisoned? = true] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = blue and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = blue and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color blue] [distance myself]
          hatch-poisons 1
          [
            set label ""
            set rival blue
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color blue] [distance myself]
          ]
        ]

    ]
  ]
    ;Grasshoppers----------------------------------------------------------------------------
    ask grasshoppers with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
      ]
  ]
ask grasshoppers with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Thorn Bugs---------------------------------------------------------------------------
       ask thornbugs with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
       ask thornbugs with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;Mantises---------------------------------------------------------------------------------
  ask mantises with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = red] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [redweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = red and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = red and health <= 0] in-radius 3
          [
            ask turtles with [color = blue] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = red and health <= 0] in-radius 6) / (count turtles with [color = blue] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
 ask mantises with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = blue] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [blueweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = blue and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = blue and health <= 0] in-radius 3
          [
            ask turtles with [color = red] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = blue and health <= 0] in-radius 6) / (count turtles with [color = red] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
    ;Pillbug----------------------------------------------------------------------------------------------------
       ask pillbugs with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
   ask pillbugs with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Cicadas-----------------------------------------------------------------------------------------------------
       ask cicadas with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
       ask cicadas with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Wasps-----------------------------------------------------------------------------------------------
  ask wasps with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
  ask wasps with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
      ;Bedbugs-------------------------------------------------------------------------------------------
  ask bedbugs with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ask bedbugs with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Walking Sticks--------------------------------------------------------------------------------------
     ask stickbug with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red] and (random 15 != 1)
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = red] with-max [damage]
          hatch-blinds 1
          [
            set rival red
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
     ask stickbug with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue] and (random 15 != 1)
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = blue] with-max [damage]
          hatch-blinds 1
          [
            set rival blue
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
    ;Tarantula Hawks-------------------------------------------------------------------------------------
  ask tarantulahawks with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
ask tarantulahawks with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
;Screwworm Flies--------------------------------------------------------------------------
ask screwworms with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set bhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
ask screwworms with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set rhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
ask larvaes with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 3
      set color blue
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
ask larvaes with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 3
      set color red
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
;Termites-----------------------------------------------------------------------------------
ask termites with [color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
          if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = red]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
ask termites with [color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)]
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = blue]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
;-------------------------------------------------------------------------------------------
ask turtles with [blindtime > 0]
    [
      left random 90
      right random 90
      forward speed
      set blindtime (blindtime - 1)
      ]
    ask turtles with [paralyzetime > 0]
    [
      set paralyzetime (paralyzetime - 1)
      ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = blue) and flying? = false]
[
  right 135
  forward speed
  ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = red) and flying? = false]
[
left 135
forward speed
]
        ask turtles with [health <= 0]
    [
      if bhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color blue
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set bhost? false
            ]
          ]
      if rhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color red
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set rhost? false
            ]
          ]
      die
    ]
    ]
  ]
  [
        if count turtles with [color = red] = 0
        [
          print "BLUE WINS"
          stop
        ]
        if count turtles with [color = blue] = 0
        [
          print "RED WINS"
          stop
        ]
  ]
  ]
    ;====================================================================================================
    ;==========================================NEST DESTROYER============================================
    ;====================================================================================================
if gamemode = 1
[
ifelse count nests = 2 and gamemode = 1
[
if gamemode = 1
[

      ask nests with [color = blue]
      [
        set color 103
        set label health
      ]
      ask nests with [color = red]
      [
        set color 13
        set label health
      ]
      ask turtles with [color = red]
      [
        set nestnumber 2
      ]
      ask turtles with [color = blue]
      [
        set nestnumber 1
      ]
      ask turtles with [recovering? = true]
      [
        setxy ([xcor] of one-of nests with [nestnumber = [nestnumber] of myself]) ([ycor] of one-of nests with [nestnumber = [nestnumber] of myself])
        set health (health + 1)
        set paralyzetime 10
        if health >= maxhealth
        [
          set recovering? false
        ]
      ]
  ;Bugs Nest==============================================
        ask bugs_nests with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color blue
      set labelmemory white
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
        ask bugs_nests with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color red
      set labelmemory white
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
  ;Pollen Flowers=============================================================
   ask pollen_flowers with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = red] in-radius 4.5
            ask turtles with [color = red] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
   ask pollen_flowers with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = blue] in-radius 4.5
            ask turtles with [color = blue] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
  ;Bug Decoys============================================================
   ask bug_decoys with [shade-of? color blue]
        [
          set color 104
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
   ask bug_decoys with [shade-of? color red]
        [
          set color 14
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
;Health Givers=====================================================================
   ask health_givers with [shade-of? color blue]
        [
          face min-one-of turtles with [color = blue] [distance myself]
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
              ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]

            ]
          ]
          setxy bx by
        ]
   ask health_givers with [shade-of? color red]
        [
          face min-one-of turtles with [color = red] [distance myself]
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = red and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = red and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
                            ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]
            ]
          ]
          setxy bx by
        ]
;Chemical Swappers==============================================================================
   ask chemical_swaps with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = red and switching? = true] != 1
          [
              if any? turtles with [color = red] in-radius 9
              [
            ask min-one-of turtles with [color = red] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = red and switching? = true]
              [
                set color blue
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = red and switching? = true] * 3)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = red and switching? = true] in-radius 9
            [
             set color blue
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
   ask chemical_swaps with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = blue and switching? = true] != 1
          [
              if any? turtles with [color = blue] in-radius 9
              [
            ask min-one-of turtles with [color = blue] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = blue and switching? = true]
              [
                set color red
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = blue and switching? = true] * 3)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = blue and switching? = true] in-radius 9
            [
             set color red
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
        ;==========================================================================
      ask turtles with [shape != "nest" and shape != "ant"]
     [
          ifelse any? turtles with [(color != [color] of myself) and (shape != "nest")] in-radius 9 and (not any? nests with [nestnumber != [nestnumber] of myself] in-radius 9)
      [
              if shape = "bug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
      if shape = "bug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
   if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  ;Bees-------------------------------------------------------------------
if shape = "bee 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
  if shape = "bee 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
                set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Ants--------------------------------------------------------------------------
if shape = "ant 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = blue]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
if shape = "ant 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = red]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Caterpillars--------------------------------------------------------------------------------
  if shape = "caterpillar" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  if shape = "caterpillar" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius 1) with [color = blue]
     [
       set health (health - 1)
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Butterflies-----------------------------------------------------------------------
      if shape = "butterfly" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = blue and health < 3]
        [
          face min-one-of caterpillars with [color = blue and health < 3] [distance myself]
          ifelse [redweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = blue] in-radius effectiverange
          [
            ask caterpillars with [color = blue] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
      if shape = "butterfly" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = red and health < 3]
        [
          face min-one-of caterpillars with [color = red and health < 3] [distance myself]
          ifelse [blueweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = red] in-radius effectiverange
          [
            ask caterpillars with [color = red] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
    ;Spiders----------------------------------------------------------------------------
if shape = "spider" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        if random 20 = 1 and count (turtles-on patches with [pcolor != 109]) with [color = red] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 109]) with [color = red] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 109
          set blueweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  if shape = "spider" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    if random 20 = 1 and count (turtles-on patches with [pcolor != 19.5]) with [color = blue] > 0
    [
          ask max-one-of (turtles-on patches with [pcolor != 19.5]) with [color = blue] [distance myself]
      [
            ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 19.5
          set redweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Moths-------------------------------------------------------------------------------
      if shape = "butterfly 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = red]
        [
          face min-one-of butterflies with [color = red] [distance myself]
          ifelse [redweb] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = red]
    [
      ask one-of (butterflies in-radius 1) with [color = red]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
          forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = red and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set speed (speed / 2) set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]
      if shape = "butterfly 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = blue]
        [
          face min-one-of butterflies with [color = blue] [distance myself]
          ifelse [BLUEWEB] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = blue]
    [
      ask one-of (butterflies in-radius 1) with [color = blue]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [BLUEWEB] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = blue and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set speed (speed / 2) set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]

    ;Dragonflies-------------------------------------------------------------------------
    if shape = "dragonfly" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    if shape = "dragonfly" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
             if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
     ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Beetles-----------------------------------------------------------------------------
        if shape = "beetle" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
          forward 0 - [damage] of self
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
            forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
if shape = "beetle" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
        forward -2
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
      forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
    ;Venom Spitters------------------------------------------------------------------------------------
  if shape = "venomspitter" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red and poisoned? = true]
        [
    face min-one-of turtles with [color = red and poisoned? = true] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = red and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = red and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color red] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival red
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color red] [distance myself]
          ]
        ]

    ]
  ]
if shape = "venomspitter" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue and poisoned? = true]
        [
    face min-one-of turtles with [color = blue and poisoned? = true] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = blue and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = blue and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color blue] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival blue
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color blue] [distance myself]
          ]
        ]

    ]
  ]
    ;Grasshoppers----------------------------------------------------------------------------
    if shape = "grasshopper" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "grasshopper" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Thorn Bugs---------------------------------------------------------------------------
       if shape = "thornbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
       if shape = "thornbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;Mantises---------------------------------------------------------------------------------
  if shape = "mantis" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = red] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [redweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = red and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = red and health <= 0] in-radius 3
          [
            ask turtles with [color = blue] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = red and health <= 0] in-radius 6) / (count turtles with [color = blue] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
 if shape = "mantis" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = blue] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [blueweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = blue and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = blue and health <= 0] in-radius 3
          [
            ask turtles with [color = red] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = blue and health <= 0] in-radius 6) / (count turtles with [color = red] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
    ;Pillbug----------------------------------------------------------------------------------------------------
       if shape = "pillbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
   if shape = "pillbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Cicadas-----------------------------------------------------------------------------------------------------
       if shape = "cicada" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
       if shape = "cicada" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Wasps-----------------------------------------------------------------------------------------------
  if shape = "wasp" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
  if shape = "wasp" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
      ;Bedbugs-------------------------------------------------------------------------------------------
  if shape = "bedbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    if shape = "bedbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Walking Sticks--------------------------------------------------------------------------------------
     if shape = "walkingstick" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red] and (random 20 != 1)
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = red] with-max [damage]
          hatch-blinds 1
          [
            set rival red
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
     if shape = "walkingstick" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue] and (random 20 != 1)
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = blue] with-max [damage]
          hatch-blinds 1
          [
            set rival blue
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
    ;Tarantula Hawks-------------------------------------------------------------------------------------
  if shape = "tarantulahawk" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
if shape = "tarantulahawk" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
;Screwworms------------------------------------------------------------------------
if shape = "screwworm" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set bhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "screwworm" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set rhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "larvae" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 3
      set color blue
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "larvae" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 3
      set color red
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;Termites-------------------------------------------------------------------------------------
 if shape = "termite" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
          if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = red]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "termite" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = blue]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;------------
      ]
      [
        ;=================
          if any? nests with [nestnumber != [nestnumber] of myself] in-radius 4
        [

          ask nests with [nestnumber != [nestnumber] of myself]
          [
              set health (health - [damage] of myself)
          ]
          ask self
          [
            forward 0 - speed
            forward -1
            if shape = "mantis"
            [
                 set speed 2
                 set speedmemory speed
                 set damage 1
                 set dmemory damage
            ]
            if shape = "beetle"
             [
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
             ]
          ]
        ]

          if [color] of self = blue
          [
            face one-of nests with [color = 13]
          ]
          if [color] of self = red
          [
            face one-of nests with [color = 103]
          ]
        ifelse shape != "mantis"
              [
        forward speed
              ]
              [
                forward speed - 1
              ]
      ]
      ]
              ;Grasshoppers----------
        ask grasshoppers
        [
            ifelse not any? turtles with [shade-of? [color] of self [color] of myself = false] in-radius 9
            [
              set speed 12
            ]
            [
              set speed speedmemory
            ]
          ]
        ;Spiders--------------------
        ask spiders with [color = blue]
        [
       if random 20 = 1 and count (turtles-on patches with [pcolor != 109]) with [color = red] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 109]) with [color = red] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 109
          set blueweb true
          set sspawntime 60
       ]
      ]
    ]
      ]
        ask spiders with [color = red]
        [
        if random 20 = 1 and count (turtles-on patches with [pcolor != 19.5]) with [color = blue] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 19.5]) with [color = blue] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 19.5
          set redweb true
          set sspawntime 60
        ]
      ]
    ]
      ]
        ;Venom Spitters---
        ask venomspitters with [color = blue]
        [
          if count turtles with [color = red and poisoned? = true] = 0
         [
                if count turtles with [color = red] >= 1
                [
          face min-one-of turtles with [shade-of? color red] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival red
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color red] [distance myself]
          ]
          ]
              ]

        ]
        ask venomspitters with [color = red]
        [
          if count turtles with [color = blue and poisoned? = true] = 0
          [
                if count turtles with [color = blue] >= 1
                [
          face min-one-of turtles with [shade-of? color blue] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival blue
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color blue] [distance myself]
          ]
          ]
              ]
        ]
        ;Beetles----------
        ask beetles
        [
          set speed (speed + 0.25)
          set speedmemory speed
          set damage speed
          set dmemory damage
          if speed > 3
          [
          set facememory [heading] of self
          set ramming true
          ]
        ]
        ;Walking Stick----
        ask stickbug with [color = blue]
        [
          if random 20 = 1 and (count turtles with [color = red] > 0)
        [
            face one-of turtles with [color = red] with-max [damage]
          hatch-blinds 1
          [
            set rival red
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]
        ]
        ask stickbug with [color = red]
        [
          if random 20 = 1 and (count turtles with [color = red] > 0)
        [
            face one-of turtles with [color = blue] with-max [damage]
          hatch-blinds 1
          [
            set rival blue
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]
        ]
          ask larvaes with [color = blue]
                  [
                    set spawntime (spawntime - 1)
          if spawntime <= 0
            [
     hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color blue
      set flying? true
    ]
                      die
                    ]
                  ]
       ask larvaes with [color = red]
                  [
                    set spawntime (spawntime - 1)
          if spawntime <= 0
            [
     hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color red
      set flying? true
    ]
                      die
                    ]
                  ]
       ;=================
    ]
    ask turtles with [blindtime > 0]
    [
      left random 90
      right random 90
      forward speed
      set blindtime (blindtime - 1)
      ]
    ask turtles with [paralyzetime > 0]
    [
      set paralyzetime (paralyzetime - 1)
      ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = blue) and flying? = false]
[
  right 135
  forward speed
  ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = red) and flying? = false]
[
left 135
forward speed
]
      ask turtles with [shape != "nest"]
    [
        if (health <= 0)
        [
          ask nests with [nestnumber = [nestnumber] of myself]
          [
            ifelse count turtles with [recovering? = true and nestnumber = [nestnumber] of myself] = 0
            [
              ask myself
              [
                setxy ([xcor] of one-of nests with [nestnumber = [nestnumber] of myself]) ([ycor] of one-of nests with [nestnumber = [nestnumber] of myself])
                set paralyzetime 10
                set recovering? true
              ]
            ]
            [
              ask myself
              [
                if bhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color blue
      set poisoned? false
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set bhost? false
            ]
          ]
      if rhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color red
      set poisoned? false
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set bhost? false
            ]
          ]
                die
              ]
            ]
        ]
        ]
    ]
    ask nests
      [
        if health <= 0
        [
          die
        ]
      ]
  ]
  [
  if count nests with [color = 13] = 0
        [
    print "BLUE WINS"
    stop
        ]
  if count nests with [color = 103] = 0
        [
    print "RED WINS"
    stop
        ]
  ]
  ]
  ;=====================================================================================
  ;=================================ENERGY BUGS=========================================
  ;=====================================================================================
  if gamemode = 2
  [
    ask points with [color = blue]
    [
      set color violet
    ]
    ask points with [color = red]
    [
      set color orange
    ]
  ;Bugs Nest==============================================
        ask bugs_nests with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color blue
      set label ""
      set labelmemory white
      set building? 0
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
        ask bugs_nests with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              hatch-bugs 1
              [
       set shield 1
       set building? 0
      set health 1
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "bug"
      set size 1.5
      set color red
      set label ""
      set labelmemory white
      set building? 0
              ]
              set health (health - 2)
              set spawntime 10
            ]
          ]
          setxy bx by
        ]
  ;Pollen Flowers=============================================================
   ask pollen_flowers with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = red] in-radius 4.5
            ask turtles with [color = red] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
   ask pollen_flowers with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
            create-links-to turtles with [color = blue] in-radius 4.5
            ask turtles with [color = blue] in-radius 4.5
            [
              set blindtime 2
            ]
          ]
          setxy bx by
        ]
  ;Bug Decoys============================================================
   ask bug_decoys with [shade-of? color blue]
        [
          set color 104
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
   ask bug_decoys with [shade-of? color red]
        [
          set color 14
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            set spawntime (spawntime - 1)
            if spawntime = 0
            [
              set health (health - 1)
              set spawntime 10
            ]
          ]
        ]
;Health Givers=====================================================================
   ask health_givers with [shade-of? color blue]
        [
              if count turtles with [color = blue] > 0
              [
          face min-one-of turtles with [color = blue] [distance myself]
              ]
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = blue and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
              ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]

            ]
          ]
          setxy bx by
        ]
   ask health_givers with [shade-of? color red]
        [
              if count turtles with [color = red] > 0
              [
          face min-one-of turtles with [color = red] [distance myself]
              ]
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            create-links-to turtles with [color = red and health < maxhealth] in-radius 6
            [
              set shape "healing"
              set color lime
            ]
            ask turtles with [color = red and health < maxhealth] in-radius 6
            [
              set health (health + 0.5)
                            ask myself
              [
                set health (health - 0.5)
                ]
              if health > maxhealth
              [
                set health maxhealth
              ]
            ]
          ]
          setxy bx by
        ]
;Chemical Swappers==============================================================================
   ask chemical_swaps with [shade-of? color blue]
        [
          set color 104
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = red and switching? = true] != 1
          [
              if any? turtles with [color = red] in-radius 9
              [
            ask min-one-of turtles with [color = red] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = red and switching? = true]
              [
                set color blue
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = red and switching? = true] * 3)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = red and switching? = true] in-radius 9
            [
             set color blue
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
   ask chemical_swaps with [shade-of? color red]
        [
          set color 14
          if ticks = 1
          [
            set bx xcor
            set by ycor
          ]
          if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
          [
            if count turtles with [color = blue and switching? = true] != 1
          [
              if any? turtles with [color = blue] in-radius 9
              [
            ask min-one-of turtles with [color = blue] in-radius 9 [distance myself]
            [
              set switching? true
            ]
            create-links-to turtles with [color = blue and switching? = true]
              [
                set color red
                set shape "chemical"
              ]
              set spawntime ([maxhealth] of one-of turtles with [color = blue and switching? = true] * 3)
          ]
            ]
            set spawntime (spawntime - 1)
            if spawntime <= 0
            [
            ask turtles with [color = blue and switching? = true] in-radius 9
            [
             set color red
             set switching? false
                ask my-links with [shape = "chemical"]
                [
                  die
                ]
            ]
              set spawntime 0
            ]
          ]
          setxy bx by
        ]
  ;==========================================================================

    ;GAMEMODE CONSTANTS================================================================================================
    ask patches with [(plabel != "") and ((rselected?? = true) or (bselected?? = true))]
    [
      set plabel-color black
    ]
    ask patches with [(plabel != "") and ((rselected?? != true) and (bselected?? != true))]
    [
      set plabel-color white
    ]
    ifelse (count points with [color = violet] > 0) and (count points with [color = orange] > 0) and gamemode = 2
    [
      set rgen (rgen - 1)
      set bgen (bgen - 1)
      if rgen <= 0
      [
        repeat (count points with [color = orange])
        [
          set rbudget (rbudget + 1)
        ]
        set rgen 12
      ]
      if bgen <= 0
      [
        repeat (count points with [color = violet])
        [
          set bbudget (bbudget + 1)
        ]
        set bgen 12
      ]
      ask points with [color = violet]
      [
        if any? turtles with [color = red] in-radius 1
        [
          set spawntime (spawntime - 1)
        ]
        if spawntime <= 0
        [
          die
        ]
        set label precision spawntime 1
      ]
      ask points with [color = orange]
      [
        if any? turtles with [color = blue] in-radius 1
        [
          set spawntime (spawntime - 1)
        ]
        if spawntime <= 0
        [
          die
        ]
        set label precision spawntime 1
      ]
      ask turtles with [blindtime > 0]
    [
      left random 90
      right random 90
      forward speed
      set blindtime (blindtime - 1)
      ]
    ask turtles with [paralyzetime > 0]
    [
      set paralyzetime (paralyzetime - 1)
      ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = blue) and flying? = false]
[
  right 135
  forward speed
  ]
ask turtles with [(patch-ahead speed = nobody) or ([pcolor] of (patch-ahead speed) = black) and (color = red) and flying? = false]
[
left 135
forward speed
]
ask turtles with [health <= 0]
    [
      if bhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color blue
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set bhost? false
            ]
          ]
      if rhost? = true
      [
        hatch-larvaes 1
        [
      set shield 1
      set health 1.5
      set maxhealth health
      set speed 1
      set speedmemory 1
      set damage 1
      set dmemory damage
      set shape "larvae"
      set size 2
      set color red
      set label-color white
      set labelmemory white
      set poisoned? false
      set flying? true
      set spawntime 20
      set rhost? false
            ]
          ]
      die
    ]
      ;===================================================================================================================
      ask turtles with [(building? != true) and (shape != "energybug")]
      [

        ifelse not any? turtles with [(shade-of? color ([color] of myself) = false) and shape != "energybug"] in-radius 9
        [
          ifelse not any? (points-on patch-here) with [(color != ([color] of myself + 10))]
          [
            if blindtime = 0 and paralyzetime = 0
            [
            if count points with [(color != ([color] of myself + 10))] > 0
            [
            face min-one-of points with [(color != ([color] of myself + 10))] [distance myself]
            if color = blue
            [
              ifelse [redweb] of patch-here = false
              [
                forward speed
              ]
              [
                forward (speed / 4)
              ]
            ]
            if color = red
            [
              ifelse [blueweb] of patch-here = false
              [
                forward speed
              ]
              [
                forward (speed / 4)
              ]
            ]
 ;Grasshoppers----------
        if shape = "grasshopper"
        [
            ifelse not any? turtles with [shade-of? [color] of self [color] of myself = false] in-radius 9
            [
              set speed 12
            ]
            [
              set speed speedmemory
            ]
          ]
        ;Spiders--------------------
        if shape = "spider" and color = blue
        [
       if random 20 = 1 and count (turtles-on patches with [pcolor != 109]) with [color = red] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 109]) with [color = red] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 109
          set blueweb true
          set sspawntime 60
       ]
      ]
    ]
      ]
        if shape = "spider" and color = red
        [
        if random 20 = 1 and count (turtles-on patches with [pcolor != 19.5]) with [color = blue] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 19.5]) with [color = blue] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 19.5
          set redweb true
          set sspawntime 60
        ]
      ]
    ]
      ]
        ;Venom Spitters---
        if shape = "venomspitter" and color = blue
        [
          if count turtles with [color = red and poisoned? = true] = 0
         [
                if count turtles with [color = red] >= 1
                [
          face min-one-of turtles with [shade-of? color red] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival red
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color red] [distance myself]
          ]
          ]
              ]

        ]
        if shape = "venomspitter" and color = red
        [
          if count turtles with [color = blue and poisoned? = true] = 0
          [
                if count turtles with [color = blue] >= 1
                [
          face min-one-of turtles with [shade-of? color blue] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival blue
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color blue] [distance myself]
          ]
          ]
              ]
        ]
        ;Beetles----------
        if shape = "beetle"
        [
          set speed (speed + 0.25)
          set speedmemory speed
          set damage speed
          set dmemory damage
          if speed > 3
          [
          set facememory [heading] of self
          set ramming true
          ]
        ]
        ;Walking Stick----
        if shape = "stickbug" and color = blue
        [
          if random 20 = 1 and (count turtles with [color = red] > 0)
        [
            face one-of turtles with [color = red] with-max [damage]
          hatch-blinds 1
          [
            set rival red
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]
        ]
        if shape = "stickbug" and color = red
        [
          if random 20 = 1 and (count turtles with [color = red] > 0)
        [
            face one-of turtles with [color = blue] with-max [damage]
          hatch-blinds 1
          [
            set rival blue
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]
        ]
        ;Larvae----------
        if shape = "larvae" and color = blue
                  [
                    set spawntime (spawntime - 1)
          if spawntime <= 0
            [
     hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color blue
      set flying? true
    ]
                      die
                    ]
                  ]
       if shape = "larvae" and color = red
                  [
                    set spawntime (spawntime - 1)
          if spawntime <= 0
            [
     hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color red
      set flying? true
    ]
                      die
                    ]
                  ]

          ]
              ]
          ]
          [

          ]
        ]
        [
          ifelse not any? (points-on patch-here) with [(color != ([color] of myself + 10))]
          [
if shape = "bug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))


            forward -2
     forward -1

  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
if shape = "bug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
   if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
  ;Bees-------------------------------------------------------------------
if shape = "bee 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
if shape = "bee 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
                set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
                forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

     set health (health - ((1 / speed) / shield))
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Ants--------------------------------------------------------------------------
if shape = "ant 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = blue]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
if shape = "ant 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set damage 1 + (0.5 * (count other ants in-radius effectiverange with [color = red]))
    set dmemory damage
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Caterpillars--------------------------------------------------------------------------------
if shape = "caterpillar" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
if shape = "caterpillar" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius 1) with [color = blue]
     [
                set health (health - ([damage] of myself))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Butterflies-----------------------------------------------------------------------
if shape = "butterfly" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = blue and health < 3]
        [
          face min-one-of caterpillars with [color = blue and health < 3] [distance myself]
          ifelse [redweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = blue] in-radius effectiverange
          [
            ask caterpillars with [color = blue] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
if shape = "butterfly" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? caterpillars with [color = red and health < 3]
        [
          face min-one-of caterpillars with [color = red and health < 3] [distance myself]
          ifelse [blueweb] of patch-here = false
          [
          forward speed
          ]
          [
          forward (speed / 4)
          ]
          if any? caterpillars with [color = red] in-radius effectiverange
          [
            ask caterpillars with [color = red] in-radius effectiverange
            [
              set health (health + 1)
              if health > 3
              [ set health 3]
            ]
          ]
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
      ]
  ]
    ;Spiders----------------------------------------------------------------------------
if shape = "spider" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        if random 20 = 1 and count (turtles-on patches with [pcolor != 109]) with [color = red] > 0
    [
      ask max-one-of (turtles-on patches with [pcolor != 109]) with [color = red] [distance myself]
      [
        ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 109
          set blueweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
if shape = "spider" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    if random 20 = 1 and count (turtles-on patches with [pcolor != 19.5]) with [color = blue] > 0
    [
          ask max-one-of (turtles-on patches with [pcolor != 19.5]) with [color = blue] [distance myself]
      [
            ask patches in-radius ([effectiverange] of myself)
        [
          set pcolor 19.5
          set redweb true
          set sspawntime 60
        ]
      ]
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
            set poisoned? true
  if thorns = true
    [
      ask myself
      [
       set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
      ]
  ]
    ;Moths-------------------------------------------------------------------------------
 if shape = "butterfly 2" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = red]
        [
          face min-one-of butterflies with [color = red] [distance myself]
          ifelse [redweb] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = red]
    [
      ask one-of (butterflies in-radius 1) with [color = red]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
          forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = red and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set dmemory damage set speed (speed / 2) set speedmemory speed set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]
if shape = "butterfly 2" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? butterflies with [color = blue]
        [
          face min-one-of butterflies with [color = blue] [distance myself]
          ifelse [BLUEWEB] of patch-here = false
         [
           forward speed
          ]
          [
            forward (speed / 4)
          ]
         if any? (butterflies in-radius 1) with [color = blue]
    [
      ask one-of (butterflies in-radius 1) with [color = blue]
     [
            set health (health - ((([damage] of myself) * 2) / shield))
              forward -2
     forward -1
      ]

    ]
        ]
       [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [BLUEWEB] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
              forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]

    ]
        ]
    if health <= 0
    [
          ask turtles in-radius effectiverange with [color = blue and [shape] of self != "beetle"]
          [
            set damage (damage / 2) set dmemory damage set speed (speed / 2) set speedmemory speed set label-color (grey - 2) set labelmemory (grey - 2)
            set dmemory damage
            set speedmemory speed
          ]
    ]
      ]
  ]

    ;Dragonflies-------------------------------------------------------------------------
if shape = "dragonfly" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
if shape = "dragonfly" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
             if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
     ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
    ;Beetles-----------------------------------------------------------------------------
if shape = "beetle" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
          forward 0 - [damage] of self
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
            forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
if shape = "beetle" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse ramming = true
        [
          set heading facememory
        ]
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ]
    forward speed
    set speed (speed + 0.25)
    set speedmemory speed
    set damage speed
    set dmemory damage
        if ([pxcor] of patch-here >= 33.9) or ([pycor] of patch-here >= -0.9) or ([pxcor] of patch-here <= 0.9) or ([pycor] of patch-here <= -45.9) and ramming = true
      [
        set ramming false
        set speed 0.25
        set speedmemory speed
        set damage speed
        set dmemory damage
        forward -2
        forward -1
       ]
    if speed > 3
      [
        set facememory [heading] of self
        set ramming true
      ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask (turtles in-radius effectiverange) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward 0 - [damage] of myself
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
          if [damage] of self > 3.5
          [
      forward 0 - [damage] of self
      forward -1
          ]
      set speed 0.25
      set speedmemory speed
      set damage speed
      set dmemory damage
      set ramming false
    ]
      ]
  ]
    ;Venom Spitters------------------------------------------------------------------------------------
if shape = "venomspitter" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red and poisoned? = true]
        [
    face min-one-of turtles with [color = red and poisoned? = true] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = red and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = red and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color red] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival red
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color red] [distance myself]
          ]
        ]

    ]
  ]
if shape = "venomspitter" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue and poisoned? = true]
        [
    face min-one-of turtles with [color = blue and poisoned? = true] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [color = blue and poisoned? = true]
    [
      ask one-of (turtles in-radius 1) with [color = blue and poisoned? = true]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
          face min-one-of turtles with [shade-of? color blue] [distance myself]
          hatch-poisons 1
          [
          set label ""
            set rival blue
            set color 52
            set ermemory effectiverange
            set size 1
            face min-one-of turtles with [shade-of? color blue] [distance myself]
          ]
        ]

    ]
  ]
    ;Grasshoppers----------------------------------------------------------------------------
if shape = "grasshopper" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage / 2))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "grasshopper" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) > 12
        [
          set speed 12
        ]
        [
          set speed speedmemory
        ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Thorn Bugs---------------------------------------------------------------------------
if shape = "thornbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "thornbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;Mantises---------------------------------------------------------------------------------
if shape = "mantis" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = red] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = red] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [redweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = red and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = red and health <= 0] in-radius 3
          [
            ask turtles with [color = blue] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = red and health <= 0] in-radius 6) / (count turtles with [color = blue] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
if shape = "mantis" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [distance myself] of (min-one-of turtles with [color = blue] [distance myself]) < 7 and speed < ([distance myself] of min-one-of turtles with [color = blue] [distance myself])
        [
          set speed (speed + 1)
          set speedmemory speed
          set damage (damage + 1)
          set dmemory damage
        ]
        [
        ifelse [blueweb] of patch-here = false
        [
    forward speed - 1
    set speed 2
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
     set speed 2
     set speedmemory speed
     set damage 1
     set dmemory damage
    ]
        ]
          if any? turtles with [color = blue and health <= 0] in-radius 3
          [
          ask one-of turtles with [color = blue and health <= 0] in-radius 3
          [
            ask turtles with [color = red] in-radius 6
            [
          set health health + (1 + (([maxhealth] of one-of (turtles with [color = blue and health <= 0] in-radius 6) / (count turtles with [color = red] in-radius 6))))
          if health > maxhealth
          [
            set health maxhealth
          ]
            ]
          ]
      ]
      ]
  ]
    ;Pillbug----------------------------------------------------------------------------------------------------
if shape = "pillbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "pillbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Cicadas-----------------------------------------------------------------------------------------------------
if shape = "cicada" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "cicada" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Wasps-----------------------------------------------------------------------------------------------
if shape = "wasp" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
if shape = "wasp" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
      ;Bedbugs-------------------------------------------------------------------------------------------
if shape = "bedbug" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "bedbug" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
     [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
    ;Walking Sticks--------------------------------------------------------------------------------------
if shape = "walkingstick" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = red] and (random 15 != 1)
        [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = red] with-max [damage]
          hatch-blinds 1
          [
            set rival red
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
if shape = "walkingstick" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
        ifelse any? turtles with [color = blue] and (random 15 != 1)
        [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - (([damage] of myself) / shield))
     forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
        ]
        [
            face one-of turtles with [color = blue] with-max [damage]
          hatch-blinds 1
          [
            set rival blue
            set color brown
            set ermemory effectiverange
            set size 1
            set heading [heading] of myself
          ]
        ]

    ]
  ]
    ;Tarantula Hawks-------------------------------------------------------------------------------------
if shape = "tarantulahawk" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
if shape = "tarantulahawk" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    repeat speed
          [
            forward 1
            if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
     set health (health - ((([damage] of myself) / ([speed] of myself)) / shield))
     if [shape] of self != "beetle"
       [
         set poisoned? true
         set effectiverange 0
         set ermemory 0
       ]
     set paralyzetime (paralyzetime + 1)
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
          ]
        ]
        [
    forward (speed / 4)
        ]
      ]
  ]
;Screwworm Flies--------------------------------------------------------------------------
if shape = "screwworm" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set bhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "screwworm" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            set poisoned? true
            set rhost? true
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "larvae" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color blue
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color red] [distance myself]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "larvae" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    set spawntime (spawntime - 1)
    if spawntime <= 0
    [
    hatch-screwworms 1
    [
      set shield 1
      set health 4
      set maxhealth health
      set speed 1.5
      set speedmemory 1.5
      set damage 1.5
      set dmemory damage
      set shape "screwworm"
      set size 2.5
      set color red
      set flying? true
    ]
    die
    ]
    face min-one-of turtles with [shade-of? color blue] [distance myself]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            set health (health - (([damage] of myself) / shield))
            forward -2
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
;Termites-------------------------------------------------------------------------------------------
if shape = "termite" and color = blue and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color red] [distance myself]
          if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = red]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [redweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color red]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color red]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
if shape = "termite" and color = red and blindtime = 0 and paralyzetime = 0 and (patch-ahead speed != nobody) and ([pcolor] of (patch-ahead speed) != black)
  [
    if count turtles with [color = red] > 0 and count turtles with [color = blue] > 0
      [
    face min-one-of turtles with [shade-of? color blue] [distance myself]
if ((not any? patches with ([nobody = true]) in-radius 3) and (any? (turtles-on patch-ahead 2) with [color = blue]) and (not any? (patches with [pcolor = black]) in-radius 3))
    [
      ask patch-ahead 3
      [
      ask patches in-radius 1 with [center? = true]
      [
        ask patches in-radius 1.5
        [
          set pcolor black
        ]
      ]
      ]
    ]
        ifelse [blueweb] of patch-here = false
        [
    forward speed
        ]
        [
    forward (speed / 4)
        ]
    if any? (turtles in-radius 1) with [shade-of? color blue]
    [
      ask one-of (turtles in-radius 1) with [shade-of? color blue]
     [
            ifelse building? != true
            [
            set health (health - (([damage] of myself) / shield))
            ]
            [
            set health (health - ((([damage] of myself) / shield)) * 4)
            ]
     forward -1
  if thorns = true
    [
      ask myself
      [
        set health (health - (damage * 0.75))
      ]
    ]
      ]
    ]
      ]
  ]
  ;-------------------------------------------------------
          ]
          [

          ]
        ]
      ]
    ]
    [
      if count points with [color = orange] = 0
        [
          print "BLUE WINS"
          stop
        ]
      if count points with [color = violet] = 0
        [
          print "RED WINS"
          stop
        ]
    ]
  ]
  ]
  tick
end 

There is only one version of this model, created almost 4 years ago by Israel Alderete.

Attached files

File Type Description Last updated
Silly Bug Game.png preview Preview for 'Silly Bug Game' almost 4 years ago, by Israel Alderete Download

This model does not have any ancestors.

This model does not have any descendants.