Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / chess or checkers demo

Author
Message
jayceeDB
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 27th Jul 2003 06:03
Hi,

I just got DB Pro and am pretty excited. I want to do a type of "combat chess" game. The first step for me is to be able to move pieces and keep track of them on the squares of the board.

I got the 3D chess pieces, but I don't know how to make the link between keeping the array updated and the pieces on the board updated. How is one square on the board different from another?

Does anyone know of any code snippets or demos that illustrate this? Any chess or even checkers game code out there?

Also, is there a mechanism to do a search on these discussions? I looked around but (other than scrolling through the subjects) can't find any way to search for things.

Thanks for any help,
john...
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 27th Jul 2003 06:41 Edited at: 27th Jul 2003 06:55
I'm making a chess game. See http://www.freewebs.com/andrew11/projects/3D_Chess/home.htm.

Right now I am taking a break from it but I plan to go back and finish it soon.

Believe me its not easy. The positioning pieces is easy enough. So is telling which pieces can move where. The real hard part is the AI. A chess game AI has to be able to look many moves in the future and calculate gains/losses.

In my game, each piece has an array, containing the piece type, the Rank and File of the piece and if it exists. Evry loop the program repositions pieces, and all movement is done with the arrays. Other functions tell the program what places it can move, and where to highlight the board. The AI looks at every move like a tree, a certain number of turns, based on difficulty setting. It then calculates every move based on piece worth (King being infinite), and makes the best move.

I would reccomend starting on a checkers game. It uses same basic rules like this, but is alot simpler, because pieces can only move 2 directions.

Also, I know you don't want to hear this but, if you are just starting out, you should do some simpler stuff, the basics.

P.S. There is a search (sort of). Go to the general section and click the first post at the top.

"All programmers are playwrites and all computers are lousy actors" -Anon
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 27th Jul 2003 07:08 Edited at: 27th Jul 2003 07:09
In Java explained on this page

Visual Basic Checkers Page with source code.

The more you see, the more you know.
The more you know, the more you see.
jayceeDB
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 27th Jul 2003 07:16
Hi Andrew,

Thanks for the feedback.

I'm not worried about the look-ahead or the AI aspect. I have an MS in AI Programming, but even with that, I don't plan on using strong AI.

I'm not trying to make a chessmaster type of chess game. It's "combat" chess, so the rules for deciding what to move will be different. For example, the player should think twice before having a pawn take a queen, since the queen (in the combat arena) will be stronger than the pawn.

When I said I was new... I meant to DB programming, not programming in general.

I think I can make my own rules and algorithms for the pieces, and I think I can make the arenas for the pieces to take a square.

My problem is the part where you said was "easy enough".

I'm new to DB and graphical interface type programs. For example, how does the user move the mouse over a pawn and move it, how can I see what square it's on?

Am I updating the array to look like the board? Or the board to look like the array?

I just need a push in the right direction. If I can find out how to move the pieces and update the right structures, I think there are enough tutorials and demos out there to help me with the rest.

Thanks,
john...

Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 27th Jul 2003 07:17
Make a Type

E.g.

Type Places
XPos as Integer
YPos as Integer
Piece as String
Status as Integer
EndType

Dim BOARD (8,8) as Places

The rest is upto the imagination

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
jayceeDB
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 27th Jul 2003 07:22
Let me put it this way...

I'm looking for some well commented sample code on placing and moving pieces on a board in DB Pro. Doesn't even have to be chess.

No AI or anything like that is needed.

Anything like that out there?

thanks,
john...

jayceeDB
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 27th Jul 2003 07:31
Thanks Codger,

But how do I know that one graphic square on the 3DS board is associated to XPos and YPos?

thanks,
john...

andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 27th Jul 2003 07:42 Edited at: 27th Jul 2003 07:54
Ok.. Sorry for treating you like a noob.

I'm sorry, but I cant give you any code. Dont think I'm selfish, but I really want to get mine done. I will tell you how to do it though.

First of all, you need to know the rules of chess. I mean not just how to play it, but really know the rules. Search for "rules of chess" on google or similar. Of course, you probably know how to play chess if you are making a chess game.

You can make your array 2 ways.
1) Have a (32,2) array,the first number being the piece, the second being file (X), and Rank (Z).
2) Have an (8*8) array, the value of each piece at each coordinate.
Which ever is easiest for you. I use #1

Every loop, change the array according to user input or computer. Now say that your board is a 8*8 grid, which is really an 80*80 plain. You would take the value of file and rank and multiply it by 10 because 80/8=10. Then position the object there.

Pretend you are playing chess.

You have the board:
_ _ _ _ _ _ _ _
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|0|

The exact center of the board is 0,0.
The players right rook (0) would be at 35,-35 because it's at file 8, rank 1, so 8*10-45 = 35 and 1*10-45 = -35. You need to multiply by 10 and subtract 45, to convert chess position to 3D position.

Hope that helps.

"All programmers are playwrites and all computers are lousy actors" -Anon
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 27th Jul 2003 07:46 Edited at: 27th Jul 2003 07:51
The Array is the board

Define the z (height) coordiante as 0
This leaves the x,y

make a board 100,100
the 1st position is 5,0,5
the balance of the pieces are 5+(10xX),0,5+(10xY)

position you Pieces per the array

For X = 1 to 8
For Y = 1 to 8
Position Object 1, x,0,y
next Y
Next x

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
jayceeDB
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 27th Jul 2003 07:51
LOL...

Thanks Andrew,

It does help a little. It's not the rules of chess or anything like that that I need.

Once I get into the guts of it, I think I'll be fine. I just need to know how the graphics portion interfaces with the user input.

And I didn't think you were treating me like a "noob".

thanks,
john...

andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 27th Jul 2003 07:55 Edited at: 27th Jul 2003 07:56
I just edited it and made it better. Read it again.

Oh and you'll need ot have something to detect the mouse clicks. Search the forums for a routine, otherwise wait till patch (Update) 5, when they'll be adding native object selection.

"All programmers are playwrites and all computers are lousy actors" -Anon
ReD_eYe
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 27th Jul 2003 11:00
yeah, update 5 with the pick object command will make your job much easier

You know whats weird???
Donald duck never wore pants, yet everything time he got out of the shower he put a towel around his waist...
Whats with that???

Login to post a reply

Server time is: 2026-07-23 04:12:29
Your offset time is: 2026-07-23 04:12:29