[소스] BADUK PROGAM - 바둑
1993
LEE GWAN SEOG (이관석)
6.17 KiB
2인용 오목을 수정한 이관석 님의 바둑 프로그램 C 소스입니다.
BADUK.C
/*-------------------------------------------------------------------*/
/* */
/* BADUK PROGRAM */
/* */
/* 1993. 5. 27. Lee Gwan Seog. */
/*-------------------------------------------------------------------*/
#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
#define ESC 27
#define SPACE 32
#define UP 328
#define LEFT 331
#define RIGHT 333
#define DOWN 336
#define SEROPOK 24
#define GAROPOK 16
#define SEROSU 19
#define GAROSU 19
#define GAROSTART 40
#define SEROSTART 25
#define GAROEND GAROSTART+SEROPOK*(SEROSU-1)
#define SEROEND SEROSTART+GAROPOK*(GAROSU-1)
static unsigned char wtdol[1][132] = {
15, 0, 15, 0, 7, 224, 7, 224, 7, 224, 7, 224, 24, 24,
24, 24, 24, 24, 24, 24, 32, 4, 32, 4, 32, 4, 32, 4,
64, 2, 64, 2, 64, 2, 64, 2, 64, 2, 64, 2, 64, 2,
64, 2, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1,
128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 17,
128, 17, 128, 17, 128, 17, 128, 17, 128, 17, 128, 17, 128, 17,
128, 33, 128, 33, 128, 33, 128, 33, 64, 34, 64, 34, 64, 34,
64, 34, 65, 130, 65, 130, 65, 130, 65, 130, 32, 4, 32, 4,
32, 4, 32, 4, 24, 24, 24, 24, 24, 24, 24, 24, 7, 224,
7, 224, 7, 224, 7, 224 };
static unsigned char bkdol[1][132] = {
15, 0, 15, 0, 7, 224, 7, 224, 7, 224, 7, 224, 31, 248,
31, 248, 31, 248, 31, 248, 63, 252, 63, 252, 63, 252, 63, 252,
127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254,
127, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239,
255, 239, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239,
255, 223, 255, 223, 255, 223, 255, 223, 127, 222, 127, 222, 127, 222,
127, 222, 126, 126, 126, 126, 126, 126, 126, 126, 63, 252, 63, 252,
63, 252, 63, 252, 31, 248, 31, 248, 31, 248, 31, 248, 7, 224,
7, 224, 7, 224, 7, 224 };
static unsigned char cursor[1][132] = {
15, 0, 15, 0, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127,
254, 127, 254, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 254, 127, 254, 127, 254, 127, 254, 127,
254, 127, 254, 127, 254, 127, 254, 127, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96 };
static unsigned char hwajom[1][36] = {
7, 0, 7, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255 };
int x = GAROSTART+SEROPOK*9-8, y = SEROSTART+GAROPOK*9-8;
int get_key()
{
unsigned key,lo,hi;
key = bioskey(0);
lo = key & 0x00FF;
hi =(key & 0xFF00) >> 8;
if (lo==0)
return hi+256;
else
return lo;
}
void baduk_pan()
{
int i,j;
char str[2];
rectangle(GAROSTART-12, SEROSTART-10, GAROEND+12, SEROEND+10);
setfillstyle(SOLID_FILL, WHITE);
floodfill(GAROSTART-11, SEROSTART-9, WHITE);
outtextxy(120, 350, "ESC : QUIT SPACE BAR : PLACE");
outtextxy(225, 380, "UP");
outtextxy(225, 395, "/\\");
outtextxy(230, 400, "|");
outtextxy(135, 410, "LEFT <-- --> RIGHT");
outtextxy(230, 425, "|");
outtextxy(225, 430, "\\/");
outtextxy(220, 445, "DOWN");
outtextxy(500, 42, "----------------");
outtextxy(500, 50, "| RANDOM BADUK |");
outtextxy(500, 58, "----------------");
outtextxy(503, 100, "WHITE : COMPUTER");
outtextxy(503, 120, "BLACK : HUMAN");
outtextxy(500, 400, "COPYRIGHT 1993");
outtextxy(550, 420, "BY");
outtextxy(510, 440, "LEE GWAN SEOG");
setcolor(BLACK);
for (i=0 ; i<GAROSU ; i++)
{
line(GAROSTART, SEROSTART+i*GAROPOK, GAROEND, SEROSTART+i*GAROPOK);
line(GAROSTART+i*SEROPOK, SEROSTART, GAROSTART+i*SEROPOK, SEROEND);
}
for (i=3; i<=15; i+=6)
for (j=3; j<=15; j+=6)
putimage(j*SEROPOK+GAROSTART-4,i*GAROPOK+SEROSTART-4,hwajom, NOT_PUT);
setcolor(WHITE);
for (i=0; i<=18; i++)
itoa(i+1, str, 10), outtextxy(GAROSTART-32, GAROPOK*i+SEROSTART-4, str);
for (j=0,i=97; i<=115; i++,j++)
str[0]=i, str[1]='\0', outtextxy(j*SEROPOK+GAROSTART-4, 2, str);
}
void baduk_disp()
{
int white_x, white_y;
putimage(x, y, bkdol, NOT_PUT);
randomize();
white_x = GAROSTART+SEROPOK*random(SEROSU)-8;
white_y = SEROSTART+GAROPOK*random(GAROSU)-8;
delay(1000);
putimage(white_x, white_y, wtdol, NOT_PUT);
sound(150);
delay(70);
nosound();
}
void main(void)
{
int GraphDriver=DETECT, GraphMode, key;
if(registerbgidriver(EGAVGA_driver) < 0) exit(1);
initgraph(&GraphDriver, &GraphMode, "");
baduk_pan();
putimage(x,y, cursor, XOR_PUT);
rectangle(0,0, getmaxx(),getmaxy());
while ( 1 )
{
key = get_key();
putimage(x,y, cursor, XOR_PUT);
switch( key )
{
case SPACE: baduk_disp();
break;
case UP : if (y<GAROPOK*2) y = SEROEND-8;
else y -= GAROPOK;
break;
case DOWN : if (y>GAROPOK*GAROSU) y = SEROSTART-8;
else y += GAROPOK;
break;
case LEFT : if (x<SEROPOK*2) x = GAROEND-8;
else x -= SEROPOK;
break;
case RIGHT: if (x>SEROPOK*SEROSU) x = GAROSTART-8;
else x += SEROPOK;
break;
case ESC : closegraph(); exit(0);
}
putimage(x,y, cursor, XOR_PUT);
}
}
/* */
/* BADUK PROGRAM */
/* */
/* 1993. 5. 27. Lee Gwan Seog. */
/*-------------------------------------------------------------------*/
#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
#define ESC 27
#define SPACE 32
#define UP 328
#define LEFT 331
#define RIGHT 333
#define DOWN 336
#define SEROPOK 24
#define GAROPOK 16
#define SEROSU 19
#define GAROSU 19
#define GAROSTART 40
#define SEROSTART 25
#define GAROEND GAROSTART+SEROPOK*(SEROSU-1)
#define SEROEND SEROSTART+GAROPOK*(GAROSU-1)
static unsigned char wtdol[1][132] = {
15, 0, 15, 0, 7, 224, 7, 224, 7, 224, 7, 224, 24, 24,
24, 24, 24, 24, 24, 24, 32, 4, 32, 4, 32, 4, 32, 4,
64, 2, 64, 2, 64, 2, 64, 2, 64, 2, 64, 2, 64, 2,
64, 2, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1,
128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 17,
128, 17, 128, 17, 128, 17, 128, 17, 128, 17, 128, 17, 128, 17,
128, 33, 128, 33, 128, 33, 128, 33, 64, 34, 64, 34, 64, 34,
64, 34, 65, 130, 65, 130, 65, 130, 65, 130, 32, 4, 32, 4,
32, 4, 32, 4, 24, 24, 24, 24, 24, 24, 24, 24, 7, 224,
7, 224, 7, 224, 7, 224 };
static unsigned char bkdol[1][132] = {
15, 0, 15, 0, 7, 224, 7, 224, 7, 224, 7, 224, 31, 248,
31, 248, 31, 248, 31, 248, 63, 252, 63, 252, 63, 252, 63, 252,
127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254,
127, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239,
255, 239, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239, 255, 239,
255, 223, 255, 223, 255, 223, 255, 223, 127, 222, 127, 222, 127, 222,
127, 222, 126, 126, 126, 126, 126, 126, 126, 126, 63, 252, 63, 252,
63, 252, 63, 252, 31, 248, 31, 248, 31, 248, 31, 248, 7, 224,
7, 224, 7, 224, 7, 224 };
static unsigned char cursor[1][132] = {
15, 0, 15, 0, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127, 254, 127,
254, 127, 254, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 254, 127, 254, 127, 254, 127, 254, 127,
254, 127, 254, 127, 254, 127, 254, 127, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96, 6, 96,
6, 96, 6, 96, 6, 96 };
static unsigned char hwajom[1][36] = {
7, 0, 7, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255 };
int x = GAROSTART+SEROPOK*9-8, y = SEROSTART+GAROPOK*9-8;
int get_key()
{
unsigned key,lo,hi;
key = bioskey(0);
lo = key & 0x00FF;
hi =(key & 0xFF00) >> 8;
if (lo==0)
return hi+256;
else
return lo;
}
void baduk_pan()
{
int i,j;
char str[2];
rectangle(GAROSTART-12, SEROSTART-10, GAROEND+12, SEROEND+10);
setfillstyle(SOLID_FILL, WHITE);
floodfill(GAROSTART-11, SEROSTART-9, WHITE);
outtextxy(120, 350, "ESC : QUIT SPACE BAR : PLACE");
outtextxy(225, 380, "UP");
outtextxy(225, 395, "/\\");
outtextxy(230, 400, "|");
outtextxy(135, 410, "LEFT <-- --> RIGHT");
outtextxy(230, 425, "|");
outtextxy(225, 430, "\\/");
outtextxy(220, 445, "DOWN");
outtextxy(500, 42, "----------------");
outtextxy(500, 50, "| RANDOM BADUK |");
outtextxy(500, 58, "----------------");
outtextxy(503, 100, "WHITE : COMPUTER");
outtextxy(503, 120, "BLACK : HUMAN");
outtextxy(500, 400, "COPYRIGHT 1993");
outtextxy(550, 420, "BY");
outtextxy(510, 440, "LEE GWAN SEOG");
setcolor(BLACK);
for (i=0 ; i<GAROSU ; i++)
{
line(GAROSTART, SEROSTART+i*GAROPOK, GAROEND, SEROSTART+i*GAROPOK);
line(GAROSTART+i*SEROPOK, SEROSTART, GAROSTART+i*SEROPOK, SEROEND);
}
for (i=3; i<=15; i+=6)
for (j=3; j<=15; j+=6)
putimage(j*SEROPOK+GAROSTART-4,i*GAROPOK+SEROSTART-4,hwajom, NOT_PUT);
setcolor(WHITE);
for (i=0; i<=18; i++)
itoa(i+1, str, 10), outtextxy(GAROSTART-32, GAROPOK*i+SEROSTART-4, str);
for (j=0,i=97; i<=115; i++,j++)
str[0]=i, str[1]='\0', outtextxy(j*SEROPOK+GAROSTART-4, 2, str);
}
void baduk_disp()
{
int white_x, white_y;
putimage(x, y, bkdol, NOT_PUT);
randomize();
white_x = GAROSTART+SEROPOK*random(SEROSU)-8;
white_y = SEROSTART+GAROPOK*random(GAROSU)-8;
delay(1000);
putimage(white_x, white_y, wtdol, NOT_PUT);
sound(150);
delay(70);
nosound();
}
void main(void)
{
int GraphDriver=DETECT, GraphMode, key;
if(registerbgidriver(EGAVGA_driver) < 0) exit(1);
initgraph(&GraphDriver, &GraphMode, "");
baduk_pan();
putimage(x,y, cursor, XOR_PUT);
rectangle(0,0, getmaxx(),getmaxy());
while ( 1 )
{
key = get_key();
putimage(x,y, cursor, XOR_PUT);
switch( key )
{
case SPACE: baduk_disp();
break;
case UP : if (y<GAROPOK*2) y = SEROEND-8;
else y -= GAROPOK;
break;
case DOWN : if (y>GAROPOK*GAROSU) y = SEROSTART-8;
else y += GAROPOK;
break;
case LEFT : if (x<SEROPOK*2) x = GAROEND-8;
else x -= SEROPOK;
break;
case RIGHT: if (x>SEROPOK*SEROSU) x = GAROSTART-8;
else x += SEROPOK;
break;
case ESC : closegraph(); exit(0);
}
putimage(x,y, cursor, XOR_PUT);
}
}
함께 나눈 이야기
댓글댓글 남기기