Worms -- OOP Redo  2016-01
Worms-Redo Project as a learning vehicle.
worm-asserts
typedef struct {
  int x, y;         // coordinates of the segment
  char c;           // the letter it carries
} SEGMENT;
#define MAXsegs  100        // max # segments per worm
typedef struct {
  WORM_KIND type;       // once set, type does not change
  int direction;        // its (head's) direction
  int nsegs;            // # of segs in this worm
  int stomach;          // food value
  LIFE status;          // EATEN, DEAD, or ALIVE
  SEGMENT body[MAXsegs];    // body parts
} WORM;
#define headSeg(wp) (wp->body + wp->nsegs)
#define xOf(wp)     (headSeg(wp)->x)
#define yOf(wp)     (headSeg(wp)->y)

WellFormed

Connected

The body[] segments of a worm need to be "connected". That is body[i] and body[i+1] need to be adjacent. That is,

(abs(body[i].x - body[i+1].x) <= 1) && (abs(body[i].y - body[i+1].y) <= 1)

Crawls