Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4330004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:54:06+00:00 2026-05-21T09:54:06+00:00

So I was assigned the problem of writing a 5x5x5 tic-tac-toe player using a

  • 0

So I was assigned the problem of writing a 5x5x5 tic-tac-toe player using a genetic algorithm. My approach was to start off with 3×3, get that working, and then extend to 5×5, and then to 5x5x5.

The way it works is this:

  • Simulate a whole bunch of games, and during each turn of each game, lookup in a corresponding table (X table or O table implemented as a c++ stdlib maps) for a response. If the board was not there, add the board to the table. Otherwise, make a random response.

  • After I have complete tables, I initialize a bunch of players (each with a copy of the board table, initialized with random responses), and let them play against each other.

  • Using their wins/losses to evaluate fitness, I keep a certain % of the best, and they move on. Rinse and repeat for X generations, and an optimal player should emerge.

For 3×3, discounting boards that were reflections/rotations of other boards, and boards where the move is either ‘take the win’ or ‘block the win’, the total number of boards I would encounter were either 53 or 38, depending on whether you go first or second. Fantastic! An optimal player was generated in under an hour. Very cool!

Using the same strategy for 5×5, I knew the size of the table would increase, but did not realize it would increase so drastically. Even discounting rotations/reflections and mandatory moves, my table is ~3.6 million entries, with no end in sight.

Okay, so that’s clearly not going to work, I need a new plan. What if I don’t enumerate all the boards, but just some boards. Well, it seems like this won’t work either, because if each player has just a fraction of possible boards they might see, then they are going to be making a lot of random moves, clearly steering in the opposite direction of optimality.

What is a realistic way of going about this? Am I going to be stuck using board features? The goal is to hard-code as little game functionality as possible.

I’ve been doing research, but everything I read leads to min/max with A-B pruning as the only viable option. I can certainly do it that way, but the GA is really cool, my current method is just exceeding reality a bit here.

EDIT Problem has been pretty much solved:

Using a similarity function that combines hamming distance of open spaces, the possible win conditions, and a few other measures has brought the table down to a very manageable 2500 possibilities, which a std::map handles in a fraction of a second.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:54:07+00:00Added an answer on May 21, 2026 at 9:54 am

    My knowledge of GA is pretty limited, but in modeling board configurations, aren’t you asking the wrong question? Your task isn’t to enumerate all the possible winning configurations — what you’re trying to do is to find a sequence of moves that leads to a winning configuration. Maybe the population you should be looking at isn’t a set of boards, but a set of move sequences.

    Edit: I wasn’t thinking so much of starting from a particular board as starting from an empty board. It’s obvious on a 3×3 board that move sequences starting with (1,1) work out best for X. The important thing isn’t that the final board has an X in the middle, it’s that the X was placed in the middle first. If there’s one or more best first moves for X, maybe there’s also a best second, third, or fourth move for X, too? After several rounds of fitness testing and recombining, will we find that X’s second move is usually the same, or is one of a small set of values? And what about the third move?

    This isn’t minimax because you’re not looking for the best moves one at a time based on the previous state of the board, you’re looking for all the best moves at the same time, hoping to converge on a winning strategy.

    I know this doesn’t solve your problem, but if the idea is to evolve a winning strategy then it seems natural that you’d want to look at sequences of moves rather than board states.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay guys, basically the problem I'm having is this. I've been assigned to write
I'm writing an application that uses Dijkstra algorithm to find minimal paths in the
Example code so I can start explaining this problem: <div style=z-index:5>5</div> <div style=z-index:2>2</div> <div
I am new to Apache-poi and using 3.8 version of poi. While writing value
I have assigned a label to my navigation item.titleview The problem is if I
let me explain my problem. I have a mouseout event assigned to a div
I'm writing a custom StyleCop rule to prevent String variables being assigned null ,
I'm writing inline assembly statements using a GNU-based toolchain, and there are three instructions
I've just started writing tests for my iOS app, I'm using Xcode4 and OCUnit.
I'm writing an exporter for Blender, and I ran into a small problem -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.