Re: [OT] Looking for algorithm

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Chris,

Are you trying to determine whether or not, given a board with X and O's
on it, someone has won? If so, that's pretty simple.

All you have to do is analyze two edges that are perpindicular to each
other, as well as diagonals from two corners on the same edge.

So, you would cycle through the top edge. In the first cell, if there
is a mark, then you would analyze the cells beneath the top edge to see if
they possesed the same mark. If you find that condition, you know that the
player with that mark has one. If any cell does not contain the mark in the
top row, then you move to the next column.

You then do the same thing horizontally against a vertical edge.

Then you just compare the diagonals.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Chris Dunaway" <dunawayc@xxxxxxxxx> wrote in message
news:1176316116.631929.323470@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am posting this here because I think someone here will either know
the answer or know a better place for me to ask this question.

I am looking for an algorithm to provide AI for a Tic Tac Toe (aka
Naughts and Crosses) style game. But not necessarily for Tic Tac
Toe.

I'm looking for an algorithm that can evaluate and arbitrary sized
board with an arbitrary win condition. So for example, tic tac toe is
a 3 by 3 board with a win condition of 3 in a row.

I need an algorithm for an m by n board with a win condition of x in a
row where x <= m and x <= n.

Does that make any sense?

I don't just want code (but I'll take anything I can get), I want to
learn the algorithm. This is for my own private project.

Does anyone have such an algorithm or know a good resource where I
could learn about such algorithms?

Thanks,

Chris



.



Relevant Pages

  • Re: Looking for algorithm
    ... I am looking for an algorithm to provide AI for a Tic Tac Toe (aka ... But not necessarily for Tic Tac ... This is for my own private project. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Looking for algorithm
    ... I am looking for an algorithm to provide AI for a Tic Tac Toe (aka ... But not necessarily for Tic Tac ... This is for my own private project. ...
    (microsoft.public.dotnet.languages.csharp)
  • [OT] Looking for algorithm
    ... I am posting this here because I think someone here will either know ... I am looking for an algorithm to provide AI for a Tic Tac Toe (aka ... But not necessarily for Tic Tac ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Looking for algorithm
    ... I am looking for an algorithm to provide AI for a Tic Tac Toe (aka ... But not necessarily for Tic Tac ... It's the algorithm of choice for almost all chess engines. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: List Performance
    ... optimization for dealing with long list, to replace an algorithm with a ... lot of append by something like this: ... mark = object ... has been a standard idiom since before objectexisted;-) ...
    (comp.lang.python)