02 Message

These directions were revised in Spring 2026. (The old directions involved making a separate file, which was confusing.)

Messages can only include numbers, strings, and lists. Structures (including posns and colors) cannot be sent in messages.

Structure Definition

We want a message structure to include two numbers and a color. The message structure gets its name abbreviated to “ic-msg” because we type it a lot.

A IC-Msg is a list that we treat like a structure.

(List Number Number Color-String)

Interpretation:

(make-ic-msg from to col)
  • from: the id of the world sending the message
  • to: the id of the world the message is intended for
  • col: the new color that world is to show

Code

Define functions to pretend that a list is a structure, like this:

(define (make-ic-msg from to col)
  (list from to col))

(define (ic-msg-from x) (first x))
(define (ic-msg-to x)   (second x))
(define (ic-msg-col x)  (third x))

That code can go near the start of your main file, right after the model structure.