Hi...
I'm currently doing a ludo game in C, I'm stuck with the pawn positions on the board. How do I manage the position of the pawns of each player, if I have maximum of two players and 4 pawns?

Here is my code for the pawn position but it is not working.

void position()                          //Function of pawn position
{
int original_position,updated_position,b,outcome;
char pawns[]={0};
original_position=0;
updated_position=0;
int i,numplayer,pawn,base;
     
  
while ((original_position<=56)&& (updated_position<=56))

b=1;
pawns[b]=original_position;
for(i=0;i<numplayer;i++)
{ 
printf("\n\n Player %d",i+1);
printf("\nCurrent position is = %d\n",original_position);
updated_position=original_position+outcome;
printf("\nNew position is = %d\n",updated_position);
rolldice();
{
if(original_position=updated_position)
{
printf("Pawn return to base");
base++;
pawn--;

}
if(original_position=56)
{
printf("Congrats you've nearly there!");
pawn--;
base--;
}
else if(pawn=4)
{
printf("Congrats you have won!");

}
}

Recommended Answers

I'm sure it is, but that doesn't mean we'll be any faster. On the contrary, we tend to ignore such pleading.
http://www.catb.org/~esr/faqs/smart-questions.html#urgent

First couple of problems
1. Your indentation needs a lot of …

Jump to Post

All 3 Replies

Reason: add code tags

Can you be more explicit please...
Or may be give me an example...
Thanks.

Please how it it done??? It's very urgent!

I'm sure it is, but that doesn't mean we'll be any faster. On the contrary, we tend to ignore such pleading.
http://www.catb.org/~esr/faqs/smart-questions.html#urgent

First couple of problems
1. Your indentation needs a lot of work.

2. if(original_position=56)
Use == for comparison, = is for assignment.

3. char pawns[]={0};
If you want 4 pawns, say so char pawns[4]={0};

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.