help in checkers game

Hello,

I am currently making a checkers game and need some help on labeling the 3rd row different numbers than the first. At the moment it prints this out:
R2 R4 R6 R8
R1 R3 R5 R7
R2 R4 R6 R8

How do I make the 3rd row, R9 R10 R11 R12? The part that assigns that is here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//puts all RED PIECES DOWN
    int piece=0;
    for(int row=0; row<8; row++)
    {
        int& piece=piece;
        piece++;
        std::string tempPiece=std::to_string(piece);
        for(int col=0; col<3; col++)
        {

            if (row%2==1)
            {
                if(col%2==0)
                {
                        playboard[col][row]="R"+tempPiece;
                }
            }
            if (row%2==0)
            {
                if (col%2==1)
                {

                playboard[col][row]="R"+tempPiece;
                }

            }
        }


AND BELOW IS THE FULL CODE TO TEST

THANKS IN ADVANCE! 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <iostream>
#include <algorithm>
#include <ctime>
using namespace std;

//bool checkAlive(char )

void setBoard(string (&playboard)[8][8])
{
    //sets up all the spaces
    for(int i=0; i<8; i++)
    {
        for(int j=0; j<8; j++)
        {
            playboard[i][j]="  ";
        }
    }

    //puts all RED PIECES DOWN
    int piece=0;
    for(int row=0; row<8; row++)
    {
        int& piece=piece;
        piece++;
        std::string tempPiece=std::to_string(piece);
        for(int col=0; col<3; col++)
        {

            if (row%2==1)
            {
                if(col%2==0)
                {
                        playboard[col][row]="R"+tempPiece;
                }
            }
            if (row%2==0)
            {
                if (col%2==1)
                {

                playboard[col][row]="R"+tempPiece;
                }

            }
        }
        //puts all BLACK PIECES DOWN
        for(int row=0; row<8; row++)
        {
            for(int col=5; col<8; col++)
            {
                if (row%2==1)
                {
                    if(col%2==0)
                    playboard[col][row]="B";
                }
                if (row%2==0)
                {
                    if (col%2==1)
                    playboard[col][row]="B";
                }
            }
        }
    }
}
void printBoard(string (&playboard)[8][8])
{
cout << "    1     2    3    4    5    6    7   8   " << endl;
cout << "   ____ ____ ____ ____ ____ ____ ____ ____" << endl;
cout << "1 | " << playboard[0][0] << " | " << playboard[0][1] << "  | " << playboard[0][2] << " | " << playboard[0][3] << "  | " << playboard[0][4] << " | " << playboard[0][5] << "  | " << playboard[0][6] << " | " << playboard[0][7] << "  | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "2 | " << playboard[1][0] << "  | " << playboard[1][1] << " | " << playboard[1][2] << "  | " << playboard[1][3] << " | " << playboard[1][4] << "  | " << playboard[1][5] << " | " << playboard[1][6] << "  | " << playboard[1][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "3 | " << playboard[2][0] << " | " << playboard[2][1] << "  | " << playboard[2][2] << " | " << playboard[2][3] << "  |" << playboard[2][4] << "  | " << playboard[2][5] << "  | " << playboard[2][6] << " | " << playboard[2][7] << "  | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "4 | " << playboard[3][0] << " | " << playboard[3][1] << " | " << playboard[3][2] << " | " << playboard[3][3] << " | " << playboard[3][4] << " | " << playboard[3][5] << " | " << playboard[3][6] << " | " << playboard[3][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "5 | " << playboard[4][0] << " | " << playboard[4][1] << " | " << playboard[4][2] << " | " << playboard[4][3] << " | " << playboard[4][4] << " | " << playboard[4][5] << " | " << playboard[4][6] << " | " << playboard[4][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "6 | " << playboard[5][0] << "  | " << playboard[5][1] << " | " << playboard[5][2] << "  | " << playboard[5][3] << " | " << playboard[5][4] << "  | " << playboard[5][5] << " | " << playboard[5][6] << "  | " << playboard[5][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "7 | " << playboard[6][0] << " | " << playboard[6][1] << " | " << playboard[6][2] << " | " << playboard[6][3] << " | " << playboard[6][4] << " | " << playboard[6][5] << " | " << playboard[6][6] << " | " << playboard[6][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
cout << "8 | " << playboard[7][0] << " | " << playboard[7][1] << " | " << playboard[7][2] << " | " << playboard[7][3] << " | " << playboard[7][4] << " | " << playboard[7][5] << " | " << playboard[7][6] << " | " << playboard[7][7] << " | " << endl;
cout << "  |____|____|____|____|____|____|____|____|\n";
}

int main()
{
    string playboard[8][8];
    setBoard(playboard);

    //RANDOMLY CHOOSE PLAYER TO GO FIRST
    srand(time(0));
    int random=rand()%(2+0)+1;
    string p;
    if (random==1)
    {
        p="R";
    }
    else
    {
        p="B";
    }
    bool active=true;

    while(active==true)
    {
        system("clear");
        int x;
        int y;
        int cX;
        int cY;
        printBoard(playboard);

        if (p=="R")
        {
            cout << "Player Red's Turn" << endl;
            p="B";
        }
        else
        {
            cout << "Player Black's Turn" << endl;
            p="R";
        }
        cout << "Which piece would you like to move?" << endl;
        cout << "Enter X: ";
        cin >> x;
        cout << "Enter Y: ";
        cin >> y;
        system("clear");
        printBoard(playboard);
        cout << "Where would you like to move " << cX << "," << cY << endl;

// PUT MOVE PEICE HERE

        for(int i=0; i<8; i++)
        {
            for(int j=0; j<8; j++)
            {
                if (playboard[j][i]=="B"||"R")
                {
                    active=true;
                }

            }
        }
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.