decide(state) { Log.info('infodumps state:: ', state); Damage.assumeStats(state.opponent.active); if (state.forceSwitch) { // our pokemon died :( // choose a random one // const possibleMons = state.self.reserve.filter( (mon) => { if (mon.condition === '0 fnt') return false; if (mon.active) return false; return true; }); const myMon = this.pickOne(possibleMons); return new SWITCH(myMon); } // check each move let maxDamage = 0; let bestMove = 0; state.self.active.moves.forEach( (move, idx) => { if (move.disabled) return; if (move.pp === 0) return; let est = -1; try { est = Damage.getDamageResult( state.self.active, state.opponent.active, move, { weather: state.weather } ); } catch (e) { Log.error(e); Log.error(state.self.active, state.opponent.active, move); } Log.info('estimated ' + est + ' for move ' + move.name); if (est > maxDamage) { maxDamage = est; bestMove = idx; } }); return new MOVE(bestMove); }
getHelp(state) { // console.log('infodumps help state:: ', state); Damage.assumeStats(state.opponent.active); const extra = {}; try { extra.moves = this._moves(state); } catch (e) { Log.error(e); Log.error(JSON.stringify(state)); } try { extra.switches = this._switches(state); } catch (e) { Log.error(e); Log.error(JSON.stringify(state)); } return extra; }