I've implemented Centipedes in DreamZZT, you can view the code here: http://svn.c99.org/viewvc/DreamZZT/trun ... iew=markup
Essentially, each segment keeps a pointer to the segment in front of and behind it, and whenever it moves it tells the segment behind it which way it moved, then that segment moves that direction on the next cycle.
ex:
cycle 1:
head: north
seg1: north
seg2: north
head hits a wall and moves east
cycle 2:
head: east
seg1: north
seg2: north
cycle 3:
head: east
seg1: east
seg2: north
cycle 4:
head: east
seg1: east
seg2: east
Hope that helps.
-Sam
Centipede code for my ZZT clone (in Pascal) help
Moderator: Terryn