473,396 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Draughts console game

i am trying to write a simple program that allows players to start a new game of draughts, store the status of the game and allow players to make moves...can anyone please give me tips on how to get started? I have found some info on the net but it is too complicated to understand.... any help is appreciated

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <graphics.h>
  6. #include <stdlib.h>
  7.  
  8. /* INITIALIZE ARRAY */
  9. int Status[8][8]={{1,5,1,5,1,5,1,5},{5,1,5,1,5,1,5,1},{1,5,1,5,1,5,1,5},{5,0,5,0,5,0,5,0},{0,5,0,5,0,5,0,5},{5,3,5,3,5,3,5,3},{3,5,3,5,3,5,3,5},{5,3,5,3,5,3,5,3}};
  10.  
  11. /* DRAW DAMA BOARD */
  12. void DAMABOARD ()
  13. {
  14.    cleardevice();
  15.    setcolor(14); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
  16.    outtextxy(335,70 ," LET'S PLAY CHECKERS!");
  17.    setcolor(10); settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  18.    outtextxy(320,100," ÉÍËÍËÍËÍËÍËÍËÍËÍ»");
  19.    outtextxy(320,115,"0º º º º º º º º º");
  20.    outtextxy(320,130," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  21.    outtextxy(320,145,"1º º º º º º º º º");
  22.    outtextxy(320,160," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  23.    outtextxy(320,175,"2º º º º º º º º º");
  24.    outtextxy(320,190," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  25.    outtextxy(320,205,"3º º º º º º º º º");
  26.    outtextxy(320,220," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  27.    outtextxy(320,235,"4º º º º º º º º º");
  28.    outtextxy(320,250," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  29.    outtextxy(320,265,"5º º º º º º º º º");
  30.    outtextxy(320,280," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  31.    outtextxy(320,295,"6º º º º º º º º º");
  32.    outtextxy(320,310," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
  33.    outtextxy(320,325,"7º º º º º º º º º");
  34.    outtextxy(320,340," ÈÍÊÍÊÍÊÍÊÍÊÍÊÍÊͼ");
  35.    outtextxy(320,355,"  0 1 2 3 4 5 6 7 ");
  36.  
  37.    setcolor(11); settextstyle(SMALL_FONT,HORIZ_DIR,5);
  38.    outtextxy(5,380," Direction:");
  39.    outtextxy(5,400," Press a number from 0 to 7, to get the row and column value.");
  40.    outtextxy(5,420," Press <ESC> to quit.");
Mar 2 '07 #1
3 3393
DeMan
1,806 1GB
Try to simplify the game into simple steps,
refine these simpler steps into more manageable processes,
continue this until you have little tasks to implement.

One approach (Top-Down programming I think).....is to wrtte the steps as code.
Then you need to implement the steps to do what they're supposed to, but we can apply the same principle again/.
eg
Expand|Select|Wrap|Line Numbers
  1. while(!gameFinished)
  2. {
  3.   thisPlayer.makemove();
  4.   displayBoard();
  5.   thisPlayer = nextPlayer();
  6. }
  7.  
We have just decided that we need to implement a player class, that it needs to have at least the methid makeMove, that we need a routine for displayBoard and that we need some way to move ionto the nextplayer.,.....

you can first implement minimal functionality (ie so long as nextPlayer returns something (which can be null initially)the code would compile. (provided you have DEFINED these methods (they don't actually have to DO anything yet)).
Once you start working on a particular method, you can use the same idea of refining what it actually is that you want the method to do.

If you have time afterwards, you can go through and find redundant methods ->things that seemed a good idea at the time, but can be better done another way
Mar 2 '07 #2
Thanks for your help but I am still struggling with it

Can you help me with the code below

# include <stdio.h>
# include <math.h>
# include <ctype.h>
# include <graphics.h>
# include <stdlib.h>

/* initilize array E=Empty, WP= White Piece - uncrowned, BP = Black Piece - uncrowned */

int Status [8] [8] = {{ BP, E, BP, E, BP, E, BP, E }, { E, BP, E, BP, E, BP, E, BP}, { BP, E, BP, E, BP, E, BP, E }, { E, E, E, E, E, E, E, E }, { E, E, E, E, E, E, E, E },
{ E, WP, E, WP, E,WP, E,WP }, { WP, E, WP, E, WP, E, WP, E }, { E, WP, E, WP, E, WP, E, WP} } ;

/* allow user to start a new game of draughts */

printf( ''Select new to start a new games: ''\n ) ; /*prompt*/

while(!gameFinished)
{
thisPlayer.makemove();
displayBoard();
thisPlayer = nextPlayer();
}

I need to store the status of the game, can anyone help?
Mar 4 '07 #3
DeMan
1,806 1GB
You can either pass a flag through the method(s) that make a turn, or you could set up a global flag that can tore the state of play
Mar 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Moosebumps | last post by:
When I have time, I am planning to evaluate Python for console game development (on Playstation 2, GameCube, and Xbox). Does anyone have any experience with this? Pretty much the only resource...
4
by: Bob | last post by:
I just recently noticed that when I start my applicatoin in debug mode, the IDE hangs (no disk or CPU activity) indefinitely (at least 20 minutes). Pausing the application shows that it's hung up...
0
by: Rahtgaz | last post by:
Hello everyone, I'm wanting to start implementation of a pet project game IO mechanism. The game is console based. A cross between MUD and Rogue types. For I/O operations I'll be using ncurses...
2
by: mer000 | last post by:
Can you guys help me out? I'm trying to create a very simple game of craps but having some trouble. Below are the rules and requirements. Much appreciated! Given the following rules for the game...
0
by: Shawn Minisall | last post by:
For my final project, I'm trying to do a GUI based game similar to are you smarter then a 5th grader. I've been working on it and am stuck with some code someone helped me with to randomize the...
2
by: Z E R O | last post by:
I'm in a really fast pace training program and we are covering a lot of material in a relatively short period of time. I've really not had much trouble up until this problem. I had to do one other...
19
by: foolsmart2005 | last post by:
I have written a snake game. There are 2 levels in the game(I finished 1st level). It can run in VC++ without problem but, when I run it on the dev C++ 4.9.9.2, it cannot run. I want to...
2
by: fairie | last post by:
It seems my choices aren't working out as I'd like. So from the first area when I input choice number 3, it should send me to the fourth area, as per the {3, 3, 0} - but it stays at the first area. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.