Frogger Simple Reflect Agent

Frogger Simple Reflect Agent preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0RC1 • Viewed 417 times • Downloaded 26 times • Run 0 times
Download the 'Frogger Simple Reflect Agent' modelDownload this modelEmbed this model

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


## ## ## WHAT IS IT?

This is application of Simple Reflect Agent. This is my homework for the 5 th semester in Jurusan Teknik Informatika UIN Maulana Malik Ibrahim Malang Indonesia. http://uin-malang.ac.id/ this is one the real frog in middle with white color. other frog is sensor. frog around the white frog simulating when the real frog(white) at the same place. is life or dead ? if life frog can move there. if dead frog can move there and find other place that save. it simulate a Simple Reflect Agent move to the save place. I know this is far from perfect. but it nice to play with NetLogo. I hope we can discus it :-) http://tarecha.wordpress.com/ http://facebook.com/tarecha agung.tarecha@gmail.com

Best Regards,

Mochamad Agung Tarecha Malang Indonesia

FYI : My other friend also have a same task, but with different algorithm, different game, different way.... I hope they also share their idea ^_^

This model is based on the classic arcade game, Frogger. The object of the game is to get the frog, found at the bottom of the view, across the traffic and river to a safe lily pad on the other side.

## ## ## HOW IT WORKS

There are two main obstacles to overcome, the road and the river. The road has cars and trucks moving at various speeds that are liable to run over the frog. Once you have crossed the road safely, you must overcome the danger lurking in the river. Unfortunately, you will die if you jump in the river, so you must keep moving towards the lily pads by jumping on the logs or sets of turtles moving back and forth in the river's current.

You must also avoid getting pushed off the edge by a log or turtle. In addition, in the later levels, some of the turtles will dive under water -- if you happen to be standing on them you will drown! Finally, you must also get across the board before the allotted amount of time runs out.

## ## ## HOW TO USE IT

Buttons

  • NEW-GAME resets the game

  • START starts the game

  • The direction buttons (UP, DOWN, LEFT, RIGHT) will move your frog in that direction

Monitors

  • FROGS LEFT tells you how many remaining lives you have

  • LEVEL monitors the current level you are playing

  • TIME LEFT shows you how much time remains

  • FROG JUMPS tells you how many jumps you has taken

Sliders

  • START-LIVES will determine how many lives you will start with

  • START-TIME sets how much time you start out with

  • START-LEVEL is used to determine which level you will start on

Cast of characters:

  • Green frog: This is you.

  • Truck: Avoid at all costs. They are usually pretty slow.

  • Car: Avoid at all costs. They are usually fast.

  • Brown squares: This is a log. You need to jump onto these to get across the river.

  • Turtle: You need to jump onto these. Avoid ones that dive.

  • Green circles: These are lily pads. You want to get on these to win the level.

  • Blue squares: This is the river. You can't land on this.

  • Gray squares: This is the road. You can jump on this, but watch out for vehicles.

  • Green Patches: This is grass. You are pretty safe here.

## ## ## THINGS TO TRY

See if you can get through all of the levels.

Try to beat your previous time.

Try to make as few jumps as possible in the time allotted.

Try to use as few lives as possible.

## ## ## THINGS TO NOTICE

Determine how many jumps it would take to get across the board without obstacles.

Determine how many jumps it would take to get across the board with obstacles.

How does each of the two questions above relate to the time it takes you to complete a level?

If you take just as many jumps with obstacles as without, why does it take different durations of time to get across?

## ## ## EXTENDING THE MODEL

Write your own levels by altering the code in the Code tab.

Add some bonuses or additional hazards.

Implement a scoring system.

Write a robot script that will move your frog automatically.

## ## ## NETLOGO FEATURES

This model uses breeds to implement the different moving game pieces.

The every command is used to control the speed of the game.

The user-message command presents messages to the user.

mouse-down?, mouse-xcor, and mouse-ycor are used to detect and handle mouse clicks.

## ## ## HOW TO CITE

If you mention this model in an academic publication, we ask that you include these citations for the model itself and for the NetLogo software:

In other publications, please use:

## ## ## COPYRIGHT NOTICE

Copyright 2002 Uri Wilensky. All rights reserved.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:

