• (2 Pages)
  • +
  • 1
  • 2

Chess Board and Moving Pieces in C++ How to make a simple chess program Rate Topic: ***** 2 Votes

#16 dr.tiberius  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-February 10

Posted 25 February 2010 - 05:32 PM

Very nice tutorial .
Was This Post Helpful? 0
  • +
  • -

#17 PlasticineGuy  Icon User is offline

  • mov dword[esp+eax],0
  • member icon

Reputation: 281
  • View blog
  • Posts: 1,436
  • Joined: 03-January 10

Posted 01 March 2010 - 02:27 AM

Solution for all your issues with Dev-C++: Stop using such an old IDE.
Was This Post Helpful? -1
  • +
  • -

#18 Guest_Tyr*


Reputation:

Posted 01 April 2010 - 08:39 AM

When will part 2 be posted?
Was This Post Helpful? 0

#19 Deepglue555  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 110
  • Joined: 13-April 09

Posted 28 June 2012 - 09:07 AM

View PostTyr, on 01 April 2010 - 09:39 AM, said:

When will part 2 be posted?



Wow, I forgot entirely about a part 2 for ages.

The good news is I have the Visual Basic 6.0 code for a full working chess program all legal rules including the intricate ones, all written by me years ago and documented in a youtube video I made of it.

Also good news, I ported it all to C++, working and everything..

Slightly bad news is I never commented any of my code (bad programming practise .. I know ..).

However now I can put it on my to do list, 1.) To comment the code, 2.) To make it a tutorial for here 3.) to port it to Microsoft Visual C++. (From Borland C++ 6).

The bad is news is I will be doing thousands of computer science students homework for ages.. and they might not really learn how to improvise code the way I did, but they can still learn from the comments and tutorial providing I finish that. I did not program this chess player for optimized speed, but rather than passing arrays of integers or doubles I used strings to be passed and received between functions. (Strings are generally slower).

However it does the job and plays 99.x% legal moves. (The game of chess has lots of legalities to take into consideration such as 'en passant' and the 50 move rule, all of which I programmed into the programs rule deductions when a human or computer moves). I didn't however program the more intricate rules into the AI or computer past the first ply.

Programming a computer to detect legal and illegal moves even not including the en passant and other rules but just piece movements is monotonous and tedious kinda boring, however commenting it wont be as much. But there is alot of code and I'm not sure what time frame I might do it in or when I might start that.

I will put it on my todo list to A.) Port the working code from Borland to the latest Microsoft Visual C++ (Win32 console). B.) comment the code C.) Create the tutorial for those interested here.

And/or do the same for the Visual Basic 6.0 version but just commenting the code and making the tutorial.

(I had tried the automatic converter for VB6 to VB.net and it failed and even destroyed the current version of the source code I had for it and had to revert to a slightly inferior source code i had backed up for it [years ago btw]).

Also the AI/Engine needs a complete rework, the harder I worked at making it more intelligent and adding pruning the dumber and crazier it got (after a certain point).

...

I will update you when I attempt to start this.
Was This Post Helpful? 0
  • +
  • -

#20 Deepglue555  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 110
  • Joined: 13-April 09

Posted 28 June 2012 - 10:44 AM

Ok, I took a look at the C++ source code and it is huge, 2471 lines of code. And I didn't even port the engine to the C++ code.

Commenting all of that might be a mid sized book worth of information. Not sure it's a tutorial the readers would just get through in a day or two.

Also I coded the UCI protocol into it, enough to play a human by the 'computer' choosing any randomly chosen legal move.

This might be too long for a tutorial I guess, is there another classification I would use for it if I did it as a tutorial?

The VB6 version is about 6800 lines of code but alot of that is GUI parameters and stuff that VB6 injects to tell the visual stuff where to place and how to work.

I might have to write a dumbed down version of just legal moves for the pieces and take king in check legal moves into consideration.
Was This Post Helpful? 0
  • +
  • -

#21 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 710
  • View blog
  • Posts: 2,033
  • Joined: 20-March 10

Posted 29 June 2012 - 01:44 PM

You can just

Split the Tutorial into parts if it is too large

If it is 6000-7000 lines of code consider
splitting it into 6 parts.

Best Wishes

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

#22 vincent_dk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-July 12

Posted 05 July 2012 - 05:10 AM

Thank for share, i need it! :bananaman:
Was This Post Helpful? 0
  • +
  • -

#23 gopal1432  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-September 12

Posted 12 September 2012 - 09:57 PM

[quote name='Deepglue555' date='11 May 2009 - 02:04 AM' timestamp='1242032669' post='637420']
[code]
#include<iostream>
#include<string>
#include<stdlib>


// in this example pieces aer described as integer values
// we will make them constants, so that if at any time we want to change their values we can do so here
// but will still need to recompile

const int pawn = 100;
const int bishop = 305;
const int knight = 300;
const int rook = 500;
const int queen = 900;
const int king = 2000;

  • why are you using const int pawn=100;
  • how you can indicate the 100 to pawn

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#24 Namshum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-October 12

Posted 18 October 2012 - 01:20 AM

Hi! Deepglue555 when will you finish the 2nd part of Simple Chess
Was This Post Helpful? 0
  • +
  • -

#25 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8393
  • View blog
  • Posts: 31,214
  • Joined: 12-June 08

Posted 18 October 2012 - 06:59 AM

The tutorial was posted 11 May 2009.

The OP hasn't been on since August. It might be a while.
Was This Post Helpful? 0
  • +
  • -

#26 Namshum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-October 12

Posted 18 October 2012 - 11:09 PM

Hi #25 modi123_1 Can you suggest a move generator on the basis of the code of deepglue555
Was This Post Helpful? 0
  • +
  • -

#27 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8393
  • View blog
  • Posts: 31,214
  • Joined: 12-June 08

Posted 19 October 2012 - 07:03 AM

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

#28 Namshum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-October 12

Posted 20 October 2012 - 12:55 AM

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

  • (2 Pages)
  • +
  • 1
  • 2