1. Bu site çerezler kullanır. Bu siteyi kullanmaya devam ederek çerez kullanımımızı kabul etmiş olursunuz. Daha Fazla Bilgi.

C ile Satranç

'Bilgisayar Programlama ve Kodlama' forumunda Powers tarafından 15 Ocak 2013 tarihinde açılan konu

  1. Powers

    Powers Administrator Site Yetkilisi

    #include<stdio.h>
    #include<graphics.h>
    #include<conio.h>
    #include<stdlib.h>
    #include<dos.h>
    #include<time.h>
    /*tasları tahta uzerinde gosterir*/
    char tahta()
    {
    int i,j,color;
    setcolor(YELLOW);
    settextstyle(1,0,1);
    outtextxy(125,25,"1 2 3 4 5 6 7 8 ");
    settextstyle(1,1,1);
    outtextxy(75,40,"A B C D E F G H ");
    setcolor(CYAN);
    setlinestyle(0,0,3);
    for(i=1;i<=9;i++)
    {
    line(100,50*i,500,50*i);
    line(50*(i+1),50,50*(i+1),450);
    }
    setfillstyle(SOLID_FILL, 11);
    color=11;
    for(i=75;i<=425;i=i+50)
    for(j=125;j<=475;j=j+50)
    {
    if(color==11)
    {
    floodfill(j,i,CYAN);
    if(j==475) {setfillstyle(SOLID_FILL, 11);color=11;}
    else {setfillstyle(SOLID_FILL, BROWN);color=BROWN;}
    }
    else
    {
    floodfill(j,i,CYAN);
    if(j==475) {setfillstyle(SOLID_FILL, BROWN);color=BROWN;}
    else {setfillstyle(SOLID_FILL,11);color=11;}
    }
    }
    }


    rbul(a0,b0)
    int a0,b0;
    {
    if((a0+b0)%100 == 0) return BROWN;
    return LIGHTCYAN;
    }


    kale(a,b,cr,tr)
    int a,b,cr,tr;
    {
    setcolor(cr);
    setlinestyle(0,0,2);
    line(a,b,a,b+3);
    line(a,b+3,a+35,b+3);
    line(a+35,b+3,a+35,b);
    line(a+35,b,a+30,b);
    line(a+30,b,a+30,b-20);
    line(a+30,b-20,a+35,b-20);
    line(a+35,b-20,a+35,b-27);
    line(a+35,b-27,a+25,b-27);
    line(a+25,b-27,a+25,b-24);
    line(a+25,b-24,a+20,b-24);
    line(a+20,b-24,a+20,b-27);
    line(a+20,b-27,a+15,b-27);
    line(a+15,b-27,a+15,b-24);
    line(a+15,b-24,a+10,b-24);
    line(a+10,b-24,a+10,b-27);
    line(a+10,b-27,a,b-27);
    line(a,b-27,a,b-20);
    line(a,b-20,a+5,b-20);
    line(a+5,b-20,a+5,b);
    line(a+5,b,a,b);
    setfillstyle(SOLID_FILL,tr);
    floodfill(a+10,b-10,cr);
    setlinestyle(0,0,3);
    }


    at(a1,b1,cr1,tr1)
    int a1,b1,cr1,tr1;
    {
    setcolor(cr1);
    setlinestyle(0,0,2);
    line(a1,b1,a1,b1+3);
    line(a1,b1,a1+7,b1);
    line(a1,b1+3,a1+35,b1+3);
    line(a1+35,b1+3,a1+35,b1);
    line(a1+35,b1,a1+28,b1);
    arc(a1+72,b1-25,185,210,50);
    arc(a1+53,b1,135,180,45);
    line(a1+25,b1-30,a1+22,b1-33);
    line(a1+22,b1-33,a1+20,b1-30);
    line(a1+25,b1-30,a1+35,b1-20);
    line(a1+35,b1-20,a1+35,b1-16);
    line(a1+35,b1-16,a1+21,b1-19);
    setfillstyle(SOLID_FILL,tr1);
    floodfill(a1+10,b1-10,cr1);
    setlinestyle(0,0,3);
    }


    fil(a2,b2,cr2,tr2)
    int a2,b2,cr2,tr2;
    {
    setcolor(cr2);
    setlinestyle(0,0,2);
    line(a2,b2,a2,b2+3);
    line(a2,b2+3,a2+36,b2+3);
    line(a2+36,b2+3,a2+36,b2);
    line(a2+36,b2,a2+30,b2);
    line(a2+30,b2,a2+20,b2-19);
    line(a2+14,b2-19,a2+6,b2);
    line(a2+6,b2,a2,b2);
    arc(a2+18,b2-23,100,250,6);
    arc(a2+18,b2-23,290,80,5);
    arc(a2+18,b2-30,-5,185,2);
    setfillstyle(SOLID_FILL,tr2);
    floodfill(a2+15,b2-10,cr2);
    setlinestyle(0,0,3);
    }

    piyon(a3,b3,cr3,tr3)
    int a3,b3,cr3,tr3;
    {
    setcolor(cr3);
    setlinestyle(0,0,2);
    line(a3,b3,a3,b3+3);
    line(a3,b3+3,a3+36,b3+3);
    line(a3+36,b3+3,a3+36,b3);
    line(a3+36,b3,a3+30,b3);
    line(a3+30,b3,a3+21,b3-18);
    line(a3+15,b3-18,a3+6,b3);
    line(a3+6,b3,a3,b3);
    arc(a3+18,b3-23,-80,260,6);
    setfillstyle(SOLID_FILL,tr3);
    floodfill(a3+15,b3-10,cr3);
    setlinestyle(0,0,3);
    }


    sah(a4,b4,cr4,tr4)
    int a4,b4,cr4,tr4;
    {
    setcolor(cr4);
    setlinestyle(0,0,2);
    line(a4,b4,a4,b4+3);
    line(a4,b4+3,a4+36,b4+3);
    line(a4+36,b4+3,a4+36,b4);
    line(a4+36,b4,a4+29,b4);
    line(a4+29,b4,a4+21,b4-20);
    line(a4+21,b4-20,a4+30,b4-25);
    line(a4+30,b4-25,a4+30,b4-32);
    line(a4+30,b4-32,a4+24,b4-26);
    line(a4+24,b4-26,a4+18,b4-32);
    line(a4+18,b4-32,a4+12,b4-26);
    line(a4+12,b4-26,a4+6,b4-32);
    line(a4+6,b4-32,a4+6,b4-25);
    line(a4+6,b4-25,a4+15,b4-20);
    line(a4+15,b4-20,a4+7,b4);
    line(a4+7,b4,a4,b4);
    setfillstyle(SOLID_FILL,tr4);
    floodfill(a4+15,b4-10,cr4);
    setlinestyle(0,0,3);
    }

    vezir(a5,b5,cr5,tr5)
    int a5,b5,cr5,tr5;
    {
    setcolor(cr5);
    setlinestyle(0,0,2);
    line(a5,b5,a5,b5+3);
    line(a5,b5+3,a5+36,b5+3);
    line(a5+36,b5+3,a5+36,b5);
    line(a5+36,b5,a5+29,b5);
    line(a5+29,b5,a5+23,b5-18);
    line(a5+13,b5-18,a5+7,b5);
    line(a5+7,b5,a5,b5);
    arc(a5+18,b5-23,100,240,8);
    arc(a5+18,b5-23,300,80,8);
    line(a5+16,b5-30,a5+18,b5-37);
    line(a5+18,b5-37,a5+20,b5-30);
    setfillstyle(SOLID_FILL,tr5);
    floodfill(a5+15,b5-10,cr5);
    setlinestyle(0,0,3);
    }



    int main()
    {
    int tas[10][10],i,j,k,s,cr,tr,h;
    int n,sayac,a,b;
    int konum[2];
    char hamle,basla;
    randomize();
    clrscr();
    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "");
    errorcode = graphresult();
    if (errorcode != grOk)
    {
    printf("Graphics error: %s\n", grapherrormsg(errorcode));
    printf("Press any key to halt:");
    getch();
    exit(1);
    }
    for(i=1;i<=8;i++)
    for(j=1;j<=8;j++)
    tas[j]=0;

    tas[1][1]=5;//beyaz kale
    tas[1][8]=5;//beyaz kale
    tas[1][2]=4;//beyaz at
    tas[1][7]=4;//beyaz at
    tas[1][3]=3;//beyaz fil
    tas[1][6]=3;//beyaz fil
    tas[1][4]=2;//beyaz vezir
    tas[1][5]=1;//beyaz sah
    tas[8][1]=11;//siyah kale
    tas[8][8]=11;//siyah kale
    tas[8][2]=10;//siyah at
    tas[8][7]=10;//siyah at
    tas[8][3]=9;//siyah fil
    tas[8][6]=9;//siyah fil
    tas[8][4]=8;//siyah vezir
    tas[8][5]=7;//siyah sah

    for(i=1;i<=8;i++)
    {
    tas[2]=6;//beyaz piyon
    tas[7]=12;//siyah piyon
    }

    s=1;
    cr=BLACK;
    tr=LIGHTGRAY;
    tahta();
    for(k=90;k<=440;k=k+350)
    {
    sah(257,k,cr,tr);
    vezir(307,k,cr,tr);
    kale(107,k,cr,tr);
    kale(457,k,cr,tr);
    at(157,k,cr,tr);
    at(407,k,cr,tr);
    fil(207,k,cr,tr);
    fil(357,k,cr,tr);
    for(i=100;i<=450;i=i+50)
    piyon(i+7,k+s*50,cr,tr);
    s=s*(-1);
    cr=DARKGRAY;
    tr=BLUE;
    }
    getch();
    for(k=1;k<=50;k++)
    {
    setlinestyle(0,0,3);
    if(k%2 != 0) {i=100;j=50;}
    else {i=100;j=400;}
    setcolor(YELLOW);
    sayac=0;
    while(sayac < 2)
    {
    rectangle(i,j,i+50,j+50);
    hamle=getch();

    switch(hamle)
    {

    case 'M': //saga hareket
    setcolor(CYAN);
    rectangle(i,j,i+50,j+50);
    i=i+50;
    if(i>450) {sound(300);delay(200);nosound();i=i-50;}
    setcolor(YELLOW);
    break;

    case 'K'://sola hareket
    setcolor(CYAN);
    rectangle(i,j,i+50,j+50);
    i=i-50;
    if(i<100) {sound(300);delay(200);nosound();i=i+50;}
    setcolor(YELLOW);
    break;

    case 'P'://asagi hareket
    setcolor(CYAN);
    rectangle(i,j,i+50,j+50);
    j=j+50;
    if(j>400) {sound(300);delay(200);nosound();j=j-50;}
    setcolor(YELLOW);
    break;

    case 'H'://yukari hareket
    setcolor(CYAN);
    rectangle(i,j,i+50,j+50);
    j=j-50;
    if(j<50) {sound(300);delay(200);nosound();j=j+50;}
    setcolor(YELLOW);
    break;

    case ' '://tas alma ve koyma
    setcolor(RED);
    rectangle(i,j,i+50,j+50);
    setfillstyle(SOLID_FILL,rbul(i,j));
    floodfill(i+15,j+15,RED);
    sayac++;
    if(sayac < 2) {a=j/50;b=(i-50)/50;}
    if(sayac == 2)
    {
    switch(tas[a])
    {
    case 1:vezir(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=1;break;
    case 2:sah(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=2;break;
    case 3:fil(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=3;break;
    case 4:at(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=4;break;
    case 5:kale(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=5;break;
    case 6:piyon(i+7,j+40,BLACK,LIGHTGRAY);tas[j/50][(i-50)/50]=6;break;
    case 7:vezir(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=8;break;
    case 8:sah(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=7;break;
    case 9:fil(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=9;break;
    case 10:at(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=10;break;
    case 11:kale(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=11;break;
    case 12:piyon(i+7,j+40,DARKGRAY,BLUE);tas[j/50][(i-50)/50]=12;break;
    }
    tas[a]=0;
    setcolor(CYAN);
    rectangle(i,j,i+50,j+50);
    }
    break;
    }
    }
    }
    }
     
    Tags:

Bu Sayfayı Paylaş

  1. Bu site çerezler kullanır. Bu siteyi kullanmaya devam ederek çerez kullanımımızı kabul etmiş olursunuz. Daha Fazla Bilgi.
  1. Bu site çerezler kullanır. Bu siteyi kullanmaya devam ederek çerez kullanımımızı kabul etmiş olursunuz. Daha Fazla Bilgi.
Yükleniyor...