Child's Play

An interactive fiction by Stephen Granade (2007) - the Inform 7 source text

Chapter 1 - Adults

Section 0 - Chatter Rules

[A hacky no-value table]

Table of Empty
MT
"-"

Semaphore is a kind of value. The semaphores are ready to act, busy acting, done acting, and not acting.

[For chatter status, "ready to act" means we'll allow the adults to talk, "busy acting" means the adults are talking, "done acting" means the adults are finished with their conversation, and "not acting" means the adults won't talk at all.]
The chatter turn count is a number that varies. The chatter turn count is 0. The chatter count is a number that varies. The chatter count is 1. The chatter list table is a table-name that varies. The chatter list table is the Table of Empty. The current chatter table is a table-name that varies. The current chatter table is the Table of Empty. The chatter status is a semaphore that varies. The chatter status is not acting.

To have adults chatter:
    if the chatter list table is the Table of Empty begin;
        report bug "Tried to have the adults chatter despite the chatter list table being Nothing.";
        change the chatter status to not acting;
        rule succeeds;
    end if;
    if the current chatter table is the Table of Empty begin;
        if the number of filled rows in the chatter list table is 0 begin;
            change the chatter status to not acting;
            rule succeeds;
        end if;
        choose a random row in the chatter list table;
        change the current chatter table to the convo entry;
        change the chatter count to 1;
        blank out the whole row;
    end if;
    choose row chatter count in the current chatter table;
    say "[chatter entry][note parent-convo][paragraph break]";
    increment chatter count by 1;
    if chatter count is greater than the number of rows in the current chatter table begin;
        change chatter status to done acting;
        change current chatter table to the Table of Empty;
    end if.

Every turn when the chatter status is ready to act (this is the start the chatter rule):
    increment the chatter turn count by 1;
    if the chatter turn count is greater than 10 plus a random number from 1 to 4 begin;
        change the chatter status to busy acting;
        change the chatter turn count to 0;
    end if.

Every turn when the chatter status is busy acting (this is the chatter control rule):
    have adults chatter;
    if the chatter status is done acting, change the chatter status to ready to act.

To restart chatter:
    change chatter status to ready to act;
    change the chatter turn count to 0;
    change current chatter table to the Table of Empty.

To cut chatter short:
    if chatter status is busy acting, change current chatter table to the Table of Empty;
    change the chatter status to not acting.

The source code to Child's Play is licensed under a Creative Commons NonCommercial Sampling Plus 1.0 License.