So I am porting a variation of the board game Hex from java to
javascript, as I am putting it on the web.  One of the functions I
need to write for the computer AI to get his next move is to fill in
the rest of the board (a filled hex is red or blue, an unfilled is
white) 300,000 times, randomly, and check the winner of the game, and
then make some quick calculations, and returns the position of the
best move.

This worked fine in Java, but it seems to be hanging up in JS.  I have
decreased the number of repetitions to 100,000, and then down to 1000,
and i still have to stop the script when I test it in firefox.  I was
wondering if I could pass the data to an AJAX call, do the
computations in PHP, and then return the correct move.  I am having 2
problems however:

1) I don't think you can pass an array to AJAX, and I have an array of
hex colors for the board that must be passed in.

2) The function making the AJAX call must return the move (and the
correct bid, as this is a bidding game), but the function ends before
the AJAX call completes.

Any suggestions about how to best do this would be appreciated.  You
can see the code break by going to http://apps.facebook.com/biddinghex
Then going to play computer, and entering a bid, hit bid - the script
will crash.

Thank you,
Jay

Reply via email to