a) this copyright notice is included.

b) this model will not be redistributed for profit without permission from Uri Wilensky. Contact Uri Wilensky for appropriate licenses for redistribution for profit.

This model was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

Comments and Questions

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

Click to Run Model

;This is application of Simple Reflect Agent. 
;This is my homework for the 5 th semester in 
;Jurusan Teknik Informatika UIN Maulana Malik Ibrahim Malang Indonesia. http://uin-malang.ac.id/ 
;this is one the real frog in middle with white color. 
;other frog is sensor. frog around the white frog simulating when the real frog(white) at the same place.
; is life or dead ? if life frog can move there. if dead frog can move there and find other place that save. 
;it simulate a Simple Reflect Agent move to the save place.
; I know this is far from perfect. but it nice to play with NetLogo. 
;I hope we can discus it :-) 
;http://tarecha.wordpress.com/ 
;http://facebook.com/tarecha agung.tarecha@gmail.com
;Best Regards,
;Mochamad Agung Tarecha Malang Indonesia

;Mochamad Agung Tarecha
;09650135
;agung.tarecha@gmail.com
extensions [ sound ]

breed [ trucks truck ]
breed [ cars car ]
breed [ logs a-log ]
breed [ river-turtles river-turtle ]
breed [ pads pad ]
breed [ frogs frog ] ;; These are all the game pieces.
breed [ frogs2 frog ]
breed [ frogs3 frog ]
breed [ frogs4 frog ]
breed [ frogs5 frog ]
breed [ frogs6 frog ]
breed [ frogs7 frog ]
breed [ frogs8 frog ]
breed [ frogs9 frog ]

;;;;;;;;;;;;;;;
;; Variables ;;
;;;;;;;;;;;;;;;

globals [
  action            ;; Last button pressed. Prevent the player from moving the frog until the
                    ;; the game is running.  Checks the status of this button every loop.
  dead?             ;; True when no frog lives are left - used to stop the game
  lives             ;; Remaining lives
  level             ;; Current level
  jumps             ;; Current number of jumps
  time-left         ;; Time remaining
  pads-done         ;; Number of frogs that have successfully reached the pads
  
]

;; In NetLogo, all the breeds are "turtles".  This can be confusing because
;; there are also "turtles" in the game of Frogger -- they swim in the river.
;; To avoid confusion, we call those turtles "river-turtles".

turtles-own [
  speed            ;; The 'time' variable will be initialized to the value of 'speed' after the turtle moves
  time             ;; This keeps track of how many time loops have occurred since the turtle last moved.
                   ;; It actually counts down from 'speed' to zero.  Once it reaches zero, the turtle
                   ;; moves forward one space
]

river-turtles-own [
  dive?            ;; True when the turtle dives
]

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

to startup            ;; Setup is the 'New Game' button, this will setup the game.
  setup
end 

to setup              ;; Initializes the game
  ;; (for this model to work with NetLogo's new plotting features,
  ;; __clear-all-and-reset-ticks should be replaced with clear-all at
  ;; the beginning of your setup procedure and reset-ticks at the end
  ;; of the procedure.)
 ; __clear-all-and-reset-ticks
  set action 0
  set dead? false
  set lives start-lives
  set-default-shape frogs "frog"
  set-default-shape frogs2 "frog"
  set-default-shape frogs3 "frog"
  set-default-shape frogs4 "frog"
  set-default-shape frogs5 "frog"
  set-default-shape frogs6 "frog"
  set-default-shape frogs7 "frog"
  set-default-shape frogs8 "frog"
  set-default-shape frogs9 "frog"
  
  set-default-shape cars "car"
  set-default-shape logs "log"
  set-default-shape river-turtles "turtle"
  set level start-level
  next-level
end 

to next-level        ;; This will call the appropriate level procedure, where the level is created
  draw-map
  
  if ( level = 1 )
    [ level-1 ]
  if ( level = 2 )
    [ level-2 ]
  if ( level = 3 )
    [ level-3 ]
  if ( level = 4 )
    [ level-4 ]
  if ( level = 5 )
    [ level-5 ]
  if ( level = 6 )
    [ user-message "Actually, that was the last level.\nPerhaps you should program some more :-)"
      set dead? true]
end 

;; This will color the patches to make the grass, road, and river, and creates the frog.
;; The second line causes the grass to be various similar shades of green so it looks
;; more like real grass.

to draw-map
  cp ct
  ask patches
    [ set pcolor scale-color green ((random 500) + 5000) 0 9000 ]
  setup-pads
  ask patches with [pycor <= max-pycor and pycor >= 3]
    [ set pcolor blue ]
  ask patches with [pycor <= -1 and pycor >= -5]
    [ set pcolor gray ]
  set pads-done 0
  create-frogs 1
    [ set color 9.9
      reset-frog
    ]
    create-frogs2 1
    [ set color 2
      reset-frog2
    ]
     create-frogs3 1
    [ set color 12
      reset-frog3
    ]
      create-frogs4 1
    [ set color 22
      reset-frog4
    ]
       create-frogs5 1
    [ set color 32
      reset-frog5
    ]
       create-frogs6 1
    [ set color 42
      reset-frog6
    ]
       create-frogs7 1
    [ set color 62
      reset-frog7
    ]
       create-frogs8 1
    [ set color 72
    
    reset-frog8
    ]
    create-frogs9 1
    [ set color 82
      reset-frog9
    ]
end 

;; Initializes the frog by setting it to the right patch and facing the right direction

to reset-frog
  ask frogs
  [
    setxy 0 -7
    set heading 0
    set jumps 0
    set time-left start-time
  ]
end 

to reset-frog2
  ask frogs2
  [
    setxy 0 -6
    set heading 0
    set jumps 1
    set time-left start-time
  ]
end 

to reset-frog3
  ask frogs3
  [
    setxy 1 -6
    set heading 0
    set jumps 0
    set time-left start-time
  ]
end 

