@SuppressWarnings("unchecked") private void initAi(AbstractAI bot) { AiProvider provider = (AiProvider) bot; String aiClass = provider.getPokerAi(); try { Class<PokerAI> forName = (Class<PokerAI>) Class.forName(aiClass); ai = forName.newInstance(); } catch (Exception e) { bot.getBot() .logWarn( "Could not create AI class: " + aiClass + ". Will use Random AI instead. Error: " + e); ai = new RandomAI(); } ai.setBot(bot); }
public Action onActionRequest(final RequestAction request) { if (ai == null) { initAi(bot); } final PerformAction response = ai.onActionRequest(request, state); Action action = new Action(bot.getBot()) { public void run() { try { bot.getBot().sendGameData(bot.getTable().getId(), bot.getBot().getPid(), response); } catch (Throwable th) { th.printStackTrace(); } } }; return action; }
public void clear() { bot.getBot().logDebug("Hand End - Clear poker table state"); state.clear(); }