Library tutorials & articles

AI 2 - Game Playing (Artificial intelligence)

Introduction

This is my second post on the topic of AI. The first covered AI basics, and was used to solve a simple single player game. In this article, I'm going to explain the minni-max method, which will enable you to take what you learned in the first article, and extend it to make multi-player games. If you didnt read my first article, dont wory, you should still be able to understand this, however having a quick read over it may be useful.

In this article, we are going to program a console naughts and cross' game (tic tac toe for those not in the UK). For those of you who dont know, the rules of tic tac toe are as follows...

You Start with a 3 by 3 grid...

     
     
     

Then the 2 players take it in turns to place a there marker on the board (one players uses the 'X' marker, the other uses the 'O' marker). The winner is the player who gets 3 of there markers in a row, eg...

X O  
  X O
O   X

X wins.

Another possibility, is that no1 wins. eg...

O O X
X X O
O O X

On the next page, I will begin to explain the theory.

Comments

  1. 12 Sep 2005 at 07:49

    wher do i get the windows.h header file? the main.cpp code doesnt seem to work and has quite a few errors. help please!

  2. 07 Aug 2005 at 17:45

    after you get this code to run i need to know how to be able to save to a file and replay the game play before. if the player is starting a new game he/she should be prompted to enter their name and it should be pass to a constructor of the tictactoe board object . if the user wishes to save the game they should be prompted to enter te name of the ouput file. the output should have the player info and as well as the different moves that make up the game.
    i might need two sperate files containing the header and implementation of the player class , file representing the playing  board and the file containing the main program.    


    I really need some help on getting this to work and any help with code or pseudocode to implement this will be appreaciated. can i be notify at oyetih@yahoo.com  

  3. 01 Jan 1999 at 00:00

    This thread is for discussions of AI 2 - Game Playing (Artificial intelligence).

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!