to reset-frog4
  ask frogs4
  [
  setxy -1 -6
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 

to reset-frog5
  ask frogs5
  [
  setxy 1 -7
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 

to reset-frog6
  ask frogs6
  [
  setxy -1 -7
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 

to reset-frog7
  ask frogs7
  [
  setxy 1 -8
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 

to reset-frog8
  ask frogs8
  [
  setxy 0 -8
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 

to reset-frog9
  ask frogs9
  [
  setxy -1 -8
  set heading 0
  set jumps 0
  set time-left start-time
  ]
end 
;; Creates the five pads equally spaced at the top of the board.
;; The second line uses the modulus operation to determine which x-cor
;; is divisible by three.  This is an easy way to have a pad created every
;; three patches.

to setup-pads
  set-default-shape pads "pad"
  ask patches with [pycor = max-pycor and pxcor mod 4 = 0]
    [ sprout-pads 1 ]
end 

to create-truck [ x y direction quickness ]   ;; Creates and initializes a truck
  let truckColor (random 13 + 1) * 10 + 3
  ask patches with [(pxcor = x or pxcor = (x + 1)) and pycor = y]
    [ sprout-trucks 1
        [ set color truckColor
          set heading direction
          set speed quickness
          set time speed
          ifelse ((pxcor = x) xor (direction = 90))
            [ set shape "truck" ]
            [ set shape "truck rear" ]
        ]
    ]
end 

to create-car [x y direction quickness]     ;; Creates and initializes a car
  create-cars 1
    [ set color (random 13 + 1) * 10 + 3
      setxy x y
      set heading direction
      set speed quickness
      set time speed
    ]
end 

;; Creates and initializes a log.

to create-log [x y leng quickness]
  ask patches with [pycor = y and pxcor >= x and pxcor < (x + leng)]
    [ sprout-logs 1
        [ set color brown
          set heading 90
          set speed quickness
          set time speed
        ]
    ]
end 

to create-river-turtle [x y leng quickness]    ;; Creates and initializes a river-turtle
  ask patches with [pycor = y and pxcor >= x and pxcor < (x + leng)]
    [ sprout-river-turtles 1
        [ set heading 270
          set speed quickness
          set time speed
          set color 54
          set dive? false
        ]
    ]
end 

to make-river-turtle-dive [num]    ;; Causes a random river-turtle(s) to dive underwater.
  repeat num
    [ ask one-of river-turtles with [not dive?]
        [ set dive? true ]
    ]
end 


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

to go            ;; The main procedure
  if dead?
    [ stop ]
  move
  gofrog
end 

;; This is the time loop: every 0.1 seconds it decrements every turtle's 'time'
;; variable and check to see if it should move (when it reaches zero).  It then will
;; reset the 'time' if it is zero.  The logs and river-turtles need their own special
;; procedure to move since they "carry" the frog with them.

to move
  move-frog
  every 0.1
    [ ask turtles
        [ decrement-time ]
      ask turtles with [time = 0.0 and breed != frogs]
        [ set time speed
          ifelse (breed = logs)
            [ move-log ]
            [ ifelse (breed = river-turtles)
                [ move-river-turtle ]
                [ fd 1 ]
            ]
        ]
      check-frog
    ]
  display
end 

to gofrog
 
 
 ask frogs2[
  ;  ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
   ;      ((pcolor = blue) and
    ;      (count pads-here = 0) and
     ;     (count logs-here = 0) and
      ;    (count river-turtles-here with [not hidden?] = 0)))
       ;   [ ]
        ;  [ 
 ;           move-up2
  ;          move-up3
   ;         move-up4          
    ;      ]
        
           
ask frogs[
     if any? pads-here with [shape = "pad"]
        [ sound:play-drum "CRASH CYMBAL 2" 97
          ask pads-here
            [ set shape "frog"
              set heading 0
              set color 9.9
              set pads-done (pads-done + 1)
            ]
          reset-frog
          reset-frog2
          reset-frog3
          reset-frog4
          reset-frog5
          reset-frog6
          reset-frog7
          reset-frog8
          reset-frog9
          
        ]
]
      
      ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
        (any? pads-here with [shape = "frog"])  or
         ((pcolor = blue) and
          (count pads-here = 0) and
          (count logs-here = 0) and
          (count river-turtles-here with [not hidden?] = 0)))
        [ 
          
          ask frogs5
          [
            ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
              ((pcolor = blue) and
                (count pads-here = 0) and
                (count logs-here = 0) and
                (count river-turtles-here with [not hidden?] = 0)))
            [
              move-left
              move-left2
              move-left3
              move-left4
              move-left5
              move-left6
              move-left7
              move-left8
              move-left9
            ];mati
            [];hidup
          ]
          
          ask frogs6
          [
            ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
              ((pcolor = blue) and
                (count pads-here = 0) and
                (count logs-here = 0) and
                (count river-turtles-here with [not hidden?] = 0)))
            [
              move-right
              move-right2
              move-right3
              move-right4
              move-right5
              move-right6
              move-right7
              move-right8
              move-right9
            ];mati
            [];hidup
          ]
          
          
        ]
           [   
            
             move-up
             move-up2
             move-up3
             move-up4
             move-up5
             move-up6
             move-up7
             move-up8
             move-up9
             
             ask frogs5
          [
            ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
              ((pcolor = blue) and
                (count pads-here = 0) and
                (count logs-here = 0) and
                (count river-turtles-here with [not hidden?] = 0)))
            [
              move-left
              move-left2
              move-left3
              move-left4
              move-left5
              move-left6
              move-left7
              move-left8
              move-left9
            ];mati
            [];hidup
          ]
          
          ask frogs6
          [
            ifelse ((any? trucks-here ) or (any? cars-here) or (time-left <= 0) or
              ((pcolor = blue) and
                (count pads-here = 0) and
                (count logs-here = 0) and
                (count river-turtles-here with [not hidden?] = 0)))
            [
              move-right
              move-right2
              move-right3
              move-right4
              move-right5
              move-right6
              move-right7
              move-right8
              move-right9
            ];mati
            [];hidup
          ]
          
          
          
             
           ]
  ]
end 

;; This will decrement the 'time' for all non-frogs and it will decrement the 'time-left'
;; global variable.  The precision function is needed to verify there is only one decimal
;; place on the time variables.

to decrement-time
  ifelse (breed = frogs)
    [ set time-left precision (time-left - 0.1) 1 ]
    [ set time precision (time - 0.1) 1 ]
end 

