When I build the PlayN project and run the java version, it’s behaviour is different to when I run the HTML version.
Basically I made a board game that uses a modified version of the Minimax algorithm (search tree and weighting evaluation) for its AI.
Since nothing is calculated randomly, and if the inputs are the same, I’d expect the outputs to be the same too.
However, the AI’s of the java and javascript (HTML) versions behave differently to the same input.
The link to the Html/javascript version can be found here:
http://mugle-app.appspot.com/+games/staff/fiar/
The java (JAR) file can be found at:
http://ez-playn.googlecode.com/files/FiarJava.zip
They both use the same code, only compilations have been different, but both using the provided Ant scripts. Tree depth is fixed, evaluator weightings are fixed
I can’t understand why there would be a difference since every thing works except the search tree…could it be because that evaluation is heavy and javascript run’s out of resources?
Thanks for any help.
It looks like you are iterating over the contents of a HashMap.
BoarddefinesemptyCellswhich is a HashMap, and thenGameSearchcallsBoard.getEmptyCellCollection(which returns the values of the HashMap as a collection) and then iterates over them. Those values do not have a predictable ordering, and the ordering will almost certainly change in the conversion from Java to JavaScript.If you need to iterate over the contents of a HashMap in predictable order, use LinkedHashMap.