Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org bantumi (sungka) game
 Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

 05-25-2009, 09:16 PM #1 chutz LQ Newbie   Registered: Jan 2009 Posts: 1 Rep: bantumi (sungka) game i have here started a code for a bantumi game... but i cannot continue anymore... please help anyone? here are the specs for the game: a two player bantumi game, the user will enter the desired position in the board game to start. there are seven pits for each player, and a home pit for each at each end... the players will put shells/stones in their pits in a counterclockwise direction, putting a shell/stone in each of the pits, except the oppponents home pit.. here is the code: #include #include int d1=0,d2=0,p1[]={7,7,7,7,7,7,7},p2[]={7,7,7,7,7,7,7},B2=0,B1=0,i,j,n,turn=1,posi; void player1() {for(i=n;i>0;i--) {if(posi<7) {p1[posi]+=1; if(p1[posi]-1==0&&i-1==0) {B1+=1; B1+=p2[posi]+p1[posi]; p2[posi]=0; i=0;turn++; } ++posi; } else if(posi==7) {B1+=1; posi++; } else {p2[j]+=1; j-=1; if(j<0&&i>0) {B2+=1; posi=0; } } } } void player2() {for(i=n;i>0;i--) {if(posi>=0) {p2[posi]+=1; if(p1[posi]+1==0&&i-1==0) {B2+=1; B2+=p2[posi]+p1[posi]; p1[posi]=0; i=0;turn++; } posi--; } else if(posi==-1) {B2+=1; posi--; } else {p1[j]+=1; j+=1; if(j>6&&i>0) {B1+=1; posi=6; } } } } int decision(int d) { d=0; for(i=0;i<7;i++) {if(p1[i]==0) d1+=1; if(p2[i]==0) d2+=1; } if(d1==7||d2==7) {B2+=p2[0]+p2[1]+p2[2]+p2[3]+p2[4]+p2[5]+p2[6]; B1+=p1[0]+p1[1]+p1[2]+p1[3]+p1[4]+p1[5]+p1[6]; if(B1>B2) printf("player 1 wins"); else if(B2>B1) printf("player 2 wins"); else printf("Draw Game"); d+=1; } return d; } void gameboard() {gotoxy(10,1); printf("[%d] [%d] [%d] [%d] [%d] [%d] [%d]",p2[0],p2[1],p2[2],p2[3],p2[4],p2[5],p2[6]); gotoxy(8,3); printf("[%d]",B2); gotoxy(38,3);printf("[%d]",B1); gotoxy(10,5); printf("[%d] [%d] [%d] [%d] [%d] [%d] [%d]",p1[0],p1[1],p1[2],p1[3],p1[4],p1[5],p1[6]); } void main() {int d=0;//this variable determines if the game is over or not clrscr(); do{ clrscr();gameboard(); gotoxy(10,15); printf("Enter position: "); scanf("%d",&posi); posi-=1;if(posi>0&&posi<6){ if(turn%2!=0) {gotoxy(10,3); printf("Player 1"); n=p1[posi]; j=6; p1[posi]=0; ++posi; player1(); } else {gotoxy(10,3); printf("Player 2");j=0; n=p2[posi]=0;++posi; player2(); }} decision(d); }while(d<1); getch(); }
 05-26-2009, 01:52 PM #2 jamescondron Member   Registered: Jul 2007 Location: Scunthorpe, UK Distribution: Ubuntu 8.10; Gentoo; Debian Lenny Posts: 961 Rep: Do you know why they give you that homework and not us? Because its for you to do. If you have a specific question, you ought really to ask it in the relevant question; though you should be asking specific questions

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post pleasehelpme Linux - Newbie 16 04-29-2007 08:58 PM fakie_flip Linux - Games 3 09-30-2006 03:47 AM Mathsniper Debian 1 01-04-2006 10:00 AM tedjordan Linux - Games 1 03-22-2005 06:40 AM Rnastyracer Linux - Games 2 04-02-2004 10:20 PM

LinuxQuestions.org

All times are GMT -5. The time now is 02:31 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -