You shouldn't care how you are affecting your opponent's board (you are affecting it randomly).
So just play for your own board.
On an empty board:
The centre square is the most valuable, crossing 4 lines
The diagonals are also valuable, crossing 3 lines
All the other squares are equally not-valuable, crossing 2 lines.
However - the squares change their value (a lot) depending on what your opponent plays.
A good strategy is therefore to wait and see what your opponent plays, then greedily collect the lines that they nearly fill in by random chance.
To acheive this... fill the valuable squares: centre and diagonals, while your opponent fills other places randomly. I guess they are doing the same.
Once you're done with the diagonals: fill the line which is most close to completed. This does not require too much thought - once you start filling a line, it's nearly always right to keep filling it.
You can break ties between lines, where necessary, by looking at which crossing lines are nearly filled.
Although the robot has the advantage of seeing what the player plays, I believe the first move outweighs this advantage (especially on the larger boards?)
This works well for the lower levels but as the grid gets bigger, a refinement stage needs adding to the tiebreak. I suggest switching view from per-square to per-line for tiebreaks. How about this:
Larger grid:
1. take centre and fill diagonals
2. for the first few lines a big grid (say level 5) is big enough that the differences between optimal and not are small, so use "most close to completed" for a few lines
3. After a few lines (I want to say 30% of target?), the "most close to completed" ties will become more relevant. Breaking ties from the focus of one square doesn't work, because the computer's completion could change things.
4. Instead, to break a tie look at the lines that cross the candidate lines. For each number in the candidate, count the Xs that cross it. Sum the Xs for a line to find a value. Do this for each candidate and the most valuable is the candidate to pick.
This works well because even a small difference in value becomes very important towards the end.
This was quite interesting, but it's so annoying to see multiple 1 line comments from new accounts, and accounts that have very little history. Even more annoying, the older "spammy" accounts all seem to be linked to accredible, the site hosting the game. Over half the contributions on this page are from those accounts; niveshi, lateguy, aheppenstall, ambitionvc, amarsaurabh, rachana318.
Apart from all that, this looks like it would be fun to turn into a pure javascript clone. The network connection seems completely unnecessary, and it would be fun to create competing AIs.
I think that's a little harsh. Let me give you some context to help make things clear. The creator of the game has been learning to program over the past year and this is one of his first projects. He's been working with Accredible and we've gotten to know him well over this time. We wanted to show our support for one of his first public projects. Yes we do work with Accredible but it's hardly a marketing endeavour to include a text link of those paying for hosting.
Given the complete lack of relationship between the two matrices, the fact that you're playing against a computer seems immaterial. You make a move, and then a random square is filled in. You lose if you don't achieve the win condition in some number of turns (I wanna say around n^2/2).
That said, here's a greedy algorithm I've arrived at, similar (but not identical to) ronaldx's:
For an unfilled point p on an unfinished line, define its value, v(p). There are a bunch of ways to do this, but one that I've thought of is: the number of x's on all unfinished lines through that point.
1. Fill in the center square
2. Choose an unfinished line with a maximal number of x's such that the sum of the values of all its unfilled points is /maximal/
3. Fill in a point p on that line with v(p) /minimal/
4. Goto: step 2
Reasoning for step 1: The center space opens up the most options, lying on more lines than any other point.
Reasoning for step 2: You want to pick a line to fill in. Moreover, you want the filling in of its points to benefit your efforts elsewhere as much as possible.
Reasoning for step 3: Now that you've picked a line, you're going to fill in all its points. You pick the points in ascending order of value to give the robot as much time as possible to fill in the best points for you.
[+] [-] ronaldx|12 years ago|reply
You shouldn't care how you are affecting your opponent's board (you are affecting it randomly). So just play for your own board.
On an empty board:
A good strategy is therefore to wait and see what your opponent plays, then greedily collect the lines that they nearly fill in by random chance.To acheive this... fill the valuable squares: centre and diagonals, while your opponent fills other places randomly. I guess they are doing the same.
Once you're done with the diagonals: fill the line which is most close to completed. This does not require too much thought - once you start filling a line, it's nearly always right to keep filling it.
You can break ties between lines, where necessary, by looking at which crossing lines are nearly filled.
Although the robot has the advantage of seeing what the player plays, I believe the first move outweighs this advantage (especially on the larger boards?)
[+] [-] esquivalience|12 years ago|reply
Larger grid: 1. take centre and fill diagonals
2. for the first few lines a big grid (say level 5) is big enough that the differences between optimal and not are small, so use "most close to completed" for a few lines
3. After a few lines (I want to say 30% of target?), the "most close to completed" ties will become more relevant. Breaking ties from the focus of one square doesn't work, because the computer's completion could change things.
4. Instead, to break a tie look at the lines that cross the candidate lines. For each number in the candidate, count the Xs that cross it. Sum the Xs for a line to find a value. Do this for each candidate and the most valuable is the candidate to pick.
This works well because even a small difference in value becomes very important towards the end.
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] Cogito|12 years ago|reply
Apart from all that, this looks like it would be fun to turn into a pure javascript clone. The network connection seems completely unnecessary, and it would be fun to create competing AIs.
[+] [-] aheppenstall|12 years ago|reply
[+] [-] hypersoar|12 years ago|reply
Given the complete lack of relationship between the two matrices, the fact that you're playing against a computer seems immaterial. You make a move, and then a random square is filled in. You lose if you don't achieve the win condition in some number of turns (I wanna say around n^2/2).
That said, here's a greedy algorithm I've arrived at, similar (but not identical to) ronaldx's:
For an unfilled point p on an unfinished line, define its value, v(p). There are a bunch of ways to do this, but one that I've thought of is: the number of x's on all unfinished lines through that point.
1. Fill in the center square
2. Choose an unfinished line with a maximal number of x's such that the sum of the values of all its unfilled points is /maximal/
3. Fill in a point p on that line with v(p) /minimal/
4. Goto: step 2
Reasoning for step 1: The center space opens up the most options, lying on more lines than any other point.
Reasoning for step 2: You want to pick a line to fill in. Moreover, you want the filling in of its points to benefit your efforts elsewhere as much as possible.
Reasoning for step 3: Now that you've picked a line, you're going to fill in all its points. You pick the points in ascending order of value to give the robot as much time as possible to fill in the best points for you.
[+] [-] Glyptodon|12 years ago|reply
[+] [-] squidpie|12 years ago|reply
[+] [-] swang|12 years ago|reply
[+] [-] waterfowl|12 years ago|reply
[+] [-] niveshi|12 years ago|reply
[+] [-] lateguy|12 years ago|reply
[+] [-] carb|12 years ago|reply
[+] [-] farnsworth|12 years ago|reply
[+] [-] baldeagle|12 years ago|reply
[+] [-] ahassan|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] Oculus|12 years ago|reply
[+] [-] rachana318|12 years ago|reply
[+] [-] fragmede|12 years ago|reply
[+] [-] DanBC|12 years ago|reply
[+] [-] christianmann|12 years ago|reply
[+] [-] nikunjk|12 years ago|reply
[+] [-] aheppenstall|12 years ago|reply
[+] [-] rachana318|12 years ago|reply
[+] [-] ambitionvc|12 years ago|reply
[+] [-] niveshi|12 years ago|reply
[+] [-] ckarthikv|12 years ago|reply
[+] [-] lateguy|12 years ago|reply