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.

Geek Culture / Best approach to making Chess?

Author
Message
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2011 07:02
Thinking about making a chess game and not sure what the best approach will be. I'm 90% sure I will use an array system with the GDI grid but not sure if I should use a formula for movment or if their is a easier way. Anyway one elses thoughts? How would you approach making a chess game?
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 31st Dec 2011 08:36
I've often thought about how one would make a chess game. I think using formulas and checks would be the best way for determining legal moves and using an array is the most logical way of doing this. The hardest bit would be the A.I though. Making a legal move is one thing but making a strategic move is another. How 'smart' do you want the computer to be? Smart enough to challenge a grand master or just for a fun game of chess?

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 31st Dec 2011 12:10
I'm helping my friend make a chess game in java. The structure doesn't have to be too complicated. We have a couple major classes: ChessBoard, ChessPiece (abstract), and then the concrete classes like Pawn, Rook, etc. that inherit from ChessPiece. The ChessBoard has a 2d array of ChessPieces. Each ChessPiece has a method "move" which takes in a ChessBoard (since they're accessed through ChessBoard, you should always be passing in "this"), and the position you want the piece to move to. That's the function that handles all the logic.

Really, the logic of moving is just a bunch of if statements. IF the space in front of the pawn is open THEN move it AND if it's occupied THEN don't, BUT if it's at the very end of the playing field...

There's no special plug and play formula (that I know of) that will handle all these cases, so you just have to hardcode them, and it's good to make sure you have everything compartmentalized so that you don't end up with like 300 straight lines of what I was saying above. Make sure you have all the movement code in separate functions and that the code for moving a pawn is independent of the code for moving something else. Also, everything should be accessed through the ChessBoard class (if you're coding in a procedural language then just worry about compartmentalization).

Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 31st Dec 2011 12:55
I'd make it online. Easier than AI. I'd also not bother with enforcing any rules. Let players set up the pieces how they want, and cheat if they feel like it.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 31st Dec 2011 13:14 Edited at: 31st Dec 2011 13:27
The problem with chess isn't really calculating the AI, it's managing all that data.

For instance, if you give each chess piece a value based on it's movement from the middle of the board, you can easily work out a score for each player, and use that to find the best moves. For the current player, fill an array with all the possible moves, then work out the possible moves for the opponent after each initial move, then repeat for however many moves ahead. Work out the score for a good number of possible move chains, then pick the initial move that leads to the best score. You can expand, and flag the board for pieces that are under threat, and reduce the score accordingly. For instance a pawn might be worth 2, a rook worth 32, and a knight worth 8 - but the king would be exagerated, like worth 1000 points as thats the main goal... total the piece values, and you know the moves that affect the board, work out values for the whole moves chain and see which moves work out in the long run.

The problem is, that the data footprint expands exponentially, so within 3 moves you might need over 100,000 array indices. And your still only checking one move for the opponent. I found that having 2 arrays, one for the current move, then an array to hold the chain of moves with the scores that can be checked. It's a lot of calculation and a lot of memory, most engines would discard the moves that don't improve the board coverage or score, to keep the memory footprint down.

Health, Ammo, and bacon and eggs!
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2011 18:11
Im currently discussing this with my friend who has over 15 years exp in C++. He suggested the hard part would be the AI. everythign else he suggested would be simple case statments or If's. However he suggested select case to keep it organized. Of course we will be making are version in VB. However, I think we might adopt some C++ code to help are version a long.

But ultimately im with Hodgey, the hardest part will be AI. I think it might be best for the AI if I talk to a chess master about suggested moves etc. Movments will be fairly easy using a simple grid system 1,1 1,2 1,3 etc. Which a simpe array can make a grid and keep track of location. I don't think point system would be needed, the goal is to capture the King; so I don't see a need for a point system.

The best way I think would be setup a X, Y grind for position. Of course that is a fairly common used thing for those who work with 2D a lot. Of course your x and y would need to have values based on your array. From what Ive seen, 99% of chess games out there use the same or simular concept. Still not 100% on this subject though. It would be interesting though to see what you guys come up with using DB, VB, C++, Java or other langs to see how you decided to make it work.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 31st Dec 2011 18:37
Quote: "I don't think point system would be needed, the goal is to capture the King; so I don't see a need for a point system."


Facepalm.

Giving each piece a point value is the basis of chess AI, there is no other way to calculate the value of moves. I'd be happy to put my code where my mouth is.

Health, Ammo, and bacon and eggs!
xplosys
19
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 31st Dec 2011 19:00 Edited at: 31st Dec 2011 19:03
Quote: "I don't think point system would be needed, the goal is to capture the King; "


That makes your version of chess much easier to code. Just keep moving pieces toward the opposing King.

If you're not doing this for fun or the learning experience, then I wouldn't bother. There are a virtual plethora of good, free chess games available for download.

Brian.

!retupmoc eht ni deppart m'I !pleH

Hassan
16
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 31st Dec 2011 19:57 Edited at: 31st Dec 2011 20:47
it's actually very easy i made several chess games with rules, though i don't have any of them at the moment, they were too old, but it was not hard at all

i used to have an 8x8 array of pointers to a structure, if the value is not NULL, the structure tells what type of piece is on this square, it's color and the ID of the object it's representing, once you set up that, the rest is easy, for example to move a piece you simply call a function that enumerates possible moves for it (used to do it in a vector), and then check if the desired move is valid, if so, then just make the new square on your array point to the old square element and set the old square in the array to NULL (do not "delete" anything), and meanwhile, you should be playing the animation of the piece moving from old position to new position.

i used new/delete operators to initiate the board/destroy a piece

i had all object positions handled by multiplying by 100 then adding 50, so 0,0 in the array would be 50, 50, 1,1 would be 150, 150, and so on

for the AI, it wasn't very easy, i got bored after creating an AI that could just think of 1 step forward without taking consequences into account, AI was pretty boring to code

good luck!

EDIT:
i found my latest attempt on one of the hdds, attached with the post, it was not written with GDK, i wrote it with an old version of my engine, very outdated so it won't work, but it's commented so it might be of some help, it does not have any code for move validation or such, it might use different ways than described above, there are 2 projects, "Hassan Chess AI", which is an application that is supposed to handle a player's AI, and "ChessAI Framework" which is responsible for rendering the actual events, i wrote that so me and another coder could just modify the chess AI (1st project) and the 2 AIs plays against eachothers

Attachments

Login to view attachments
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2011 23:33
Thank you Hassan, I'll give this a shot after I finish my other projects.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Jan 2012 03:58 Edited at: 1st Jan 2012 04:01
Quote: "I'd be happy to put my code where my mouth is."


No response?

Nobody feel like a code challenge with chess AI, a learning experience for anyone willing to have a go at a chess engine.

It's fine if nobody is interested in actually doing something, but really I'm dog tired of trying to advise people who cannot be advised. If Old School thinks that his principles would work, then surely having a challenge against a different technique could only possibly improve and strengthen their own techniques.

So what do you say Old School, fancy making a chess engine, and putting it head to head against my own idea and other peoples, with the goal of strengthening all our techniques, and learning from others. We could use a temporary interface to play engines against each other automatically to find out the top system. What if we said that anyone with a fresh chess engine can go head to head at the end of January, so like a month to come up with a chess engine, then an extra week to impliment what we learn and see how clever and effective we can make our engines. This could only ever benefit development in my opinion - I mean I've been thinking about a solid game system for an AppGameKit project, having a chess game that is played on any format against any format would be interesting, but a strong AI engine on top would be great to make it a more rounded game. Are you planning on dismissing any piece of advice I have, or do you ever intend to pay it any mind. Let me know so I know whether or not to read your posts and consider my opinion and any advice I might have, or dismiss it all as hot air.

How about this... In 1 month I'll release an AppGameKit cross platform chess game with AI, anyone who wants to improve their techniques or just go head to head for fun is welcome to get in touch with me and colaborate, and investigate the results between different engines in order to learn and improve.

I'm not calling anyone out, I just want a little challenge, and chess AI seems to be ideal for stretching the old brain cells. Maybe I'm a bit tired of my constant, current project which has quite annoying quality demands (shine shine bloody shine) and just want to have to think for a little while. I think that its especially old school, if you know what I mean - language needn't be a factor other than processing speed, other than speed it's all about the AI technique. Chess AI techniques would help in other projects, which is the main draw for me. I think that the techniques in effective chess AI can apply to other AI engines, for RTS games especially - which I want to tackle again soon as the genre seems quite stagnant right now.

Health, Ammo, and bacon and eggs!
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 1st Jan 2012 06:26
Quote: "really I'm dog tired of trying to advise people who cannot be advised"


I hate to sound rude so please don’t take offense but why did you single me out, out of all the responses. I mean I’m all for getting around to making a chess game sometime but I’m not going to go make it tomorrow. I also don’t understand why you say “I’m tired of advising the unadvisable”. I hate to say this but some people are not good teachers. I’m not trying to imply you’re a bad teacher but sometimes you don’t make any sense to me logically speaking. I’m sure most of us listen to what you say but sometimes it does not always make sense or we find a different way that makes more sense to us. To me the joy of programming is discovery and finding solutions that make sense to myself. Another great thing about programming is there is not one right answer to a problem. I can make something have the same result a million different ways. But I guess that’s the magic of programming and being a programmer. We never stop learning and you can never truly master it. It’s a endless language of possibilities.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Jan 2012 06:39 Edited at: 1st Jan 2012 06:41
Quote: "Nobody feel like a code challenge with chess AI, a learning experience for anyone willing to have a go at a chess engine."

That would make an amusing competition actually. Who can code the 'smartest' chess engine. Play them against each other, see which engine is the best.

Quote: "How about this... In 1 month I'll release an AppGameKit cross platform chess game with AI"

Would that be in BASIC or C++?

Quote: "anyone who wants to improve their techniques or just go head to head for fun is welcome to get in touch with me and colaborate"

I'd really like to take you up on that offer VanB but I'm a bit busy over the next month or two. If you started up a chess design theory thread I'd certainly engage in that.

I have a few quick AI theory questions:
1) How would you handle the openings? Would you hard code a bunch of them (as well as their counter-attacks, variations etc) and pick a random opening or would you pick 1 of the possible 10 pieces that can begin and simply let the AI work with that?
2) How would you decide when to castle (swap a castle/rook and king)?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Jan 2012 17:21
Quote: "I hate to sound rude so please don’t take offense but why did you single me out, out of all the responses. I mean I’m all for getting around to making a chess game sometime but I’m not going to go make it tomorrow. I also don’t understand why you say “I’m tired of advising the unadvisable”. I hate to say this but some people are not good teachers. I’m not trying to imply you’re a bad teacher but sometimes you don’t make any sense to me logically speaking. I’m sure most of us listen to what you say but sometimes it does not always make sense or we find a different way that makes more sense to us. To me the joy of programming is discovery and finding solutions that make sense to myself. Another great thing about programming is there is not one right answer to a problem. I can make something have the same result a million different ways. But I guess that’s the magic of programming and being a programmer. We never stop learning and you can never truly master it. It’s a endless language of possibilities. "


Van B is a very advanced programmer. His ideas are very good. Points systems are hidden points that the computer uses to figure out what is the best move. Neural Networks use point systems too, and they simulate a brain, so you can't get much better than simulating a brain.

old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 1st Jan 2012 22:51
Quote: " advanced programmer"


I hate to pick at peoples posts but I want to make a point super fast. There is no such thing as a "advanced programmer", programming is logic. my good friend Steve who has studied C++ for over 15 years and whom currently is a professor will even tell you he is a newb. It will take you roughly 6 weeks to read a book and understand how to program/logic concept behind it. However, you will learn something new everyday when you program.

No one can ever "master" programming or a programming language. Technology changes, the language changes and so on. Also need to understand programming is about taking a idea and writing it down in logical steps or creating a solution using logic. So no one programmer is greater than another. They just have different solutions/ideas on how something should be done logically.

If you read the posts above you can clearly see this put into practice. I personally think Hassan had the best approach because he stated briefly but clearly how he had accomplished certain aspects of making a chess game. However, a few others disagreed. That does not make his argument any less valid, it just means others have a different idea on how to accomplish to goal. Also something that can be said that is stereotypically is that most programmers have a degree of arrogance. If you read the posts you can some of us do come across a bit arrogant about are solutions. Our strong opinions should not cloud your judgment and make you sway toward someone else’s ideas. In the end, the best solution is the one that makes the most sense to you and the one you know you can write your self with little or no help. I hope this helps you in the future.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Jan 2012 00:37 Edited at: 2nd Jan 2012 00:37
Quote: "If you read the posts you can some of us do come across a bit arrogant about are solutions. "

I didn't find that at all... maybe you're projecting?

Obviously someone who programmed in C++ for a day will be worse than when they studied it in 15 years. Also, you can learn methods of logic that improve how you think! If no one had suggested that I use a barnes-hut tree to improve the speed of a code I might still be writing extremely slow stuff. There is CERTAINLY a degree of beginner<intermediate<advanced in programming.

Also: Hassan's post doesn't explain AI, so it can't be compared to a point system?

Quote: "I hope this helps you in the future."

this isn't arrogant?

old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 2nd Jan 2012 01:09 Edited at: 2nd Jan 2012 01:12
Quote: "Quote: "I hope this helps you in the future."
this isn't arrogant?"


That’s simply hoping everyone has learned something from the discussion as a whole.

So once again I hate to poke holes in posts but here we go again. Books are great for providing samples and for use as a reference but I don't think you should do everything by the book. The methods in books are suggestions and tools to get you thinking in a logical sense. The true successful programmers are the ones who can think out side the box and solve problems not written in books.

Moving on, Hassan's comment to me personally laid the foundation in my mind on how to write the software. Using his suggestions I can write about 85% of the software and the remaining AI would fall into place. Now that is my personal thoughts, yours may differ.

So again programming is about discovery, not falling in line and conforming to the rest of the world’s ideas. To me it's about creating a concept inside my head and bringing the concept to life through code. Your personal thoughts of programming may differ from mine but that is why it's called "Computer Theory". Just like any science, there are certain known aspects or also commonly known as "laws" in the science world.

However, theories and laws were not created/discovered by reading books and saying that must be true because this book said so. These things are discovered by challenging others suggestions and their logic. If Christopher Columbus had not challenged the "great minds" of the 15th century, we would of not discovered America until several years later. So that is what makes programming so interesting because you can challenge someone’s concepts, you can discover new things and more. Programming is a endless world of never ending discovery. To label someone a "master" to me is not correct because they have only "mastered" what others learned. So their can never be a "master" of programming because its a endless discovery/science.
Thraxas
Retired Moderator
19
Years of Service
User Offline
Joined: 8th Feb 2006
Location: The Avenging Axe, Turai
Posted: 2nd Jan 2012 02:14
Quote: "In the end, the best solution is the one that makes the most sense to you and the one you know you can write your self with little or no help."


I totally disagree with this statement, clearly there are solutions to coding problems that are better than others. I can code things one way with no help, but that doesn't mean it's the best way.

Not getting help doesn't make you a better programmer than someone who looks to others for help.

You are correct that books are not the be all and end all of programming, but clearly the books are showing you a good way to do things. I can ignore all the programming books advice and work out my own ways, but why would I, or anyone, try to reinvent the wheel? Unless your solution improves the program in any way, all you have achieved is wasting time doing something that has already been done, and wasted time which could have used elsewhere in your project.

I don't have anything against you, but I do feel, that you are incredibly arrogant when it comes to programming, and the way you present yourself on the forums. It seems like you ask questions of people, only to ignore the advice if it wasn't what you expected it to be. In this thread, your response to VanB's post made it seem like you didn't actually understand what he said to you with regards to the AI, that's why you got the response from him that you did.

Quote: "That’s simply hoping everyone has learned something from the discussion as a whole. "


Here's hoping you also take something from the discussion

Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 2nd Jan 2012 03:06
I don't think you understand the scientific process too well. I find this URL explains the difference between scientific terms very well and also gives a little insight into how the scientific method works, at least enough for easy-to-understand bite-size chunks. I could sit here all night telling you how your idea of science doesn't work and how it doesn't work with 'programming theory', but I hope the link suffices.

Trying to save a massive argument:
Quote: "I’m not trying to imply you’re a bad teacher but sometimes you don’t make any sense to me logically speaking. I’m sure most of us listen to what you say but sometimes it does not always make sense or we find a different way that makes more sense to us. To me the joy of programming is discovery and finding solutions that make sense to myself."


If something doesn't make sense, ask, if you're willing to learn then when something isn't clear then asking questions can really benefit you. There's bad teachers, but there's also bad students.

Discovery is great, but you're trying to run a business, you're trying to improve your programming and learn the best what to make a Chess game, which would be beneficial to you as a programmer for developing other AI's. I think there's no shame in taking the advice of others and it can help you greatly improve your progress along.

You talk a lot about science and discovery within science. Scientists don't try and reinvent the wheel, they see that it's useful, use it, improve on it, develop it, see how it can be applied, see what it can be used for and what it can achieve. The wheel has a long history of improvements and has been used in a variety of application and yes great minds can think outside of the box and develop new and great ideas and it's probably why the wheel now has tires, suspension and breaks, it's also why the wheels on a car may one day be replaced by other technology.

I am a person who likes to learn on his own and I do enjoy it and am self taught on many things (including programming), but I won't turn down good advice when it's given to me, especially if I open a thread to discuss a problem I'm trying to figure out.

The question you asked with the thread was 'The Best Approach to Making Chess?" Why would you need to ask this if you were going to figure it out yourself? So I hope you can at least see where the confusion lies.

old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 2nd Jan 2012 03:31
I do agree Thraxas their is always typicaly a better way to do things. But my point was books as you said are not the end all to every solution etc. As for reinventing the wheel, I say why not. If no one reinvented the wheel, no one would of put rubber on it or attached it to a metal rod. Don't misunderstand me, I do see your point but my point was sometimes you need to think outside the box and you do need to reinvent the wheel.

Also like to state anything accomplished/learned by remaking something allready made is not a waste of time if you learned something from it. Is making your own OS using Linux a waste of time even if you never plan to sell it and only make it for personal use? Of course not, your doing it to learn something.

Moving on to arrogence. Honestly I try very hard to not be arrogent or appear to have a ego. however, I'm not perfect and to be honest I think most of the mods here have ego's of their own and my ego/theirs seem to clash often. I think we clash becase we have different views of course on how things should be done but thats fairly typical for people in this field.

Also need to point out again, I do listen to what others say. However your thoughts(TGC Mods) and mine do not always agree. Typically when you guys suggest something I do not 100% follow or agree on, I consult my friends who also have several years of experiance in the field and we discuss it. Sometimes your suggestions work and sometimes we agree to try something else. So I do value the advice given but sometimes we go different routes. Of course we respect your suggestions but sometimes they don't fit into the puzzle. I also commonly ask the MSDN because that is the best place I think to ask questions about programing. That of course is debatable but it's my personal view. So what you have when I ask a question is me gathering a bunch of suggestions from people and reviewing the information given. In a nutshell I'm researching a solution. So I hope that explains why I question things said a lot and why I don't allways do what is advised on here.

I would like to point out quickly, I question things as well because sometime I don't know/understand or agree. The only way someone can learn is by asking questions. Now sometimes people of course take that in the wrong context. As we are all only human and we will make mistakes and have misunderstandings. So if I question your advice, don't take it too harshly.
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 2nd Jan 2012 04:37
Quote: "As for reinventing the wheel, I say why not. If no one reinvented the wheel, no one would of put rubber on it or attached it to a metal rod."


That's not reinventing, that's improving it. Granted you can go and find your own solutions to a problem and try to work things out for yourself and that can be a great thing and essential to a learning process, but outside information is vital.

But what really confuses me is why would you be interested in finding out the 'best' way to make a Chess Game when your attitude is to not try and understand what somebody has written and their advice given but instead argue that programming is about reinventing the wheel and finding your own solutions, going against the grain and using your own sense of discovery.

It really comes off as a case of:
"I need some input."
"Here's some input."
"I don't need your input. I want to figure it out myself."

Correct me where I'm wrong of course. I would like to be able to see you achieve your best, yet, you seem to hold yourself back. I mean your projects never seem to be all that serious, people's help and feedback on them doesn't seem to be adopted or are discounted for some reason or another, usually giving the impression that the project isn't serious enough for those changes. Yet you want to be able to market your own software professionally.

You say this Chess project is so you can learn, in which case, learn as much as you possibly can! Take down all you can, any input people can give should teach you something. Embrace it! Don't just try to figure out your own way to do it but also see how other people do it, experiment, see what way actually works 'best' and what produces the best result - if somebody's solution isn't quite what you want, use it and improve it. Use what you learn to develop your knowledge further, apply it elsewhere.

old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 2nd Jan 2012 05:28
Quote: "given but instead argue"


This is why I have a hard time making my points and understanding posts on here sometimes. This is the only forum I visit that people confuse discussion with argument in a non-constructive sense. I hate to pick at my posts as well as others above but I clearly stated several times I agreed with Hassan's post. Just because I don't agree with a mod does not mean I'm ignoring their view.

My attitude is to obtain a better understanding of programing but if I don't agree or see a person's logic, Im not going to fall inline just because it's a mod or somoone suggested it. The point of this discussion was to see others views on how they would construct a chess game. Clearly everyone has different views on how it should be done. This does not mean no one listened to the other persons view, it just means we have different ways we would construct the game.

My position on this topic is to try and keep an open mind as I do when I code/take advice from others. However, I see someof you seem to take offense to people not taking your advice. So my question is why? Why would you be offended if someone did not take your advice? A good example; I ask my mother for advice all the time but I don't always take it. I can't speak for everyone but I'm sure most of oyu as well don't do everything that is suggested/advised as well. so I have to ask the question again, why are you getting upset? Their is no reason for getting upset. Just sounds like were making mountains out of ant hills. Just my thoughts. That being said, can we please get back on topic and have a good discussion about chess please. Thank you.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 2nd Jan 2012 12:31
I can't speak for VanB himself but I'll have a go at explaining his points (no pun intended). What the point system would do is work out the worth or value of each possible move. The more points, the better the move. You would subtract points for each piece you lose and add points for each piece you take. I've won games by sacrificing a bishop for two pawns. With the two pawns gone the kings defences are lowered allowing my queen swoop in for the kill. VanB's point system would identify those sorts of moves (if it checks moves far enough ahead) along with the more obvious piece for piece moves. It's actually quite a good system if you think about it.

Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 2nd Jan 2012 12:59 Edited at: 2nd Jan 2012 13:27
It's not so much the not taking advice, I mean you don't HAVE to take every bit of advice thrown at you. You're perfectly right about that. But it was more or less that your response, where you went on and on about how you try to reinvent the wheel, work things out for yourself and going against the grain, as opposed to considering methods that are proven to work because that's how a successful programmer works.

It's clear you didn't understand VanB's response. That's fine, you can't understand everything and it might not necessarily be explained in a way you understand it, we're all only human. You even went on about 'bad teachers', so okay his response didn't make sense to you.

I just REALLY don't understand your response. I thought if you had an open mind and were willing to listen to other people, you would have asked questions. I understand you've taken Hassan's advice, it was sound advice, but he was talking about how to create rules and not AI.


P.S. It's very difficult to offend me. 99.9% of my posts are posted in a calm manner. I may sometimes be hard talking, but don't take it to heart, I'm not trying to be nasty in doing so.

