; by
; Jose M Vidal
;
; Tileworld was (first?) described in:
;
;Martha Pollack and Marc Ringuette. "Introducing the Tileworld: experimentally
evaluating agent architectures."
;Thomas Dietterich and William Swartout ed. In Proceedings of the Eighth National
Conference on Artificial
; Intelligence, p. 183--189, AAAI Press. 1990.
breed [ robots ]
breed [ tiles ]
breed [ holes ]
tiles-own [time-to-live]
holes-own [time-to-live]
to setup
ca
set-default-shape tiles "box"
set-default-shape holes "circle"
create-robots num-robots [
setxy get-random-xcor get-random-ycor]
end
to-report get-random-xcor
report (random world-width) + min-pxcor
end
to-report get-random-ycor
report (random world-height) + min-pycor
end
to update
if (random-float 1.0 < tile-birth-prob) [
create-tiles 1 [
set heading 0
set time-to-live tile-lifetime
setxy get-random-xcor get-random-ycor
set color yellow]]
if (random-float 1.0 < hole-birth-prob) [
set holes-born holes-born + 1
create-holes 1 [
set heading 0
set time-to-live hole-lifetime
setxy get-random-xcor get-random-ycor
set color blue]]
tileworld - page 1
ask tiles [age]
ask holes [age]
no-display
ask robots [move]
display
; plot holes-filled
if (holes-born > 0)[
set score holes-filled * 100 / holes-born
plot score]
end
;tiles
;robots
tileworld - page 2
; with all of them getting in each others' way.
to move
let closest-tile 0
let closest-hole 0
;I am not next to the tile, so set my heading towards the best position next to
it.
set heading rectify-heading towardsxy destination-x destination-y
;If my move will cause a tile to move then change direction by +- 90.
;This will, hopefully, allow me to move around the target to push it back.
if (any? tiles-at dx dy)[
ifelse (random-float 1.0 < .5)[
set heading heading + 90]
[
set heading heading - 90]]
move-one heading]
end
tileworld - page 3