home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Ultimate House of Games 2000
/
UHOG2000.iso
/
Games
/
Strategy
/
WINFOUR
/
FOUR.C
next >
Wrap
Text File
|
1995-12-08
|
1KB
|
78 lines
#include <stdio.h>
int my_algo(int mycode,int hiscode,int board[7][6])
{
return(0);
}
int human(int mycode,int hiscode,int board[7][6])
{
int i;
printf("Enter column \n");
scanf("%d",&i);
i--;
return(i);
}
printboard(int board[7][6])
{
int i,j;
for(j=5;j>=0;j--)
{
printf("|");
for(i=0;i<7;i++)
{
if (board[i][j]==10) printf("0");
else if (board[i][j]==20) printf("1");
else printf(" ");
}
printf("|\n");
}
return(0);
}
int full(int board[7][6])
{
int i;
for (i=0;i<7;i++) if(board[i][5]==0) return(0);
return(1);
}
move(int board[7][6],int color,int column)
{
int i;
i=5;
while(board[column][i]==0 && i>0) i--;
if(board[column][i]!=0) i++;
board[column][i]=color;
}
getmove(int mycode,int hiscode,int board[7][6],int p)
{
if(p==1) return(my_algo(mycode,hiscode,board));
if(p==2) return(human(mycode,hiscode,board));
}
dogame(int mycode,int hiscode,int board[7][6])
{
while(!full(board))
{
printboard(board);
move(board,mycode, getmove(mycode,hiscode,board,2));
printboard(board);
move(board,hiscode,getmove(hiscode,mycode,board,1));
printf("\n");
}
printboard(board);
return(0);
}
main()
{
int board[7][6];
int i,j;
for(i=0;i<7;i++) for(j=0;j<6;j++) board[i][j]=0;
dogame(10,20,board);
return(0);
}