📄 maze3d.c
字号:
seed_5=(*counter_5);
seed_6=(*counter_6);
seed_7=(*counter_7);
for (iteration=1; iteration <= 8; iteration++)
{
substitution_index=10*seed_1+seed_0;
tem_0=substitution_low[substitution_index];
tem_1=substitution_high[substitution_index];
substitution_index=10*seed_3+seed_2;
seed_0=substitution_low[substitution_index];
tem_2=substitution_high[substitution_index];
substitution_index=10*seed_5+seed_4;
seed_2=substitution_low[substitution_index];
seed_1=substitution_high[substitution_index];
substitution_index=10*seed_7+seed_6;
seed_5=substitution_low[substitution_index];
seed_7=substitution_high[substitution_index];
seed_3=tem_0;
seed_6=tem_1;
seed_4=tem_2;
}
(*counter_0)=seed_0;
(*counter_1)=seed_1;
(*counter_2)=seed_2;
(*counter_3)=seed_3;
(*counter_4)=seed_4;
(*counter_5)=seed_5;
(*counter_6)=seed_6;
(*counter_7)=seed_7;
return;
}
static void increment(
int *counter_0,
int *counter_1,
int *counter_2,
int *counter_3,
int *counter_4,
int *counter_5,
int *counter_6,
int *counter_7)
{
register tem;
tem=(*counter_0)+1;
if (tem <= 9)
(*counter_0)=tem;
else
{
(*counter_0)=0;
tem=(*counter_1)+1;
if (tem <= 9)
(*counter_1)=tem;
else
{
(*counter_1)=0;
tem=(*counter_2)+1;
if (tem <= 9)
(*counter_2)=tem;
else
{
(*counter_2)=0;
tem=(*counter_3)+1;
if (tem <= 9)
(*counter_3)=tem;
else
{
(*counter_3)=0;
tem=(*counter_4)+1;
if (tem <= 9)
(*counter_4)=tem;
else
{
(*counter_4)=0;
tem=(*counter_5)+1;
if (tem <= 9)
(*counter_5)=tem;
else
{
(*counter_5)=0;
tem=(*counter_6)+1;
if (tem <= 9)
(*counter_6)=tem;
else
{
(*counter_6)=0;
tem=(*counter_7)+1;
if (tem <= 9)
(*counter_7)=tem;
else
(*counter_7)=0;
}
}
}
}
}
}
}
return;
}
static void get_cursor(
unsigned char *cursor_row,
unsigned char *cursor_column,
unsigned char *cursor_start,
unsigned char *cursor_stop)
{
static union REGS in;
static union REGS out;
in.h.ah=(unsigned char) 3;
in.h.bh=(unsigned char) 0;
int86(0x10,&in,&out);
*cursor_row=out.h.dh;
*cursor_column=out.h.dl;
*cursor_start=out.h.ch;
*cursor_stop=out.h.cl;
return;
}
static void set_cursor_position(
unsigned char cursor_row,
unsigned char cursor_column)
{
static union REGS in;
static union REGS out;
in.h.ah=(unsigned char) 2;
in.h.dh=cursor_row;
in.h.dl=cursor_column;
int86(0x10,&in,&out);
return;
}
static void set_cursor_size(
unsigned char cursor_start,
unsigned char cursor_stop)
{
static union REGS in;
static union REGS out;
in.h.ah=(unsigned char) 1;
in.h.ch=cursor_start;
in.h.cl=cursor_stop;
int86(0x10,&in,&out);
return;
}
static void titillate()
{
set_cursor_position(cursor_row,cursor_column);
titillator_index++;
if (titillator_index > 3)
titillator_index=0;
putchar((int) titillator[titillator_index]);
return;
}
static void solve_maze(
int max_x,
int max_y,
int *num_rooms_in_solution,
int *adjacency,
char **page,
stack_rec *stack)
{
static int delta_index;
static int passage_found;
static int stack_head;
static int x;
static int x_next;
static int y;
static int y_next;
*num_rooms_in_solution=1;
*adjacency=0;
x=1;
y=1;
stack_head=-1;
page[x][y]='S';
do
{
delta_index=0;
passage_found=FALSE;
do
{
while ((delta_index < 4) && (! passage_found))
{
x_next=x+delta_x[delta_index][0];
y_next=y+delta_y[delta_index][0];
if (page[x_next][y_next] == ' ')
passage_found=TRUE;
else
delta_index++;
}
if (! passage_found)
{
delta_index=(int) (stack[stack_head].index_1);
page[x][y]=' ';
x-=delta_x[delta_index][0];
y-=delta_y[delta_index][0];
page[x][y]=' ';
x-=delta_x[delta_index][0];
y-=delta_y[delta_index][0];
stack_head--;
delta_index++;
}
}
while (! passage_found);
page[x_next][y_next]='S';
x_next+=delta_x[delta_index][0];
y_next+=delta_y[delta_index][0];
if (y_next <= max_y)
{
stack_head++;
stack[stack_head].index_1=(char) delta_index;
page[x_next][y_next]='S';
x=x_next;
y=y_next;
}
}
while (y_next < max_y);
x=max_x-1;
y=max_y-1;
*adjacency=0;
while (stack_head >= 0)
{
for (delta_index=0; delta_index < 4; delta_index++)
{
x_next=x+delta_x[delta_index][0];
y_next=y+delta_y[delta_index][0];
if (page[x_next][y_next] != 'S')
{
if (page[x_next][y_next] == 'W')
{
x_next+=delta_x[delta_index][0];
y_next+=delta_y[delta_index][0];
if (x_next < 0)
(*adjacency)++;
else
if (x_next > max_x)
(*adjacency)++;
else
if (y_next < 0)
(*adjacency)++;
else
if (y_next > max_y)
(*adjacency)++;
else
{
if (page[x_next][y_next] == 'S')
(*adjacency)++;
}
}
}
}
x-=(2*delta_x[stack[stack_head].index_1][0]);
y-=(2*delta_y[stack[stack_head].index_1][0]);
stack_head--;
(*num_rooms_in_solution)++;
}
for (delta_index=0; delta_index < 4; delta_index++)
{
x_next=x+delta_x[delta_index][0];
y_next=y+delta_y[delta_index][0];
if (page[x_next][y_next] != ' ')
{
if (page[x_next][y_next] == 'W')
{
x_next+=delta_x[delta_index][0];
y_next+=delta_y[delta_index][0];
if (x_next < 0)
(*adjacency)++;
else
if (x_next > max_x)
(*adjacency)++;
else
if (y_next < 0)
(*adjacency)++;
else
if (y_next > max_y)
(*adjacency)++;
else
{
if (page[x_next][y_next] == 'S')
(*adjacency)++;
}
}
}
}
return;
}
static void generate_maze(
int num_columns,
int num_rows,
int num_rooms_in_maze,
int max_x,
int max_y,
char **page,
stack_rec *stack,
char *seed_ptr)
{
static int adjacency;
static int age;
static int counter_0;
static int counter_1;
static int counter_2;
static int counter_3;
static int counter_4;
static int counter_5;
static int counter_6;
static int counter_7;
static int delta_index_1a;
static int delta_index_1b;
static int delta_index_1c;
static int delta_index_1d;
static int delta_index_2;
static int digit;
static int digit_num;
static int num_rooms_in_solution;
static int passage_found;
static int r_n [8];
static int r_n_index_1;
static int r_n_index_2;
static int search_complete;
static int stack_head;
static int sum;
static int tem_int;
static int trial_num_mod_10;
static int x;
register int x_next;
static int y;
register int y_next;
while ((*seed_ptr == ' ')
|| (*seed_ptr == (char) 9))
seed_ptr++;
r_n_index_1=0;
while ((r_n_index_1 < 8) && (*seed_ptr) && (*seed_ptr != '\n'))
r_n[r_n_index_1++]=(int) (*(seed_ptr++) % 10);
r_n_index_2=7;
while (r_n_index_1 > 0)
{
r_n_index_1--;
r_n[r_n_index_2]=r_n[r_n_index_1];
r_n_index_2--;
}
while (r_n_index_2 >= 0)
{
r_n[r_n_index_2]=8;
r_n_index_2--;
}
counter_0=r_n[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -