Thread: Chess engine

  1. #1
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321

    Chess engine

    Hi all, havn't posted anything in a while so how are all of you?

    Anyways, I've wanted to make a chess engine since I was little, but the problem is I don't know how to program any AI. And I have a few design issues of my framework/engine that I havn't even started to code yet, still in the design stage. So..... What should the base class include, just to start me off? I'm pretty stuck because a chess engine is extremely new to me and I havn't programmed anything in a while. Is the AI hard to program? Is their any tutorials on how to program AI? If so can somebody please point me in the right direction?

    Best wishes

    Beene

  2. #2
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    The AI you'd normally use for chess is a minimax tree, which isn't that bad. If you have a class that can represent a board state, let the user change the board state, and evaluate the board state for each player then you have most of what you're going to need. To do the AI you just build a tree where the root is the current state, the next layer is all of your possible moves, the layer after that is all of your opponents possible moves (you might want to start with checkers or connect 4 here because the branching factor on chess is something like 40). Once you have the tree built to a certain depth, you evaluate each board state in the tree and find a path to the end where you go for your highest score while assuming your opponent plays optimally.
    Illusion and reality become impartiality and confidence.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    I am currently writing my chess engine. If you want some search keywords for google, try minimax, alpha-beta prunning, transposition table, iterative deepening. Here is a tutorial specifically on Chess programming http://www.gamedev.net/reference/lis...categoryid=163
    starting from "Chess Programming Part I: Getting Started." Also, if you don't want to write a GUI but want to have one, try writing your chess engine to interface with xboard/winboard compatible interfaces (google "xboard communication protocol"), that is what I am doing now. However, like ichijoji said, I wouldn't recommend starting with chess if you have never programmed any AI before, as the rules of chess is pretty complicated (castling, en passant, promotion, draw by repetition, 50 moves rule etc), and the average branching factor is around 35, which means your code has to be pretty optimized to reach any considerable depth. This is my second AI program, my first one was an AI for reversi (othello), and I would recommend starting on reversi because of its much simpler rules and smaller average branching factor of 8.
    Last edited by cyberfish; 08-17-2007 at 08:25 PM.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    For basic Chess AI: http://aihorizon.com/essays/chessai/index.htm

    (Though cyberfish's page looks better.)

    [edit] Moderators: consider moving this thread to the General AI Programming forum. Just a thought. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Good idea.

    Done.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  3. Chess engine
    By coconutkid in forum Projects and Job Recruitment
    Replies: 16
    Last Post: 11-22-2004, 07:30 AM
  4. Ultra chess engine contest
    By yodacpp in forum Projects and Job Recruitment
    Replies: 8
    Last Post: 11-21-2004, 07:58 AM
  5. Ultra chess engine
    By yodacpp in forum Game Programming
    Replies: 2
    Last Post: 11-19-2004, 12:33 PM