coding help

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

coding help

NetLogo-Users mailing list
net logo keeps telling me that it expected a literal value and I'm not really sure what that means or how to fix it. Could someone take a look at my code and see where I could've gone wrong.
 

 breed [ bacteria1 bacterium1 ]
 breed [ bacteria2 bacterium2 ]
 breed [flagella1  flagellum1]
 breed [flagella2  flagellum2]
 breed [macrophage macrophages]
 directed-link-breed [connectors connector]
 

 bacteria1-own [variation1]
 bacteria2-own [variation2]
 

 globals [
   wiggle?                   ;;  boolean for whether the bacteria wiggle back and forth randomly as they move
   speed-scalar              ;;  scales the speed of all bacteria movement
   bacteria1-default-color    ;;  color of bacteria when color is not used in visualize-variation setting
   bacteria2-default-color    ;;  color of bacteria when color is not used in visualize-variation setting
   flagella1-size             ;;  size of the flagella1
   flagella2-size             ;;  size of the flagella2
   initial-bacteria1-per-variation1
   initial-bacteria2-per-variation2
   visualize-variation1
   visualize-variation2
 ]
 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;  Setup Procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

 to setup
   clear-all
   set-default-shape macrophage "circle"
   create-macrophage initial-number-macrophages  ; create the macrophages, then initialize their variables
   [
     set color orange
     set size 1.5  ; easier to see
     setxy random-xcor random-ycor
   ]
   
   set bacteria1-default-color   [100 100 100 200]
 

   set-default-shape bacteria1 "bacteria"
   set-default-shape flagella1 "flagella"
 

   set speed-scalar 0.04
   set flagella1-size 1.2
   set wiggle? true
   ask patches [ set pcolor white ]
 

   setup-bacteria1
   
   set bacteria2-default-color   [100 100 100 200]
 

   set-default-shape bacteria2 "bacteria"
   set-default-shape flagella2 "flagella"
 

   set speed-scalar 0.04
   set flagella2-size 1.2
   set wiggle? true
   ask patches [ set pcolor white ]
 

   setup-bacteria2
   reset-ticks
 end
 

 to setup-bacteria1
   foreach [1] [ this-variation1 ->
     create-bacteria1 initial-bacteria1-per-variation1 [
       set label-color black
       set size 1
       set variation1 this-variation1
       make-flagella1
       setxy random-xcor random-ycor
     ]
   ]
   visualize-bacteria1
 end
 

 

 to setup-bacteria2
   foreach [1] [ this-variation2 ->
     create-bacteria2 initial-bacteria2-per-variation2 [
       set label-color black
       set size 1.5
       set variation2 this-variation2
       make-flagella2
       setxy random-xcor random-ycor
     ]
   ]
   visualize-bacteria2
 end
 

 to make-flagella1 ;; bacteria1 procedure
   let flagella1-shape word "flagella-" variation1
   hatch 1 [
     set breed flagella1
     set color bacteria1-default-color
     set label ""
     set shape flagella1-shape
     bk 0.4
     set size flagella1-size
     create-connector-from myself [
       set hidden? true
       tie
     ]
   ]
 end
 

 to make-flagella2 ;; bacteria2 procedure
   let flagella2-shape word "flagella-" variation2
   hatch 1 [
     set breed flagella2
     set color bacteria2-default-color
     set label ""
     set shape flagella2-shape
     bk 0.4
     set size flagella2-size
     create-connector-from myself [
       set hidden? true
       tie
     ]
   ]
 end
 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;  Runtime Procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

 to go
   if not any? turtles [ stop ]
   ask macrophage [
     move
   ]
   move-bacteria1
   ask flagella1 [ move-flagella1 ]
   visualize-bacteria1
   tick
   move-bacteria2
   ask flagella2 [ move-flagella2 ]
   visualize-bacteria2
   tick
 end
 

 to move  ; turtle procedure
   rt random 50
   lt random 50
   fd 1
 end
 

 to move-bacteria1
   ask bacteria1 [
     if wiggle? [ right (random-float 25 - random-float 25) ]
     fd variation1 * speed-scalar
   ]
 end
 

 to move-bacteria2
   ask bacteria2 [
     if wiggle? [ right (random-float 25 - random-float 25) ]
     fd variation2 * speed-scalar
   ]
 end
 

 to move-flagella1
   let flagella1-swing 15 ;; magnitude of angle that the flagella swing back and forth
   let flagella1-speed 60 ;; speed of flagella swinging back and forth
   let new-swing1 flagella1-swing * sin (flagella1-speed * ticks)
   let my-bacteria1 one-of in-link-neighbors
   set heading [ heading ] of my-bacteria1 + new-swing1
 end
 

 to move-flagella2
   let flagella2-swing 15 ;; magnitude of angle that the flagella swing back and forth
   let flagella2-speed 60 ;; speed of flagella swinging back and forth
   let new-swing2 flagella2-swing * sin (flagella2-speed * ticks)
   let my-bacteria2 one-of in-link-neighbors
   set heading [ heading ] of my-bacteria2 + new-swing2
 end
 

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;visualization procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

 to visualize-bacteria1
   ask bacteria1 [
     ifelse visualize-variation1 = "# flagella1 as label"
       [ set label word variation1 "     " ]
       [ set label "" ]
     ifelse member? visualize-variation1 ["flagella1 and color" "as color only"]
       [ set color item (variation1 - 1) [red] ]
       [ set color bacteria1-default-color ]
   ]
   ask flagella1 [
     set hidden? member? visualize-variation ["as color only" "# flagella1 as label" "none"]
   ]
 end
 

 to visualize-bacteria2
   ask bacteria2 [
     ifelse visualize-variation2 = "# flagella2 as label"
       [ set label word variation2 "     " ]
       [ set label "" ]
     ifelse member? visualize-variation2 ["flagella2 and color" "as color only"]
       [ set color item (variation2 - 1) [purple] ]
       [ set color bacteria2-default-color ]
   ]
   ask flagella2 [
     set hidden? member? visualize-variation2 ["as color only" "# flagella2 as label" "none"]
   ]
 
 end