Thread: Chess function

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Chess function

    Hi, i want to complete my chess game including a human vs computer option. I would like to know if you can help me to find a known and very simple function that finds the best move. Thank you very much.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    I would probably try to build this in stages.
    my 1st stage would be to look for a winning move. i.e. one that causes check mate
    2nd poss stage would be look for a capture of highest value for lowest cost.

    have you had any thoughts yourself?
    have you searched for some source code you could possibly learn from. Im sure i have seen source for chess games on the web.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Lightbulb Chess function

    Hi, it is very interesting to think about those stages. I have
    thought when the computer decides the best move, then it must
    change his color and decide the best move, and change the color..... a few times. In this way, it can evaluate the best move of a set of moves. But i don't know really if it works .
    I am not very fond in chess, i am a newbie. I want this function
    because i am a C/C++'s teacher and i want to propose a chess
    game to my students, a complete one. I have found an interesting web. Take a look, there are a lot of program sources:
    http://www.xs4all.nl/~verhelst/chess/sources.html
    I will watch the sources in the next days.
    See you,
    Daniel.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    14
    To do a chess AI is not that hard.. unless you really want it to kick ass, since that will make you have to teach the computer some of the most common "chess strategies".

    Basically as in all AI's, recursive methods is the way to go.

    create a method that in general does this.

    whatever FindBestMove("a move" //represented in anyway)
    {
    // Am I happy with the current situation, then in some way register this result and save the list of moves I've made so far.
    return;

    // Otherwise

    //Find all possible moves I may do. Place these in some sort of list.

    //Realise which one of them really suck, and throw those away.

    //Run FindBestMove with each of the moves still left in the list.
    }

    When we are all done, we should have a lot of nice results registered .. analyse these to find out what is the best move..

    Chess Mate

    /Laos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM