Vowel Shift

Vowel Shift preview image

1 collaborator

Default-person Jessica Hughes (Author)

Tags

linguistics 

Tagged by Jessica Hughes over 10 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.3 • Viewed 293 times • Downloaded 17 times • Run 0 times
Download the 'Vowel Shift' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

; Vowel Shift Model
; designed by Jessica Hughes
; as a final Masters project for GMU MAIS-CSS, Fall 2013

; CODE TABLE OF CONTENTS:
;1. Initializing Variables and Breeds
;2. Setup
;3. Go Procedures 
;4. Utilities
;5. Run Tests
;6. Follow One Agent


;=====================================
;1. INITIALIZING VARIABLES AND BREEDS
;=====================================
globals [num-tick   ; each simulation run has one global clock and set of global averages overall and for each breed
  avg-vowel1
  avg-vowel2
  avg-green-vowel1
  avg-green-vowel2
  avg-red-vowel1
  avg-red-vowel2
  starting-avg-green-vowel1
  starting-avg-green-vowel2
  starting-avg-red-vowel1
  starting-avg-red-vowel2
  change-avg-green-vowel1
  change-avg-green-vowel2
  change-avg-red-vowel1
  change-avg-red-vowel2
  ]

turtles-own [  ; each turtle has its own vowel (changes during run), partner (also changes), memories of vowels heard,
               ; break-point between the vowels, and speed to move around at
  vowel1  ; This is not the prototype, this is the next vowel sound to be spoken based on memory
  vowel2
  avg-own-vowel1  ; This is the prototype vowel for a given turtle
  avg-own-vowel2
  partner
  vowel1-memory
  vowel2-memory
  vowel-break-point
  move-speed
  observation
  explanation1
  explanation2
  explanation3
]

breed [reds redd]      ; establish two breeds: reds and greens
breed [greens greenn]

;=========
;2. SETUP
;=========

to setup
  clear-all
  ask n-of num-turtles patches [sprout 1]    ; decide how many turtles to sprout based on input slider
  ask turtles [
    identify-breed      ; set turtles on the left as reds, and on the right as greens
    first-memory        ; set their starting memories of Vowel 1 based on their breed (vowel 2 is the same for both breeds)
    set move-speed random 2 + 1   ; each turtle is given a speed from "birth"
  ]
  do-utils              ; set initial averages for plots
  starting-utils        ; record initial averages for determining change
  do-plots              ; show averages on plots
  ask turtles [shade-color]
  reset-ticks           ; set ticks back to 0
end 

to identify-breed  ; set turtles on the left as reds, and on the right as greens. color accordingly.
  ifelse xcor > 0
    [set breed greens
     set color green]
    [set breed reds
      set color red]
end 

to first-memory
; VOWEL1
  ifelse breed = greens
   [set vowel1 round random-normal 2 1]     ; set greens' vowel1 a random integer between ~0 and 4
   [set vowel1 round random-normal 7 1]     ; set reds' vowel1 a random integer between ~5 and 9
  set vowel1-memory list [vowel1] of self [vowel1] of self  ; fill each turtle's memory with 10x this vowel
  repeat 8 [set vowel1-memory fput vowel1 vowel1-memory]
; VOWEL2
  set vowel2 round random-normal 9 1     ; set all turtles' vowel2 a random integer between ~8 and 12
  set vowel2-memory list [vowel2] of self [vowel2] of self  ; fill each turtle's memory with 10x this vowel
  repeat 8 [set vowel2-memory fput vowel2 vowel2-memory] 
end 

;=================
;3. GO PROCEDURES
;=================

to step
  ifelse homing-beacon? = true [move-turtles-beacon] [move-turtles] ; turtle moves according to own speed and beaconing
  ask turtles [
    set partner one-of other turtles in-radius conv-radius
    listen-neighbor
    pick-vowel-example
    shade-color
  ]
  do-utils
  second-utils
  do-plots
  set num-tick num-tick + 1
end 

to go
  ifelse standard-deviation [vowel1] of turtles > 0.7   ; keep going until the two communities' vowel 1's have merged.
    [step]
    [stop]
end 

to fast-fwd
  repeat 10 [step]
end 