I will apologise for being too critical, people here want to help and they want your business to work, but giving you advice is a bit of a struggle.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jan 2012 17:08
That's exactly right Hodgey, I would say a method of scoring moves based on pieces taken or lost, along with some additional logic for sensible move selection. For example, giving bonus points for having both pieces (both rooks, knights, bishops), because loosing one of those pieces compared to 2 pawns could have a big impact, especially later in the game when trying for checkmates.

Anyway, I agree with Old_School, programmers need some degree of arrogance, because you need that to get anywhere when learning to program. It is a constant learning experience - but that is my point, you have to develop AI, it's not something that you know exactly how it'll work until you get something up and running, can measure, and can improve on. Having chess AI techniques going head to head sounds like an ideal way to me, fun too. For me, the only goal with making a chess game, would be for it to be able to beat me - it doesn't have to go up against Deep Blue, or anything crazy like that. I like to take established ideas and put my own spin on them, I don't like to follow the rules too closely, and that keeps programming fun for me. The only real constant is this forum, I've learned more from threads in this forum than anywhere else, and from people here who think outside the box.

Health, Ammo, and bacon and eggs!
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 2nd Jan 2012 18:38
I see what your saying now about the point system. So correct me if I'm wrong but chess does have a point system allready yes? I mean in tournaments or something they judge by points i think. So that being the case, maybe a easy way to make a AI system would be by setting up the AI to go after the peice worth the most points everytime. Of course I would make a special class called special moves for strategic moves the AI could perform based on situation but that would be where talking to a "chess master" would come in handy. Maybe even just reading a book on chess moves would work. Ultimately when were talking chess + AI = nightmare. So many great chess players out there and I'm sure some would become disappointed if the AI was not super good.
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 2nd Jan 2012 18:45 Edited at: 2nd Jan 2012 18:46
i've never heard of a chess tournament assigning points to pieces.

What they're talking about is making the computer give values to specific moves and/or peices.

For example, a knight moving to a square that will put the other player in check is +5. However, a space where the other player could then capture the knight is worth -5. Making the final value 0. Compare that to a bunch of other potential moves, and then pick the one with the best score, and move that.


Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 2nd Jan 2012 20:56
Quote: "For example, giving bonus points for having both pieces (both rooks, knights, bishops), because loosing one of those pieces compared to 2 pawns could have a big impact, especially later in the game when trying for checkmates."

Being pieces down is a nightmare when trying to checkmate your opponent. That's why I only ever perform the above sacrifice when I'm 100% sure it will result in a checkmate.

Quote: "So correct me if I'm wrong but chess does have a point system allready yes?"

That's correct but it's something like pawn = 1, bishop and knight = 3, rooks = 5 and queen = 9. When building your AI those values might be a bit too close together though. You could use a common multiplier to keep them in the same ratio, like 10.

Quote: "So that being the case, maybe a easy way to make a AI system would be by setting up the AI to go after the peice worth the most points everytime. "

The AI might be easier to program but will be easily defeated if you keep trying to capture the most valuable piece because there would be a lack in checking for weaknesses in your defences. Also be careful not to exaggerate the queen's value too much. I once sacrificed 2 or 3 good pieces just to capture the opponent's queen. This left me with just a queen and my opponent with something like 2 rooks and a bishop. I didn't stand a chance. The queen is a very powerful piece but can be outnumbered.

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Jan 2012 22:25
Quote: "So correct me if I'm wrong but chess does have a point system allready yes? I mean in tournaments or something they judge by points i think."


I think you're confusing a "points-based game" with a "points-based AI system". The point-based AI system uses points from potential moves to determine the "best" next move. The points are rarely disclosed to the player, and make the AI seem more intelligent. I'm not sure of a better way to make a chess AI, other than an internal points-based system.

Giving points to a player as some kind of score is a completely different topic.


Senior Developer - CBS Interactive Music Group
Drillfoot
14
Years of Service
User Offline
Joined: 7th Aug 2010
Location: United States
Posted: 31st Jan 2012 01:14
The DarkBASIC Pro 2nd Edition by J Harbour, the final game project is a "checkers" game without AI. Shows you how to lay out the board and pieces, select the pieces, move the pieces, and animate. Just dont include AI.

