Advertisement

How to program a chess: a forum based tutorial

Started by December 23, 2004 11:09 PM
276 comments, last by da_grat1 19 years, 8 months ago
ok... i will have a look at the code first... there might be a lot of questions I will ask.. just get ready... :)

O yeah.. I tried to play the game vs other player... I think there is something wrong with the rules.. It doesn't follow the rules.. lets say if i place my white pawn at the end of the black board position, lets say i capture the black castle there..usually we can change the pawn to queen, or etc.. but here it doesn't change.. it stuck there ..lol..

another thing is, when we check the king, it will straight away checkmate and the game end.. usually we can still move the king to other position to avoid the check right..

so this is the first question i will ask...
1. what kind of AI search algorithm does beowulf use? is it best first searh..emm I don;t think so.. is it A* algorithm ?

2. // Arrows + Home/End pad
#define UTIL_KEYBOARD_UP 273
#define UTIL_KEYBOARD_DOWN 274
#define UTIL_KEYBOARD_RIGHT 275

the above is how you define for the keyboard arrow key.. can you tell me how to define the alphabeth keys.. such as 'a' . 'b' etc... I think the value is different...such as the #define UTIL_KEYBOARD_UP the value is 273.. what about the alphabeth value key..

[Edited by - da_grat1 on March 29, 2005 1:38:14 AM]
Hey,

My computer parts arrived yesterday, so I've been kinda busy :).

Quote:
1. what kind of AI search algorithm does beowulf use? is it best first searh..emm I don;t think so.. is it A* algorithm ?


I think its something like negamax. You can find a bunch of info on it at:
http://www.chessbrain.net/beowulf/theory.html

Quote:
2. // Arrows + Home/End pad
#define UTIL_KEYBOARD_UP 273
#define UTIL_KEYBOARD_DOWN 274
#define UTIL_KEYBOARD_RIGHT 275

the above is how you define for the keyboard arrow key.. can you tell me how to define the alphabeth keys.. such as 'a' . 'b' etc... I think the value is different...such as the #define UTIL_KEYBOARD_UP the value is 273.. what about the alphabeth value key..


Just use the ascii value. For example if you want the letter c you would pass 'c' to the function.

Keep up the good work,
- llvllatrix
Advertisement
"game_res_draw_button_text(quit, left, right, bottom, top);"

can you explain to me about the "left,right,bottom,top"

"new_button.position(0.0f, 0.5f, 0.0f, 0.06f);"

and this new_button position.. the value of (0.0f, 0.5f, 0.0f, 0.06f).. how do you position it.. is it the same as x,y and z coordinate..
Quote:
can you explain to me about the "left,right,bottom,top"

"new_button.position(0.0f, 0.5f, 0.0f, 0.06f);"

and this new_button position.. the value of (0.0f, 0.5f, 0.0f, 0.06f).. how do you position it.. is it the same as x,y and z coordinate..


There are two ways you can position a ui control and they are both handy for various things. The first and less frequently used is by using absolute coordinates. Basically the idea is that you are constantly updating the left, right, top, and bottom. For example, if you wanted to move the new button to the right then you would change the position to:

new_button.position(0.5f, 5.5f, 0.0f, 0.06f); // just add 5 to the right

This type of positioning is useful if you want to specify the absolute position of the control within a frame or something; the basic idea behind this type of positioning is that you really never want to change it (or at least change it often) because you could inadvertently end up stretching the control. Typically you set the position once and in most cases its easiest to just set it at the origin with the width and height values specified.

So how do we move the control if we're not going to constantly call position? Remember that our engine is completely based on opengl, so we can easily use the glTranslate functions to move anything before we draw it :). Keeping in mind that the origin is at the center, we can produce predictible ui and positioning values which are never distorted.

Using translation, we can position the button within a frame, and then translate the entire contents of the frame together. Translation also makes the code a lot easier to read. There is only one problem with translation; If we translate the controls, how does the mouse know where the control is? To solve this problem, I've written a set of mouse functions that translate the mouse using the inverse of the translation matrix. The end result; the mouse can easily be tested against any control irregardless of its positioning within opengl. The only tradeoff is that you have to "update" your buttons right after drawing them otherwise you will probably loose the gl translation.

Hope this helps,
- llvllatrix
the game seems to have a lot of errors.. lol.. you only will be able to drag the pawn but not the other pieces such as knight.. etc... llvllatrix... can you fix that..
llvlltrix.. try to play the game.. try to play human vs human... once you play then you will discover a lot of bugs.. ;) The one I hate most is the game will end straight away when you check the second players' king while there are still many possible moves.. I think need to fix the beowulf engine.. Do you have time for that... :)

ohh yeah... another question

"glLoadName(8*z + x)" and "InitName"
what are those functions for?

[Edited by - da_grat1 on March 30, 2005 3:25:00 PM]
Quote:
the game seems to have a lot of errors.. lol.. you only will be able to drag the pawn but not the other pieces such as knight.. etc... llvllatrix... can you fix that..
llvlltrix.. try to play the game.. try to play human vs human... once you play then you will discover a lot of bugs.. ;) The one I hate most is the game will end straight away when you check the second players' king while there are still many possible moves.. I think need to fix the beowulf engine.. Do you have time for that... :)


lol, yah; I was playing it the other day and noticed the same thing :) Things like that shouldnt be too hard to fix, so i'll leave it up to u guys.

Quote:
"glLoadName(8*z + x)" and "InitName"
what are those functions for?


These are functions used for "picking" or collision detection with the mouse to the individual pieces on the board. You can find out more about picking from:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32

Unfortunately, I wont be able to do another game with you guys this month. I have to get ready for my next term at University, which starts two months from now. However, I should be able to get things rolling again in september. That said, here are a few of the things we will have to tackle:

Converting the tutorials into a manuscript for the book:
If everything goes according to plan, we should be able to convert our tutorial into a full fledged text book. This will consume most of my free time, but I think a lot of people will benefit. The text book will contain most of what has been presented here, along with more information on design and working on large projects. I will make sure to keep you guys up to date on what is going on with the book and of course I value your input. If theres an area you want to know more about, I'll do my best to accomodate you in the text.

Creating more new games with the engine:
So we have a pretty comprehensive engine and why not use it :) I would like to spend about the first month in september creating one small game (just one level) from the most common genres using the engine. The format will be same online tutorials. Naturally, we will be adding more to the engine as time goes by to accomodate our new games. So you guys have 5 months to come up with ideas for the games you want to tackle. These games will also end up in the text as well.

Cheers,
- llvllatrix
Advertisement
alright....I'll wait till september for our new game.. :)
good luck for your exam..
llvllrix....

everytime when i check the king it will be checkmate...just want to know whether the problem comes from the beowulf AI ENGINE... or you forgot to link it with the chess rules...
since you said it is simple :) can help to solve that problem? just the king problem.. because no fun.. everytime i play with my friend i will be the first one to lose the game... because he always check my king first.. due to that problem, we have to avoid from checking each others' king... :) because it will end the game..oo yeah.. there is no castling aswell :) maybe you can solve the problems in 20 minutes... really wish for that...

This topic is closed to new replies.

Advertisement