14 Replies - 20357 Views - Last Post: 16 January 2008 - 07:00 PM Rate Topic: -----

#1 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Chess Game

Posted 25 August 2007 - 12:38 AM

I am working on a project off and on, Its a chess program, and eventually i want to get it to be with a gui, and i am wondering should i start on the gui now or wait untill im done with the program to do a gui? im not the best at guis yet so thats why im asking.
Is This A Good Question/Topic? 0
  • +

Replies To: Chess Game

#2 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: Chess Game

Posted 25 August 2007 - 12:53 AM

Depends on how you're writing the program. Is it a program that you can interface to from a GUI or from CLI? Or is it pretty dependant on the GUI?

If it's the former; design the CLI version, then add what's needed to make the GUI.

If it's the latter; start building the GUI and implement it as you write your code.

That's my opinion on the matter. Now for older and wiser heads to chime in. :)
Was This Post Helpful? 0
  • +
  • -

#3 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: Chess Game

Posted 25 August 2007 - 12:57 AM

View PostMorphiusFaydal, on 25 Aug, 2007 - 12:53 AM, said:

Depends on how you're writing the program. Is it a program that you can interface to from a GUI or from CLI? Or is it pretty dependant on the GUI?

If it's the former; design the CLI version, then add what's needed to make the GUI.

If it's the latter; start building the GUI and implement it as you write your code.

That's my opinion on the matter. Now for older and wiser heads to chime in. :)


Im making sort of a CLR interface, just a menu and outputs in my code so i can see the program actully work, is that what you mean?

I.E Here is an example of my menu

		while(1)

		{

			//system("cls");

		char choice = 'f';

		cout << "***********CHESS*************" << endl;

		cout << "* a) Play new game		 *" << endl;

		cout << "* b) Load previous game	*" << endl;

		cout << "* c) Exit				  *" << endl;

		cout << "****************************" << endl;

		cout << "?>";



		choice = getch();

		cout << endl;



		switch(choice)

		{

		case 'a':

		case 'A':

		startnewgame();

		break;

		case 'b':

		case 'B':

		playpreviousgame();

		break;

		case 'c':

		case 'C':

		exit();

		break;



		}

		}


This post has been edited by musya: 25 August 2007 - 12:58 AM

Was This Post Helpful? 0
  • +
  • -

#4 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 854
  • View blog
  • Posts: 2,338
  • Joined: 20-August 07

Re: Chess Game

Posted 25 August 2007 - 02:35 AM

If you develop both the GUI and the engine code modularly, then they should be completely independent of one another. Although most likely, you'll come to a situation when creating your GUI when you realise that your chess engine needs extra functionality - similarly, you'll come across UI issues when designing your engine. Thinking about the design from both angles simultaneously may help you design both the application interface, and the user interface.

from an application viewpoint, you probably want to be able to send & recieve event messages between the UI and the engine which contain information such as board coordinates, chesspiece identifiers, valid moves, current board state, etc.. This may help you design your chess engine structure. (You may want to investigate bitboards for implementing the actual chess program logic)

from a UI viewpoint you'll need to decide how the user is going to move pieces around - you don't need a chess engine to drag & drop pictures around a window, so you can do it with dummy callbacks which just output lines of text such as "D2-D4".

you might eventually build an event handling system which acts as the 'glue' between the engine & GUI (in other words, something to handle event messages).. this bit will obviously need to be written once both the GUI and chess engine are up and running

This post has been edited by Bench: 25 August 2007 - 02:38 AM

Was This Post Helpful? 0
  • +
  • -

#5 Pontus  Icon User is offline

  • Cattlebruiser

Reputation: 17
  • View blog
  • Posts: 612
  • Joined: 28-December 06

Re: Chess Game

Posted 25 August 2007 - 06:59 AM

I suggest u build them at the same time. Example: if u have created a large chunk of code, but in some matter of way it wont work with ui that u build after u would have to rewrite that code. As for u might not know what the limitations of your gui will be.
Was This Post Helpful? 0
  • +
  • -

#6 pevlo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-December 07

Re: Chess Game

Posted 12 December 2007 - 05:14 PM

hello to everyone i am new to the forum..i would like to ask sth and i would be very glad and helpful if somebody could help.I have an essay and the deadline is in two weeks.I would like some help in making a chess program in miscrosoft visual C++ .This program has to show all the possible moves of a chess game (which would be loaded by a text.file)and the moves that the player can make with each chessman and make the required controls for every move.Thanks in advance.
P.S:i would like the code in C..and not a program..or anything else helpful
Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Chess Game

Posted 12 December 2007 - 05:20 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#8 pevlo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-December 07

Re: Chess Game

Posted 12 December 2007 - 05:39 PM

View Postskyhawk133, on 12 Dec, 2007 - 05:20 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.



ok i got it :) thanks for the reply i will try to start doing sth and then i will post it ( if i find sth).Anyway thank you very much again.
Was This Post Helpful? 0
  • +
  • -

#9 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5642
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Chess Game

Posted 12 December 2007 - 07:18 PM

It should probably go without saying the an implementation of a chess AI, even a mediocre one, is not a trivial thing. If someone is looking for a computer game player, start with tic-tac-toe or something. Even better, solitaire style stuff where the computer doesn't even have to think.

To the original post, I'd implement the logic first. It's the hard part and should reasonaby be separated from layout and UI anyway. Such separation could seem like a challenge, but it's really very simple. Consider this code:
class ChessBoard {
public:
   ChessBoard();
	void move(ChessBoardPos fromPos, ChessBoardPos toPos);
	ChessPiece getPiece(ChessBoardPos pos);
	void setPiece(ChessBoardPos pos, ChessPiece piece);
	ChessBoardStatus getStatus();
	void clear();
};

class ChessSolver {
public:
   ChessSolver(PlayerLevel level);
	PlayerLevel getLevel();
	ChessBoardPos getNextMove(ChessBoard board);
};



There, all done. Ok, a few more classes and probably some enums, but you get the idea. It's the code behind this that's the hard part. Any UI should be able to hook into something this simple.
Was This Post Helpful? 0
  • +
  • -

#10 pevlo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-December 07

Re: Chess Game

Posted 14 December 2007 - 04:50 PM

hello my friends i am trying to make the beginning..and the first thing i have to do is to load a random chess board that is saved in a text file in an array and print it in the screen..i am trying much time but i guess the code that i have written is wrong ..please help to correct it .
to be more specific i want to load and print in the screen this
BTA1
BKC1
BTE1
BOF1
WKG1
BSA2
WHC2
BSE2
BSG2
WQD4



#include <stdlib.h>
#include <stdio.h>


# define SIZE 20




 void main ()
	

 { 
int array2[SIZE],count;
 count=0;
	 
	 FILE *fp;
	 
	 if (( fp= fopen("text.txt","rb"))==NULL )

	 {

		 fprintf(stderr, "error1");
		 exit(1);


	 }

	 if (fread(array2,sizeof(int),SIZE,fp) !=SIZE)



	 {

		 fprintf(stderr, "error printing");
		 exit(1);

		
	 }
	 fclose(fp);

	for(count=0; count<SIZE;count++)
	printf("%d",array2[count]);
}

Was This Post Helpful? 0
  • +
  • -

#11 Bouclas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-January 08

Re: Chess Game

Posted 15 January 2008 - 05:51 AM

ela re pevlo ti leei i kriti???? re den tin ekanes??? poios eisai??? :ph34r: :ph34r:
Was This Post Helpful? 0
  • +
  • -

#12 carltech  Icon User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: Chess Game

Posted 15 January 2008 - 10:34 PM

like skyhawk133 said, use the code tags, Pevlo.

And baavgai's code seemed easier than i would have figured, although it makes perfect since to do it like that, I wish I was an expert so i do stuff so easily

This post has been edited by carltech: 15 January 2008 - 10:39 PM

Was This Post Helpful? 0
  • +
  • -

#13 jjhaag  Icon User is offline

  • me editor am smartastic
  • member icon

Reputation: 44
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: Chess Game

Posted 15 January 2008 - 11:22 PM

Code tags added. Please remember to :code: next time.
Was This Post Helpful? 0
  • +
  • -

#14 lovely12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 08-January 08

Re: Chess Game

Posted 16 January 2008 - 07:11 AM

good work
Was This Post Helpful? 0
  • +
  • -

#15 pevlo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-December 07

Re: Chess Game

Posted 16 January 2008 - 07:00 PM

bouclas ela re patriwtis ??edw pera de perimena na vrw kanenan:P mia xara apo kriti eisai esi? prospathisa kati psila ekana alla oxi polla prammata..thn eixes k esi? ti ekanes esi?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1