### Troubles with mancala

For my class I'm making a mancala game, but I'm having troubles with the actual movement of marbles in the game
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131`` ``````#include #include bool finished(vector displayboard); void displayboard(vector boardvalue); void makemove(vector &boardvalue, int player); using namespace std; void makemove(vector &boardvalue, int player) { char position; int numposition; cout << "\nWhich column do you want to pick from? "; cin >> position; if (player == 1) { switch(position) { case 'A': numposition=1; break; case 'B': numposition=2; break; case 'C': numposition=3; break; case 'D': numposition=4; break; case 'E': numposition=5; break; case 'F': numposition= 6; break; default: cout << "Enter the letter of one of the pits"; break; } } if (player == 2) { switch(position) { case 'A': numposition=13; break; case 'B': numposition=12; break; case 'C': numposition=11; break; case 'D': numposition=10; break; case 'E': numposition=9; break; case 'F': numposition=8; break; default: cout << "Enter the letter of one of the pits"; break; } } int numstones = boardvalue[numposition]; boardvalue[numposition]=0; for (int i = 1; i < numstones; i++) { boardvalue[(numposition + i)] += 1; } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool finished(vector displayboard) { if (displayboard[1] ==0 && displayboard[2] ==0 && displayboard[3] ==0 && displayboard[4] ==0 && displayboard[5] ==0 && displayboard[6] ==0 ||displayboard[13] ==0 && displayboard[8] ==0 && displayboard[9] ==0 && displayboard[10] ==0 && displayboard[11] ==0 && displayboard[12] ==0) return true; else return false; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void displayboard(vector boardvalue) { cout << " " << boardvalue[13] << " " << boardvalue[12] << " " << boardvalue[11] << " " << boardvalue[10] << " " << boardvalue[9] << " " << boardvalue[8]; cout << endl << boardvalue[0] << " " << boardvalue [7] << endl; cout << " " << boardvalue[1] << " " << boardvalue[2] << " " << boardvalue[3] << " " << boardvalue[4] << " " << boardvalue[5] << " " << boardvalue[6]; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int main() { vector boardvalue(14); int player = 1; for (int i = 0; i <= boardvalue.size(); i ++) { boardvalue[i] = 4; } boardvalue[0] = 0; boardvalue[7] = 0; displayboard(boardvalue); cout << "\n A B C D E F\n"; while (!finished(boardvalue)) { if (player == 1) { cout << "\nPlayer 1's turn!"; } else { cout << "\nPlayer 2's turn!"; } makemove(boardvalue, player); if (player == 1) { cout << " A B C D E F\n"; } displayboard(boardvalue); if (player == 2) { cout << "\n A B C D E F\n"; } if (player == 1) { player = 2; } else player = 1; } return(0); } ``````

Specifically in makemove towards the end at
 ``123456`` ``````int numstones = boardvalue[numposition]; boardvalue[numposition]=0; for (int i = 1; i < numstones; i++) { boardvalue[(numposition + i)] += 1; }``````

It ends when the vector gets to 13, though it should keep looping until it runs out of stones.
I know there's a simple solution to the problem, and I feel really dumb because it is escaping my grasp right now.
Any other advice would be appreciated as well.
Topic archived. No new replies allowed.