Dark Age Games
Home Dark Age EX Dark Age 2 Message Board Fan Art FAQ Kelzar Mage DALpedia MS Forum
Board Index Dark Age General Bug Report Website Off Topic Register User Edit User User List Search

In reply to: Help -- corim123 14:04:49 07-25-2005

Well...
Posted by: Xorlak
10:49:49 07-26-2005

You read the article I showed you, right?  The basic algorithm is:

for every possible move
  for every possible opponent response to that move
    pick the opponent's "best" response to that move
  assign a "score" to that move
pick the best move based on the score


Basically "minimize the maximum amount of damage" the opponent can do to you.  You'll have to code methods to:

- Pick a valid move you can do (i.e. check every possible move each one of your pieces can do)

- Pick a valid move the opponent can do (same thing, basically)

- Assign a score to a board configuration (maybe assign a point value to each of your existing pieces, pawns could be worth 1, knights 3, etc.)

How you do these things depends on the game and how you put it together (e.g. how the piece info is set up, where they are located, etc. are stored).  I did an example for tic-tac-toe.  Although the way you implement the above methods would be very different for a chess game, the order you executed them in and what you did with the results would be the same.  Watch out, though.  Chess has a much larger branching factor (i.e. there are way more possible board setups than a little tic-tac-toe game) so this way of doing things could be VERY slow, especially in RPG Code.

----------
-Xorlak
Edit Post