Draughts game

Hello, everyone.
I want to code a turkish draughts game. But i dont know where to start. I dont have any idea about how to code it. I dont want the entire code from, I only need ideas. Can you help me?

If you dont know turkish draughts: http://en.wikipedia.org/wiki/Turkish_draughts
http://www.gamerz.net/pbmserv/dama.html
You need to think about a few things first.
- Is this going to be text based (console), or graphics based?
- If graphics based, what graphics library?
- How complex do you want the computer's logic to be? i.e. does it do move look-ahead to find the best move?

My suggestion is to start with a simple text based version. Keep the text displays well isolated so that if you later decide to move to a graphics version, the text displays are easily replaced. Get the program logic working well before trying to move to a graphics version.
i have started to work. It will be turn based(two players on one computer).
And i dont think to use any graphic it will be a text based console game
Some obvious things to work on:
- Drawing the board. How to represent the each side's pieces.
- How to accept input from the players?
- How to input jumps (captures)?
- Checking for game over. After each player's move, check for win or draw.
- Checking each player's move is legal.
i have started from drwing the board. For that i code like that:

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
#include <iostream>

using namespace std;

int tahta( string dama[ ][ 8 ], string oyuncu);
//int kontrol( string );

//int x;
//int y;


int main()
{
	string dama[ 8 ][ 8 ];
	
	string oyuncu1;
	string oyuncu2;
	
	for( int i=0; i<8; i=i+2)
	{
		for( int j=0; j<8; j=j+2)
		{
			dama[ i ][ j ]="|   |";
		}
	}	
	
	for( int i=1; i<8; i=i+2)
	{
		for( int j=1; j<8; j=j+2)
		{
			dama[ i ][ j ]="|:::|";
		}
	}
	
	tahta( dama , oyuncu1 );
	//kontrol( tas , oyuncu1 );
	//hamle;
	
	//tahta( dama , oyuncu2 );
	//kontrol( tas , oyuncu2 );
	//hamle;
	
}




int tahta( string dama[ ][ 8 ] , string oyuncu )
{
	for( int i=1; i<8; ++i)
	{
				
		for( int j=1; j<8; ++j)
		{
			cout<< dama[ i ][ j ];
		}
		
		cout<<endl;
	}
	cin.get();
}




but its looks like that when i run it:
1
2
3
4
5
6
7
|:::||:::||:::||:::|
|    ||    ||   || 
|:::||:::||:::||:::|
|    ||    ||   || 
|:::||:::||:::||:::|
|    ||    ||   || 
|:::||:::||:::||:::|




Last edited on
The first thing I notice is that your board is an 8x8 array of strings.
I don't think you really want to represent each cell as a string.
You should also separate the display of the board from the playing of the game.

Are you doing this as an exercise to learn C++?
If so, I'd strongly suggest you make the board a class, with an array of cells representing each square. You could make each cell an enum such as:
1
2
3
4
5
6
7
8
  enum cell = 
    { empty_white = 0,
       empty_black = 1, 
       occupied_white_red = 2,
       occupied_white_black = 3, 
       occupied_black_red = 4,
       occupied_black_black = 5,
    };

Note from the enum that each cell can have 6 states. You may end up with more states (jumped, etc) as your game develops. I would actually recommend making each cell a class. In the enum above, I've combined several conditions (base color, occupied, piece color) into a single enum. That's not really the best idea. It's better to keep those states as separate variables in a class.
Here is part of a class I use to draw a very nice board in text mode on the console using the MS-DOS code page (437).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class CONSOLE 
{  static const unsigned char DBL_UL_CORNER = 201;
    static const unsigned char DBL_HORIZ_LINE = 205;
    static const unsigned char DBL_TOP_TEE = 209;
    static const unsigned char DBL_BOTTOM_TEE = 207;
    static const unsigned char DBL_LEFT_TEE = 199;
    static const unsigned char DBL_RIGHT_TEE = 182;
    static const unsigned char DBL_UR_CORNER = 187;    
    static const unsigned char DBL_LL_CORNER = 200;    
    static const unsigned char DBL_LR_CORNER = 188;    
    static const unsigned char DBL_VERT_LINE = 186;    
    static const unsigned char SINGLE_HORIZ_LINE = 196;
    static const unsigned char SINGLE_VERT_LINE = 179;        
    static const unsigned char SINGLE_CROSS = 197;        
   
public:
    CONSOLE ();
    virtual ~CONSOLE ();
        
    void DisplayUpperLine (int len);
    void DisplayMiddleLine (int len); 
    void DisplayBottomLine (int len); 
    void DisplayVertLine (bool dbl);
};


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
void CONSOLE::DisplayUpperLine (int len) 
{  cout << DBL_UL_CORNER;
    for (int i=0; i<len; i++)
    {   cout << DBL_HORIZ_LINE;
         if (i == len-1)
             cout << DBL_UR_CORNER;
         else
             cout << (DBL_TOP_TEE;
    }	        
    cout  << endl;
}

void CONSOLE::DisplayMiddleLine (int len) 
{  cout << DBL_LEFT_TEE;
    for (int i=0; i<len; i++)
    {   cout << SINGLE_HORIZ_LINE;
         if (i == len-1)
             cout << DBL_RIGHT_TEE;
        else
            cout << SINGLE_CROSS;
    }	        
    cout << endl;
}

void CONSOLE::DisplayBottomLine (int len) 
{  cout << DBL_LL_CORNER;
    for (int i=0;i<len; i++)
    {   cout << DBL_HORIZ_LINE;
         if (i == len-1)
	cout << DBL_LR_CORNER;
        else
              cout << DBL_BOTTOM_TEE;
    }	        
    cout << endl;
}

void CONSOLE::DisplayVertLine (bool dbl)
{   if (dbl)
         cout << DBL_VERT_LINE;
    else
        cout << SINGLE_VERT_LINE;
}			    
Last edited on
yes it is an exercise but i dont know how to use classes so i dont know how can i give a position to cells using enum. I am plaaning to make the board as a string. And the men will be strings too. and i will ask each player to coordinate of the man which he want to play before asking where he want to play the man. then i will check if he can play again(jumping). İf he can i will give the second change of playing
Topic archived. No new replies allowed.