;;  Every time loop, we need to see what the frog's status is (dead, on a pad, etc..)
;;  First it will need to see if it is on a pad and make sure there are no other frogs there
;;  (by checking the shape of the the pad).  Then you need to check to see if the frog is in
;;  a space where he should die.  Finally, it checks to see if the level is complete.

to check-frog
  ask frogs
    [ if any? pads-here with [shape = "pad"]
        [ sound:play-drum "CRASH CYMBAL 2" 97
          ask pads-here
            [ set shape "frog"
              set heading 0
              set color 9.9
              set pads-done (pads-done + 1)
            ]
          reset-frog
         
          reset-frog2
          reset-frog3
          reset-frog4
          reset-frog5
          reset-frog6
          reset-frog7
          reset-frog8
          reset-frog9
          
        
        ]
      if ((any? trucks-here) or (any? cars-here) or (time-left <= 0) or
         ((pcolor = blue) and
          (count pads-here = 0) and
          (count logs-here = 0) and
          (count river-turtles-here with [not hidden?] = 0)))
        [ kill-frog 
          ;reset-frog2
          ;reset-frog3
         ; reset-frog4
        ]
        
    ]
  if ( pads-done = 5 )
    [ set level (level + 1)
      set pads-done 0
      user-message (word "Congrats, all your frogs are safe!\nOn to level " level "...")
      next-level
      setup-pads
    ]
end 

to kill-frog        ;; This is called when the frog dies, checks if the game is over
  set lives (lives - 1)
  ifelse (lives = 0)
    [ user-message "Your frog died!\nYou have no more frogs!\nGAME OVER!"
      set dead? true
      die
    ]
    [ user-message (word "Your frog died!\nYou have " lives " frogs left.")
      reset-frog
      reset-frog2
      reset-frog3
      reset-frog4
       reset-frog5
          reset-frog6
          reset-frog7
          reset-frog8
          reset-frog9
    ]
end 

;; This is a special procedure to move a log.  It needs to move any frogs that
;; are on top of it.
;; tempat jejak katak

to move-log
  ask frogs-here
    [ if (pxcor != max-pxcor)
        [ set xcor xcor + 1
          
             ;; patches on the right side
        
        ]
         ask frogs2
        [ set xcor xcor + 1]
        
        ask frogs3
        [ set xcor xcor + 1]
        ask frogs4
        [ set xcor xcor + 1]
        ask frogs5
        [ set xcor xcor + 1]
        ask frogs6
        [ set xcor xcor + 1]
        ask frogs7
        [ set xcor xcor + 1]
        ask frogs8
        [ set xcor xcor + 1]
        ask frogs9
        [ set xcor xcor + 1]
    ]
  fd 1
end 

;; This is a special procedure to move the river-turtles.  It needs to move any frogs that
;; are on top of it.

to move-river-turtle
  fd 1
  ask frogs-at 1 0
    [ set xcor xcor - 1
      if (xcor = max-pxcor)
        [ set xcor xcor - 1 ]
        
        ask frogs2
         [set xcor xcor - 1]
        
        ask frogs3
            [set xcor xcor - 1]
        ask frogs4
              [set xcor xcor - 1]
        ask frogs5
              [set xcor xcor - 1]
        ask frogs6
             [set xcor xcor - 1]
        ask frogs7
             [set xcor xcor - 1]
        ask frogs8
                [set xcor xcor - 1]
        ask frogs9
                [set xcor xcor - 1]
    ]
  dive-river-turtle
end 

;; If a river-turtle has been instructed to dive, this procedure will implement that.
;; It will also cause it to splash and rise back up.  It uses a random numbers to
;; determine when it should dive and rise back up.  Theoritically, it will dive about
;; every eighth move and stay down for about five moves, but this isn't always the case
;; (the randomness is added for increasing the challenge of the game)

to dive-river-turtle
  if dive?
    [ ifelse (hidden? and random 5 = 1)
        [ show-turtle ]
        [ if ( shape = "splash" )
            [ set shape "turtle"
              hide-turtle
            ]
          if (shape = "turtle" and random 8 = 1)
            [ set shape "splash" ]
        ]
    ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Interface Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to move-frog
  if (action != 0)
    [ if (action = 1)
        [ move-left ]
      if (action = 2)
        [ move-right ]
      if (action = 3)
        [ move-down ]
      if (action = 4)
        [ move-up ]
      sound:play-drum "LONG GUIRO" 50
      set action 0
    ]
end 

to move-left
  ask frogs with [xcor != min-pxcor]
    [ set heading 270
       fd 1
     ; 
      set jumps ( jumps + 1 )
      
      set heading 0
    
    ]
  ;check-frog
end 

to move-right
  ask frogs with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      ;set pcolor red
      set jumps ( jumps + 1 )
     ; set pcolor red 
      set heading 0
      
    ]
 ; check-frog