to listen-neighbor
if (partner != nobody ) [                                         ; if there is someone else within conversation-radius,
;    ifelse random 2 = 1                                               
      ifelse random-normal [vowel1] of partner 0.5 > [vowel-break-point] of self    ; listen to partner's instantiation of vowel1
        [set vowel2-memory fput round [vowel1] of partner vowel2-memory  ; if it's higher than your vowel-break-point
         set vowel2-memory but-last vowel2-memory]                 ; remember it as an instance of vowel2 and trim earliest memory
        [set vowel1-memory fput round [vowel1] of partner vowel1-memory  ; if it's not higher than your vowel-break-point,
         set vowel1-memory but-last vowel1-memory]                 ; remember it as an instance of vowel1 (as intended) and trim earliest memory
      
 ;     [ifelse random-normal [vowel2] of partner 0.5 < [vowel-break-point] of self ; This code, plus the line commented out above,
  ;      [set vowel1-memory fput round [vowel2] of partner vowel1-memory           ; would allow turtles to listen to each others'
   ;      set vowel1-memory but-last vowel1-memory]                                ; vowel 2's as well. However, the desired behavior
    ;    [set vowel2-memory fput round [vowel2] of partner vowel2-memory           ; does not emerge under those conditions (see paper)
     ;    set vowel2-memory but-last vowel2-memory]     
     ; ]
]
end 

to pick-vowel-example
  set vowel1 one-of vowel1-memory                 ; pick a new example vowel1 based on average memory
  set vowel2 one-of vowel2-memory                 ; pick a new example vowel2 based on average memory
end 

;=============
;4. UTILITIES
;=============

to shade-color
; Color by vowel1:  NEED TO FIX THIS LATER
  ifelse breed = greens
  [set color scale-color [color] of self avg-own-vowel1 5 0]
  [set color scale-color [color] of self avg-own-vowel1 10 0]
end 

to move-turtles          ; each turtle moves in a random direction at its own speed
  ask turtles [right random 360
  forward [move-speed] of self]
end 

to move-turtles-beacon       ; if turtles far too far outside their home area, they should turn back toward home and move that way
  ask greens
    [if xcor >= -4 [ right random 360 forward [move-speed] of self]
     if xcor < -4 [facexy 16 8 forward [move-speed] of self] ]
  ask reds
    [if xcor <= 4 [ right random 360 forward [move-speed] of self]
     if xcor > 4 [facexy 0 8 forward [move-speed] of self] ]
end 

to do-utils
  ask turtles [set avg-own-vowel1 mean vowel1-memory
               set avg-own-vowel2 mean vowel2-memory
               set vowel-break-point (avg-own-vowel1 + avg-own-vowel2) / 2 ]  ; recalculate the break point between the two vowels]
  set avg-vowel1 mean [avg-own-vowel1] of turtles
  set avg-vowel2 mean [avg-own-vowel2] of turtles
  set avg-green-vowel1 mean [avg-own-vowel1] of greens
  set avg-green-vowel2 mean [avg-own-vowel2] of greens
  set avg-red-vowel1 mean [avg-own-vowel1] of reds
  set avg-red-vowel2 mean [avg-own-vowel2] of reds
;  set std-vowel1 standard-deviation [vowel1] of turtles
end 

to starting-utils                                     ; after initial util run, this procedure records the starting values for analysis
  set starting-avg-green-vowel1 avg-green-vowel1
  set starting-avg-green-vowel2 avg-green-vowel2
  set starting-avg-red-vowel1 avg-red-vowel1
  set starting-avg-red-vowel2 avg-red-vowel2
end 

to second-utils                 ; this are in a separate procedure because they require starting-utils (which only runs once)
  set change-avg-green-vowel1 (avg-green-vowel1 - starting-avg-green-vowel1)              ; and do-utils (which runs every step)
  set change-avg-green-vowel2 (avg-green-vowel2 - starting-avg-green-vowel2)
  set change-avg-red-vowel1 (avg-red-vowel1 - starting-avg-red-vowel1)
  set change-avg-red-vowel2 (avg-red-vowel2 - starting-avg-red-vowel2)
end 

to do-plots
  set-current-plot "Vowel1 distro"     ; histogram
  set-current-plot-pen "value"
  histogram [vowel1] of turtles

  set-current-plot "Vowel2 distro"     ; histogram
  set-current-plot-pen "value"
  histogram [vowel2] of turtles

  set-current-plot "vowels-over-time"     ; plot
  set-current-plot-pen "green-vowel1"
  plot avg-green-vowel1
  set-current-plot-pen "green-vowel2"
  plot avg-green-vowel2
  set-current-plot-pen "red-vowel1"
  plot avg-red-vowel1
  set-current-plot-pen "red-vowel2"
  plot avg-red-vowel2