* Sorry to bump the thread but I just noticed it on TGC's Facebook.

http://www.amazon.com/DarkBASIC-Game-Programming-Jonathan-Harbour/dp/1598632876/ref=sr_1_1?ie=UTF8&qid=1327968873&sr=8-1

rem allow user create game with one click
rem create graphics, sound, scripts, models, with one click
rem slap user in face if game choice is mmo
Teh Stone
15
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 31st Jan 2012 01:35
So you thought it would be a good idea to bump a thread completely about chess ai to provide a link to a tutorial for everything but ai...
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 31st Jan 2012 03:21
Yes, old_School you're really not understanding what Van is talking about. The term "points" has nothing to do with a score in this context. It is common practice for A.I systems to assign "points" to each of their next possible moves based on a list of criteria, and then pick the move with the highest "point" total as their chosen move.

A simplified example of this kind of A.I:

Imagine you have one computer controlled player, and their objective is to avoid being shot.

This A.I moves around the world on a virtual "grid" and can only move up, down, left, right, or diagonally one grid square at a time.

Every time the A.I wants to determine which of the 9 possible locations it should pick for it's next move (8 locations around the A.I, one location where the A.I already is), the A.I analyzes each spot and assigns it points based on its analysis:

> 1 Point if the tile is farther away from the attacking player
> 3 Points if the tile is behind a barrier this providing the A.I with cover if it goes to this tile
> 5 Points if the tile has an "Active Cammo" power-up in it.

Using this basic system, the A.I assigns a point value to each of it's possible 9 tiles and in the end, has one tile with the highest point value. This tile is obviously the A.I's best move to make next.

The same kind of logic can be put into programming a chess game assigning point values to all of the possible moves the A.I can make it's turn. Look up A* (A Star) pathfinding for some more in depth information on this.
Nomad Soul
Moderator
18
Years of Service
User Offline
Joined: 9th Jan 2007
Location: United Kingdom
Posted: 3rd Feb 2012 17:54
@old_School

Quote: "No one can ever "master" programming or a programming language. Technology changes, the language changes and so on"


This is not true. John Carmack is the best programmer in the world and has made a better version of everything he has tried. I'm pretty sure he would know what the best chess AI system is and how to implement it.

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 3rd Feb 2012 18:31
The idea of battling different AI systems is awesome! We should make a TGC AI tournament. It could be done with anything not just chess.

Join DNG today! We are a game development team open to all. Visit our Headquarters to learn more.
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 4th Feb 2012 06:16
Reminds me of an old programming competition I entered back in high school. Each high school elected one programmer and - using a provided API - the programmer had to write an AI system for a tower-defense kind of game. The programmer has 2 hours to finish it and after all entries were completed the system would randomly pair two AI's against each other until a final winner was announced. It was pretty fun, especially since they allowed you to tweak your code after each set of fights to fix any problems or weak points you noticed as you watched your AI fight.
Quik
16
Years of Service
User Offline
Joined: 3rd Jul 2008
Location: Equestria!
Posted: 4th Feb 2012 14:49
@the topic: well, i tink you should start by carving some figures, preferably from wood as its probably easiest/cheapest


The result of origin.. Oh and ponies
Fatal Berserker
14
Years of Service
User Offline
Joined: 2nd Jul 2010
Location:
Posted: 4th Feb 2012 18:47
Quote: "Nobody feel like a code challenge with chess AI, a learning experience for anyone willing to have a go at a chess engine."

Beat my engine:

If (Ai.State == State.Loosing)
{
goto AIWin;
}

Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Feb 2012 21:26
Quote: "Beat my engine:

If (Ai.State == State.Loosing)
{
goto AIWin;
}
"


OK:
If (Ai.State == State.Losing)
{
goto AIWin;
}

[b]

Login to post a reply

Server time is: 2025-05-22 15:20:34
Your offset time is: 2025-05-22 15:20:34