Is "the robot" just "other humans"?
Show HN: Boxes
21–30 of 31 posts
Re: Show HN: Boxes
#22Re: Show HN: Boxes
#23Fun! But why is the AI done server-side? So slow!
Re: Show HN: Boxes
#24Given 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.
Re: Show HN: Boxes
#25Re: Show HN: Boxes
#26Re: Show HN: Boxes
#27Re: Show HN: Boxes
#28Re: Show HN: Boxes
#29Apart 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.
Re: Show HN: Boxes
#30Current thoughts on strategy: 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 yo…
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.