for (int i = castle_frame; i > 2; i--) num%=i+2;  num %= 4; num %= 3;  castle_frame+=2; castle_frame %= 16;  return num;
if (num >= 8) return 2; else if (num >= 6) return 1; return 0;
static int get_frame (void){	int num = rand();	for (int i = castle_frame; i > 2; i--)		num%=i+2;		num %= 4;	num %= 3;	castle_frame+=2;	castle_frame %= 16;	return num;}