letters

No preview image

1 collaborator

Default-person Abdullah yousaf (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.2 • Viewed 95 times • Downloaded 14 times • Run 0 times
Download the 'letters' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

globals
[
  text
  left-edge
  right-edge
]
breed[abdullah abdullahize]

turtles-own
[
  word-length
  num-word
  leader
  new-line?
]

to setup
  clear-all
  setup-tabels
  set text (word "Abdullah "

                "Abdullah yousaf "
                "Abdullah yousaf")
  create-abdullah 30
  [
    set word-length 0
    set leader nobody
    set new-line? false
    scatter
  ]
  setupname
  reset-ticks
end 

to scatter
  setxy random-xcor random-ycor
end 

to setup-tabels
  ask patches [ set pcolor  red]
end 

to setupname
  let remaining-text text
  let word-count 1

  let prev-letter nobody

  ask turtles
  [
    set label first remaining-text
    set leader prev-letter
    set num-word word-count
    if label = " "
    [
      set word-count word-count + 2
      set num-word num-word + 1
    ]
    set remaining-text but-first remaining-text
    set prev-letter self
  ]

  let index 1
  repeat word-count
  [
    let turtles-in-word turtles with [num-word = index]
    ask turtles-in-word
      [ set word-length count turtles-in-word ]
    set index index + 1
  ]
end 

to go
  ask abdullah
  [
    set new-line? false
    pick-heading
    ifelse trap?
      [ move-to patch-here ]
      [ fd 0.5 ]
  ]
  tick
end 

to pick-heading
  ifelse leader = nobody

    [ face patch left-edge max-pycor ]
    [
      let p [patch-at 1 0] of leader
      if p != nobody
      [ face p ]
      if right-edge - left-edge < word-length
      [

        if [pxcor] of leader >= right-edge
        [
          set new-line? true
          face patch left-edge new-line-pycor

        ]
      ]

  ]
end 

to-report new-line-pycor
  ifelse abs ([pycor] of leader - 2) > max-pycor
    [ report [pycor] of leader ]
    [ report [pycor] of leader - 2 ]
end 

to-report trap?
  if leader = nobody
    [ report (pxcor = left-edge) and (pycor = max-pycor) ]
  ifelse new-line?
    [ report (pxcor = left-edge) and (pycor = new-line-pycor) ]

    [ report patch-at -1 0 = [patch-here] of leader ]
end 

There is only one version of this model, created almost 6 years ago by Abdullah yousaf.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.