
Show HN: Boxes - sidbatra
http://theboxes.co/
======
ronaldx
Current 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 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?)

~~~
esquivalience
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.

------
Cogito
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.

~~~
aheppenstall
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.

------
hypersoar
Neat! This was fun to think about.

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
There should be an option to let the computer play first.

------
squidpie
This is a good time, but it would be nice to see what the robot is doing,
having their game board visible but no numbers showing would nice.

------
swang
There is a bug in the game where if your search page 503s I lose a turn
(computer takes a square, the square I clicked isn't acknowledged).

------
waterfowl
Was having fun but I think HN just killed it. Alas!

~~~
niveshi
it's back! new servers tomorrow.

------
carb
Why would you disable the context menu? For something so simple, this
application's front-end seems incredibly over-complicated.

------
farnsworth
Fun! But why is the AI done server-side? So slow!

~~~
baldeagle
Could the yellow square be preserved? Sometimes (often) I tab away while
waiting for the server to return and miss where the computer went.

------
ahassan
I'm kinda confused about how to win. Do I choose a number and if the computer
also chooses that number, we both get X's?

------
Oculus
I think it'd be nice to see the NPC board even if it's just a grid of blank
squares.

------
rachana318
@lateguy - am one of the developers. try figuring it out ;)

~~~
fragmede
This isn't twitter, and threaded comments are supported.

------
DanBC
Is "the robot" just "other humans"?

~~~
christianmann
Couldn't be, the human always goes first.

------
nikunjk
Exciting game. Please build a mobile version of this!

------
aheppenstall
Really like it - what algorithm are you using for the robot?

~~~
rachana318
play a few games and try figuring it out ;)

------
ambitionvc
Really cool!

------
niveshi
This is awesome

------
ckarthikv
Good stuff, addictive!

------
lateguy
I beated till 3 levels, really cool. What algo you are using?

------
amarsaurabh
I liked the game. Super cool stuff. Pretty addictive. I could cross level 4.