end 

to move-up
 ask frogs with [ycor != max-pycor]
    [ set heading 0
      fd 1
     ; set pcolor red
      set jumps ( jumps + 1 )
     ; set pcolor red 
      set heading 0
   ;  set pcolor red 
    ]
 
;  check-frog
end 

to move-down
  ask frogs with [ycor != min-pycor]
    [ set heading 180
      fd 1
     ; set pcolor red 
      set jumps ( jumps + 1 )
     ; set pcolor red 
      set heading 0
   
    ]
;  check-frog
end 

to move-left2
  ask frogs2 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right2
  ask frogs2 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up2
 ask frogs2 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down2
  ask frogs2 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left3
  ask frogs3 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right3
  ask frogs3 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up3
 ask frogs3 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down3
  ask frogs3 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left4
  ask frogs4 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right4
  ask frogs4 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up4
 ask frogs4 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down4
  ask frogs4 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left5
  ask frogs5 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right5
  ask frogs5 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up5
 ask frogs5 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down5
  ask frogs5 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left6
  ask frogs6 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right6
  ask frogs6 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up6
 ask frogs6 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down6
  ask frogs6 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left7
  ask frogs7 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right7
  ask frogs7 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up7
 ask frogs7 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down7
  ask frogs7 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left8
  ask frogs8 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right8
  ask frogs8 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up8
 ask frogs8 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down8
  ask frogs8 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 

