LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 05-25-2009, 10:16 PM   #1
chutz
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Exclamation 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<stdio.h>
#include<conio.h>
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();
}
 
Old 05-26-2009, 02:52 PM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
will you play windows game or linux native game pleasehelpme Linux - Newbie 16 04-29-2007 09:58 PM
killall esd before game. run esd after game. missing gnome sounds. fakie_flip Linux - Games 3 09-30-2006 04:47 AM
How to play java game(like yahoo game) in firefox? Mathsniper Debian 1 01-04-2006 11:00 AM
2D/3D Game EASY Game Development Software tedjordan Linux - Games 1 03-22-2005 07:40 AM
game not receving game list from master server Rnastyracer Linux - Games 2 04-02-2004 11:20 PM


All times are GMT -5. The time now is 10:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration