nobots

nobots preview image

1 collaborator

Moi Yassine Chaouche (Author)

Tags

game 

Tagged by Yassine Chaouche over 10 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.1 • Viewed 399 times • Downloaded 28 times • Run 0 times
Download the 'nobots' 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

extensions [sound]
breed [humans human]
breed [robots robot]
turtles-own [dead]
globals [  thehuman door-closed? level entrance starty ]

to setup
  clear-patches
  set level 0
  set nb-robots 0
  set entrance []
  setup-level
  ask patches with [count neighbors != 8] [set pcolor white]
end 

to setup-level
  clear-turtles
  create_player
  create_ennemies
  ask turtles [set dead false]
  set door-closed? true
  foreach entrance [ask ? [set pcolor  black]]  
end 

to create_player
  create-humans 1 
  [
    set shape "person" 
    set color white 
    set size 2 
    set thehuman self
    ;setxy xcor oldy
  ]
end 

to create_ennemies
  create-robots nb-robots 
  [
    set shape "turtle" 
    setxy (max-pxcor - 1 - random 10)random-ycor 
    set color white 
    set size 2
  ]
end 

to load-levelmap
  let levelbackup level
  let entrancebackup entrance
  if level != 0 
  [
    run (word "import-world \"maps/nobots_map" level  ".csv\"")
  ]
  set level levelbackup
  set entrance entrancebackup
end 

to go [direction]

  go-human direction 
  go-robots
  
  if not any? robots with [dead = false]
  [
    if door-closed? [
      open-door
      set door-closed? false
      ]
  ]
end 

to go-human [direction]
  ask thehuman
  [
    ifelse any? robots-here with [dead = false] 
    [become-dead]
    [
      if direction != 0   ; if direction = 0 that means stay where you are. To go up, use 360.
      [ set heading direction
        if not ([pcolor] of patch-ahead 1 = white )[fd 1]
      ]
    ]
  ]
  if human-died? [
    let oldy starty
    wait 1
    setup-level
    set starty oldy
    ask thehuman [
      show (word "my new ycor will be " starty)
      setxy min-pxcor starty
    ]
  ]
  
  ; this is only possible if thehuman reaches the entrance
  if [pxcor] of thehuman = max-pxcor [
    let oldy ([ycor] of thehuman)
    show (word "old coordinates " [xcor] of thehuman " " [ycor] of thehuman)
    level-up
    setup-level
    set starty oldy
    ask thehuman 
    [
      setxy min-pxcor starty
      show (word "new coordinates " xcor " " ycor)
    ]
  ]
end 

to go-robots
  ask robots with [dead = false] 
  [   
    face thehuman 
    fd 1
    if (any? other robots-here) or (pcolor = white) [become-dead]
  ]
end 

to-report human-died?
  report [dead] of thehuman = true
end 

to become-dead
  set shape "x"
  set dead true
  sound:play-sound "audio/test.wav"
end 

to level-up
  sound:play-sound "audio/ghost.wav"  
  set nb-robots nb-robots + 3
  show (word "level was " level)
  set level (level + 1)
  show (word "level is now " level)
  load-levelmap
end 

to open-door
  sound:play-sound "audio/info.wav"
  set entrance []
  ask one-of patches with [(pxcor = max-pxcor) and (pycor > min-pycor + 5) and (pycor < max-pycor - 5)]
  [
    set entrance lput (patch min-pxcor [pycor] of self) entrance
    set pcolor black
    foreach [1 2 3 4 5]
    [
      let thepatch patch-at 0 ?
      ask thepatch [set pcolor black]
      set entrance lput (patch min-pxcor [pycor] of thepatch) entrance
    ]
  ]
end 

to go-up 
  go 360
end 

to go-upright
  go 45
end 

to go-right
  go 90
end 

to go-downright
  go 135
end 

to go-down
  go 180
end 

to go-downleft
  go 225
end 

to go-left
  go 270
end 

to go-upleft
  go 315
end 

to draw-obstacles
  draw white
end 

to remove-obstacles
  draw black
end 

to draw [thecolor]
    if mouse-down?
  [
    ask patch mouse-xcor mouse-ycor
    [ set pcolor thecolor]
  ]    
end 

There is only one version of this model, created about 11 years ago by Yassine Chaouche.

Attached files

File Type Description Last updated
nobots.png preview preview over 10 years ago, by Yassine Chaouche Download
nobots_map1.csv data first map over 10 years ago, by Yassine Chaouche Download
nobots_map2.csv data second map over 10 years ago, by Yassine Chaouche Download
nobots_map3.csv data Third map over 10 years ago, by Yassine Chaouche Download
nobots_map4.csv data fourth map over 10 years ago, by Yassine Chaouche Download
nobots_map_edtor.nlogo extension Map editor over 10 years ago, by Yassine Chaouche Download

This model does not have any ancestors.

This model does not have any descendants.