to move-left9
  ask frogs9 with [xcor != min-pxcor]
    [ set heading 270
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
  ;check-frog
end 

to move-right9
  ask frogs9 with [xcor != max-pxcor]
    [ set heading 90
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 ; check-frog
end 

to move-up9
 ask frogs9 with [ycor != max-pycor]
    [ set heading 0
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
 
;  check-frog
end 

to move-down9
  ask frogs4 with [ycor != min-pycor]
    [ set heading 180
      fd 1
      set jumps ( jumps + 1 )
      set heading 0
    ]
;  check-frog
end 
;;;;;;;;;;;;;;
;;; Levels ;;;
;;;;;;;;;;;;;;

to level-1
  create-truck 5 -5 270 .9
  create-truck 0 -5 270 .9
  create-truck -8 -4 90 .9
  create-truck -5 -4 90 .9
  create-truck 2 -4 90 .9
  create-truck -3 -3 270 .8
  create-truck 6 -3 270 .8
  create-car 0 -2 90 .4
  create-car -4 -2 90 .4
  create-car 8 -1 270 .2
  create-car 3 -1 270 .2
  create-log 4 3 3 .6
  create-log -8 3 5 .6
  create-log 4 5 2 .7
  create-log -4 5 3 .7
  create-log 1 7 4 .3
  create-log -6 7 4 .3
  create-river-turtle 2 4 2 .4
  create-river-turtle -4 4 4 .4
  create-river-turtle 5 4 4 .4
  create-river-turtle -3 6 4 .5
  create-river-turtle 7 6 3 .5
end 

to level-2
  create-truck 4 -5 270 .8
  create-truck -3 -5 270 .8
  create-truck 0 -4 90 .9
  create-truck -4 -4 90 .9
  create-truck -1 -3 270 .8
  create-truck 4 -3 270 .8
  create-truck -5 -3 270 .8
  create-car 0 -2 90 .2
  create-car -4 -2 90 .2
  create-car 8 -2 90 .2
  create-car 6 -1 270 .4
  create-car 2 -1 270 .4
  create-car -3 -1 270 .4
  create-car -6 -1 270 .4
  create-log 6 3 3 .6
  create-log -4 3 4 .6
  create-log 0 5 3 .3
  create-log -6 5 3 .3
  create-log 1 7 4 .5
  create-log 6 7 4 .5
  create-river-turtle 0 4 4 .3
  create-river-turtle 6 4 4 .3
  create-river-turtle 0 6 4 .4
  create-river-turtle 6 6 3 .4
  make-river-turtle-dive 1
end 

to level-3
  create-truck -8 -5 270 .7
  create-truck -4 -5 270 .7
  create-truck 0 -5 270 .7
  create-truck -2 -4 90 .7
  create-truck 2 -4 90 .7
  create-truck -6 -4 90 .7
  create-truck -4 -3 270 .7
  create-truck 0 -3 270 .7
  create-truck 4 -3 270 .7
  create-car -3 -2 90 .2
  create-car -5 -2 90 .2
  create-car 5 -2 90 .2
  create-car 1 -2 90 .2
  create-car 0 -1 270 .3
  create-car 5 -1 270 .3
  create-car -7 -1 270 .3
  create-car -3 -1 270 .3
  create-log -6 3 4 .4
  create-log -2 5 3 .4
  create-log 5 5 3 .4
  create-log -4 7 2 .2
  create-log 0 7 2 .2
  create-log 4 7 2 .2
  create-river-turtle -4 4 4 .3
  create-river-turtle 5 4 4 .3
  create-river-turtle -1 6 3 .4
  create-river-turtle -8 6 3 .4
  make-river-turtle-dive 3
end 

to level-4
  create-truck -8 -5 270 .5
  create-truck -2 -5 270 .5
  create-truck 6 -5 270 .5
  create-truck 4 -4 90 .6
  create-truck -1 -4 90 .6
  create-truck -6 -4 90 .6
  create-car -4 -3 270 .3
  create-car 0 -3 270 .3
  create-car 4 -3 270 .3
  create-car 7 -3 270 .3
  create-car -3 -2 90 .2
  create-car -5 -2 90 .2
  create-car 5 -2 90 .2
  create-car 1 -2 90 .2
  create-car 0 -1 270 .3
  create-car 5 -1 270 .3
  create-car -7 -1 270 .3
  create-car -3 -1 270 .3
  create-log -3 3 3 .3
  create-log -3 5 3 .3
  create-log -3 7 3 .3
  create-river-turtle -4 4 4 .3
  create-river-turtle 4 4 4 .3
  create-river-turtle -7 4 1 .3
  create-river-turtle -1 6 3 .4
  create-river-turtle -8 6 3 .4
  create-river-turtle 3 6 2 .4
  make-river-turtle-dive 4
end 

to level-5
  create-car -4 -5 270 .3
  create-car 0 -5 270 .3
  create-car 4 -5 270 .3
  create-car 7 -5 270 .3
  create-car -3 -4 90 .2
  create-car -5 -4 90 .2
  create-car 5 -4 90 .2
  create-car 1 -4 90 .2
  create-car 8 -4 90 .2
  create-car -4 -3 270 .3
  create-car 0 -3 270 .3
  create-car 4 -3 270 .3
  create-car 7 -3 270 .3
  create-car -3 -2 90 .2
  create-car -5 -2 90 .2
  create-car 4 -2 90 .2
  create-car 1 -2 90 .2
  create-car 7 -2 90 .2
  create-car 0 -1 270 .3
  create-car 5 -1 270 .3
  create-car -7 -1 270 .3
  create-car -3 -1 270 .3
  create-log -5 3 2 .2
  create-log 0 5 2 .1
  create-log -5 7 2 .2
  create-river-turtle -4 4 2 .3
  create-river-turtle 4 4 3 .3
  create-river-turtle -7 4 2 .3
  create-river-turtle -1 6 2 .3
  create-river-turtle -8 6 2 .3
  create-river-turtle 3 6 3 .3
  make-river-turtle-dive 5
end 


; Copyright 2002 Uri Wilensky. All rights reserved.
; The full copyright notice is in the Info tab.

There is only one version of this model, created about 11 years ago by Mochamad Agung Tarecha.

Attached files

File Type Description Last updated
Frogger Simple Reflect Agent.png preview Preview for 'Frogger Simple Reflect Agent' about 11 years ago, by Mochamad Agung Tarecha Download

This model does not have any ancestors.

This model does not have any descendants.