end 

;=============
;5. RUN TESTS
;=============

to runTests
  let numReps 10        ; <-- number of repetitions of test per variable combination
  let maxSteps 3000   ; <-- number of steps to run per test
  let conv-radiusList (list 1 2 3) ; <-- list conv-radius values to test here 
  let num-turtlesList (list 30 50 70 90) ; <-- list num-turtles values to test here
  set homing-beacon? false  ; <-- will test be with homing beacon?
  
  let a 0
  let b 0
  let i 0
  let rs 1
  set rs 1
  
  let file user-new-file
  if file-exists? file 
    [print "file exists"
     stop ]
  file-open file
  
  file-print "Vowel Shift: Parameter Sweep"
  file-type "Homing beacon? " file-print homing-beacon?
  file-type "conv-radius " file-print conv-radiusList
  file-type "num-turtles " file-print num-turtlesList

  file-print "trial,tick,conv-radius,num-turtles,start-green1,change-green1,start-green2,change-green2,start-red1,change-red1,start-red2,change-red2"
  
  ;data to print as csv:
  foreach conv-radiusList[
    set a ?
    set conv-radius a
     
    foreach num-turtlesList[
      set b ?
      set num-turtles b
       
          set i 0
          set rs 1
          while [i < numReps] [
            random-seed rs
            setup
            while [standard-deviation [vowel1] of turtles > 0.7] [step]
            set i (i + 1)
            set rs (rs + 1)
                        
            file-type i file-type "," file-type num-tick file-type "," 
            file-type a file-type "," file-type b file-type "," 
             file-type avg-green-vowel1 file-type "," file-type change-avg-green-vowel1 file-type "," 
            file-type avg-green-vowel2 file-type "," file-type change-avg-green-vowel2 file-type ","
             file-type avg-red-vowel1 file-type "," file-type change-avg-red-vowel1 file-type "," 
            file-type avg-red-vowel2 file-type "," file-print change-avg-red-vowel2
        
      ]
    ]
  ]
  
  file-print " "
  file-close
end 


;===================
;6. FOLLOW ONE AGENT
;===================

to followAgent
  let maxSteps 1000   ; <-- number of steps to run per test (will stop early if greens' and reds' vowel1s have merged)
  
  ; select settings for follow-agent test
  set conv-radius 2 
  set num-turtles 70
  set homing-beacon? true

  ; set up model run according to those settings  
  setup
  
  ; choose a red border agent to follow
  let pick-agent one-of reds with [xcor > -5]
  set pick-agent pick-agent

  let file user-new-file
  if file-exists? file 
    [print "file exists"
     stop ]
  file-open file
  
  file-print "Vowel Shift: Conversations of an Agent"
  file-type "Homing beacon? " file-print homing-beacon?
  file-type "conv-radius " file-print conv-radius
  file-type "num-turtles " file-print num-turtles
  file-type "agent number " file-print pick-agent
;;  file-type "starting sentiment " file-print [starting-sentiment] of pick-agent
    
  ;column headers:
;;  file-print "step,observation,first,therefore,and-then,conflict-narrative,alt-narr,gap,sentiment"

  ;data to print as csv:
  while [standard-deviation [vowel1] of turtles > 0.7]
    [
    step
    file-type num-tick file-type ", " 
    file-type [observation] of pick-agent file-type "," 
    file-type [explanation1] of pick-agent file-type "," 
    file-type [explanation2] of pick-agent file-type "," 
    file-type [explanation3] of pick-agent file-type "," 
    file-type [vowel1] of pick-agent file-type "," 
    file-type [vowel2] of pick-agent file-type "," 
    file-type [avg-own-vowel1] of pick-agent file-type ","
    file-type [avg-own-vowel2] of pick-agent file-print "," 
    if (num-tick > maxSteps) [file-close stop] 
    ]
  file-close
end 

There is only one version of this model, created over 10 years ago by Jessica Hughes.

Attached files

File Type Description Last updated
Vowel Shift.png preview Preview for 'Vowel Shift' over 10 years ago, by Jessica Hughes Download

This model does not have any ancestors.

This model does not have any descendants.