/* ioccc/2020/ferguson1 - Snake terminal testing utility * * This will imperfectly: * * (0) Test if terminal supports the features Snake uses. * (1) Report terminal (and playing) size(s). * (2) Estimates the minimum number of columns to play unhindered (based on the * size, max size and growth rate). * (3) Reports the max size of the Snake and the number of bugs required to * reach that size but doesn't use shedding. */ #include #include #include #define f(a,b) ((a)<(b)?(a):(b)) static char *v; static size_t Y=997,X=5, S=5, rows,N, K; static int x, y; struct caps { char *caps, *sup, *desc; int fatal; }; static size_t b(size_t n) { size_t i=n/10, j=1; while (i) { i/=10; ++j; } return j; } static size_t a(int n) { int i=n/10; size_t j=1; while (i) { i/=10; ++j; } return j; } static struct caps caps[] = { { "cup", NULL, "cursor movement", 1 }, { "civis", NULL, "making cursor invisible", 0 }, { "bold", NULL, "bold", 0 }, { NULL, NULL, NULL, 0 } }; static size_t c(size_t M, size_t V) { size_t i; if (!S) S = 5; for (i=0; V