~ knotless Search/
↑↓ move↵ open⇧↵ all results

spaces.cameron.stream/hello

Hello.

0
1
main
122 lines · 4.7 KB Raw History
/* The history of the town, one month at a time, from its founding.
 *
 * A household is a line: a family, or an institution. Every first of the month
 * each line writes to the World and posts it. Then the month passes. People go to
 * church and set their clocks by the bell. They move house, and change their
 * habits a little. They die, the longer they have kept the house the likelier,
 * and their children take the house and the initial.
 * A household that misses the post three months running gets up ten minutes
 * earlier; one that is more than an hour early for it three months running
 * stays in bed ten minutes longer. Everything that happens by chance was decided by the line's seed.
 *
 * Almost everything. The Society is the dead letter office: the only people who
 * read every letter written to the World, and so the only people who know what
 * it must say on the census day. It has seen to it. Its acts are in the records,
 * and nobody in town knows of them. A member does each one, and has to be able
 * to walk to the household to do it. */

#ifndef HISTORY_H
#define HISTORY_H

#include <stdint.h>

#include "records.h"

#define MAX_LINES 32
#define CHURCH "Church"
#define REACH 800 /* How far, in metres, a member of the Society will walk to do something: half a mile. */

enum kind {
	RESIDENT,
	INSTITUTION,
	BELL, /* The church. Its clock is the bell. It does not change. */
};

struct household {
	enum kind kind;
	char line[FIELD]; /* Which line: an initial and a number, or for institutions their name. */
	char initial; /* What the line writes. Residents only. */
	char sends[8]; /* What the institution sends. Institutions only. */
	char name[FIELD];
	char home[FIELD];
	struct day since; /* When the line was founded. Before then it does nothing. */
	int weekdays, weekends; /* When they wake, or for institutions leave to post, by their own clock. */
	int writes; /* Minutes spent writing. */
	struct day set; /* When their clock was last set by the bell. */
	int adjusted; /* Minutes the Society has put the clock wrong since. The bell puts it right. */
	int gains; /* Seconds their clock gains a day. Negative if it loses. */
	uint64_t seed;
	int generation;
	int head_since; /* The month the present head of the household took it over. */
	int member; /* Of the Society. Members work at the dead letter office, and do not write. */
	int misses; /* Posts missed in a row. */
	int early; /* Posts in a row made more than an hour before the van came. */
};

struct town {
	int month; /* Months since January 1900. */
	int lines;
	struct household line[MAX_LINES];
};

/* What the Society does. */
enum deed {
	NAMES,  /* Sees to the naming of a child. */
	HOUSES, /* Finds the household a house. */
	CLOCKS, /* Puts the household's clock a number of minutes fast, or slow. */
	WORDS,  /* Has a word, so that they get up a number of minutes later, or earlier. */
};

#define MAX_ACTS 256

struct act {
	int month; /* Done at the end of the month, after everything else, by a member. */
	char line[FIELD];
	enum deed deed;
	char what[FIELD]; /* The name, or the house. */
	int minutes; /* For clocks and words. */
};

/* The Society's acts: those in records/society.txt, unless others have been set. */
int society(const struct act **acts);
void set_society(const struct act *acts, int n);

/* Told of everything that happens in the history, if set. The Society's acts are
 * told with a what beginning "The Society". */
extern void (*chronicle)(struct day day, const struct household *h, const char *what);

/* Whether a household moves house in a month. Sometimes they move into the house they had. */
int moves(const struct household *h, int month);

/* Whether a line had been founded by a day. */
int active(const struct household *h, struct day day);

/* The names a line with an initial may be given. */
int names_for(char initial, const char *out[]);

/* The places anyone may live. */
int homes(const char *out[]);

/* How many minutes fast a household's clock is on a day. Slow clocks are negative. */
int fast(const struct household *h, struct day day);

/* The real time, when a household's clock shows a given time. */
int real_time(const struct household *h, int shown, struct day day);

/* The town as founded, from the founding records. */
void found(struct town *town);

/* One household's month, from the first of `month` to the first of the next.
 * What the Society does is done by the town, in advance(). */
void live(struct household *h, int month);

/* What the Society does in a month, once the town has lived it. */
void carry_out(struct town *town, int month);

/* The whole town's month, and then the Society's. */
void advance(struct town *town);

/* The town as it was on the first of the month a day is in. */
const struct town *town_on(struct day day);

#endif