我試圖從GAMUT java庫中生成Polymatrix遊戲。從GAMUT生成Polymatrix遊戲
try {
PolymatrixGame polyGame = new PolymatrixGame();
polyGame.setParameter("players", nbOfPlayers); //nbOfPlayers = 3L;
polyGame.setParameter("actions", nbOfActions); //nbOfActions is a Vector<String> with three entries: each equal "2".
polyGame.setParameter("graph", "RandomGraph");
polyGame.setParameter("graph_params", new ParamParser(new String[] {"-nodes", "" + nbOfPlayers, "-edges", "" + 3, "-sym_edges", "1", "-reflex_ok", "0"}));
polyGame.setParameter("subgame", "Chicken");
polyGame.setParameter("subgame_params", new ParamParser());
polyGame.initialize();
polyGame.doGenerate();
} catch (Exception e) {
e.printStackTrace();
}
我得到以下錯誤:
FATAL ERROR: Unable to generate polymatrix game (subgame Chicken)
java.lang.NullPointerException
我經歷過的源代碼,但挖我無法找到錯誤的根源。錯誤信息本身也不是很有用。
最終,我試圖用給定數量的玩家生成一個隨機Polymatrix遊戲,並給出每個玩家的動作次數。
使用命令行有沒有成功? –
是的。 _java -jar gamut.jar -g PolymatrixGame -players 3 -actions 2 -graphics RandomGraph -graph_params [-nodes 3 -geges 3 -sym_edges 1 -reflex_ok 0] -subgame Chicken -subgame_params [] _成功生成一個遊戲。上面的java代碼似乎完全代表這個命令,但似乎並不工作。 – Auberon
k,我問,因爲我也使用GAMUT來產生隨機遊戲。經過與API的長期鬥爭之後,我簡單地編寫了一個適配器,以便從命令行調用jar。我通過使用'Runetime.getRuntime()。exec(「java -jar ....」)調用jar來將它集成到我的應用程序中。 –