BlueGit

projects-timfalken-com meteors

chore: rebuild game.js (t1144)

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
004da2dbf375de8a13a1128321fce454df4a30c3
Parent
cabc0b87
1 file changed +327 −6
build/game.js +327 −6
@@ -10569,11 +10569,263 @@ function executeBotMove (core, move)
10569 10569 return true;
10570 10570 }
10571 10571
10572 /**
10573 * Max board evaluations (apply + hasMatch + undo) for a depth-2 search
10574 * in one AI tick. A 10×13 field with typical stacks stays well under this.
10575 */
10576 var PLAN_BUDGET = 4000;
10577 /** Skill at or below this: never start a 2-step setup (early rounds). */
10578 var LOOKAHEAD_START = 0.10;
10579 /** Skill at or above this: always look for a 2-step setup when no immediate match. */
10580 var LOOKAHEAD_FULL = 0.40;
10581
10582 /**
10583 * Probability of searching a 2-step setup after a successful roll
10584 * that found no immediate match. 0 through 10% skill (rondes 1–6),
10585 * then linear up to 1 at 40% skill (ronde 36).
10586 */
10587 function lookaheadChance (skill)
10588 {
10589 skill = Number(skill) || 0;
10590 if (skill <= LOOKAHEAD_START)
10591 { return 0; }
10592 if (skill >= LOOKAHEAD_FULL)
10593 { return 1; }
10594 return (skill - LOOKAHEAD_START) / (LOOKAHEAD_FULL - LOOKAHEAD_START);
10595 }
10596
10597 function copyMove (m)
10598 {
10599 return {
10600 col: m.col,
10601 fromY: m.fromY,
10602 toY: m.toY,
10603 dist: m.dist,
10604 blockId: m.blockId
10605 };
10606 }
10607
10608 function movesEqual (a, b)
10609 {
10610 return a && b && a.col === b.col && a.fromY === b.fromY && a.toY === b.toY;
10611 }
10612
10613 function betterImmediate (cand, best)
10614 {
10615 if (!best)
10616 { return true; }
10617 if (cand.dist !== best.dist)
10618 { return cand.dist < best.dist; }
10619 if (cand.col !== best.col)
10620 { return cand.col < best.col; }
10621 if (cand.fromY !== best.fromY)
10622 { return cand.fromY < best.fromY; }
10623 return cand.toY < best.toY;
10624 }
10625
10626 function betterPlan (cand, best)
10627 {
10628 if (!best)
10629 { return true; }
10630 if (cand.total !== best.total)
10631 { return cand.total < best.total; }
10632 var a0 = cand.steps[0];
10633 var b0 = best.steps[0];
10634 if (a0.dist !== b0.dist)
10635 { return a0.dist < b0.dist; }
10636 if (a0.col !== b0.col || a0.fromY !== b0.fromY || a0.toY !== b0.toY)
10637 { return betterImmediate(a0, b0); }
10638 return betterImmediate(cand.steps[1], best.steps[1]);
10639 }
10640
10641 /**
10642 * Legal vertical swaps from a colour grid: contiguous non-null cells
10643 * in a column (gaps break a segment, same as swapToward).
10644 */
10645 function listMovesFromGrid (grid, width, height)
10646 {
10647 var moves = [];
10648 for (var col = 0; col < width; col++)
10649 {
10650 var start = -1;
10651 for (var r = 0; r <= height; r++)
10652 {
10653 var filled = r < height && grid[col][r] != null;
10654 if (filled)
10655 {
10656 if (start < 0)
10657 { start = r; }
10658 }
10659 else if (start >= 0)
10660 {
10661 var end = r;
10662 if (end - start >= 2)
10663 {
10664 for (var i = start; i < end; i++)
10665 {
10666 for (var j = start; j < end; j++)
10667 {
10668 if (i === j)
10669 { continue; }
10670 moves.push({
10671 col: col,
10672 fromY: i,
10673 toY: j,
10674 dist: Math.abs(j - i),
10675 blockId: null
10676 });
10677 }
10678 }
10679 }
10680 start = -1;
10681 }
10682 }
10683 }
10684 return moves;
10685 }
10686
10687 function listMovesFromCore (core)
10688 {
10689 var moves = [];
10690 for (var col = 0; col < core.width; col++)
10691 {
10692 var segs = contiguousSegments(core, col);
10693 for (var s = 0; s < segs.length; s++)
10694 {
10695 var seg = segs[s];
10696 if (seg.length < 2)
10697 { continue; }
10698 for (var i = 0; i < seg.length; i++)
10699 {
10700 var fromY = Math.round(seg[i].y);
10701 for (var j = 0; j < seg.length; j++)
10702 {
10703 if (i === j)
10704 { continue; }
10705 var toY = Math.round(seg[j].y);
10706 moves.push({
10707 col: col,
10708 fromY: fromY,
10709 toY: toY,
10710 dist: Math.abs(toY - fromY),
10711 blockId: seg[i].id
10712 });
10713 }
10714 }
10715 }
10716 }
10717 return moves;
10718 }
10719
10720 /**
10721 * A 2-step setup: first swap creates no match, second swap does.
10722 * Prefers smaller total distance, then shorter first step, then the
10723 * same column / fromY / toY ties as findBotMove. First moves come
10724 * from the live core (legal segments only). Budget-capped.
10725 */
10726 function findSetupPlan (core, budget)
10727 {
10728 if (!core)
10729 { return null; }
10730 var width = core.width;
10731 var height = core.height;
10732 var grid = snapshotGrid(core);
10733 if (hasMatch(grid, width, height))
10734 { return null; }
10735 budget = budget == null ? PLAN_BUDGET : budget;
10736 var firstMoves = listMovesFromCore(core);
10737 firstMoves.sort(function (a, b)
10738 {
10739 if (a.dist !== b.dist)
10740 { return a.dist - b.dist; }
10741 if (a.col !== b.col)
10742 { return a.col - b.col; }
10743 if (a.fromY !== b.fromY)
10744 { return a.fromY - b.fromY; }
10745 return a.toY - b.toY;
10746 });
10747 var best = null;
10748 var evals = 0;
10749 for (var i = 0; i < firstMoves.length; i++)
10750 {
10751 var first = firstMoves[i];
10752 if (best && first.dist + 1 > best.total)
10753 { break; }
10754 applyColumnMove(grid, first.col, first.fromY, first.toY);
10755 if (hasMatch(grid, width, height))
10756 {
10757 applyColumnMove(grid, first.col, first.toY, first.fromY);
10758 continue;
10759 }
10760 var seconds = listMovesFromGrid(grid, width, height);
10761 for (var j = 0; j < seconds.length; j++)
10762 {
10763 var second = seconds[j];
10764 var total = first.dist + second.dist;
10765 if (best && total > best.total)
10766 { continue; }
10767 if (evals++ >= budget)
10768 { break; }
10769 applyColumnMove(grid, second.col, second.fromY, second.toY);
10770 var ok = hasMatch(grid, width, height);
10771 applyColumnMove(grid, second.col, second.toY, second.fromY);
10772 if (!ok)
10773 { continue; }
10774 var cand = {
10775 steps: [copyMove(first), copyMove(second)],
10776 total: total
10777 };
10778 if (betterPlan(cand, best))
10779 { best = cand; }
10780 }
10781 applyColumnMove(grid, first.col, first.toY, first.fromY);
10782 if (evals >= budget)
10783 { break; }
10784 // 1+1 is the shortest possible setup; firstMoves is sorted so
10785 // the first such plan is already the tie-break winner.
10786 if (best && best.total === 2)
10787 { break; }
10788 }
10789 return best;
10790 }
10791
10792 /**
10793 * True when `step` is still a legal vertical swap on this core, and
10794 * (when mustMatch) would create a 3+ match.
10795 */
10796 function stepIsValid (core, step, mustMatch)
10797 {
10798 if (!core || !step)
10799 { return false; }
10800 var moves = listMovesFromCore(core);
10801 var found = null;
10802 for (var i = 0; i < moves.length; i++)
10803 {
10804 if (movesEqual(moves[i], step))
10805 {
10806 found = moves[i];
10807 break;
10808 }
10809 }
10810 if (!found)
10811 { return false; }
10812 step.blockId = found.blockId;
10813 if (!mustMatch)
10814 { return true; }
10815 var grid = snapshotGrid(core);
10816 applyColumnMove(grid, step.col, step.fromY, step.toY);
10817 return hasMatch(grid, core.width, core.height);
10818 }
10819
10572 10820 /**
10573 10821 * One AI tick. `rng` is a () => [0,1) function. Success if roll < skill.
10574 10822 * At skill 0 the bot never moves; at skill 1 it always looks for a move.
10823 * `memory` is an optional object that stores a 2-step plan across ticks
10824 * (`memory.plan`). On a later successful roll the bot follows the
10825 * remaining step if it is still legal and still makes a match; otherwise
10826 * it re-plans.
10575 10827 */
10576 function tryBotRoll (core, skill, rng)
10828 function tryBotRoll (core, skill, rng, memory)
10577 10829 {
10578 10830 rng = rng || Math.random;
10579 10831 var roll = rng();
@@ -10581,13 +10833,73 @@ function tryBotRoll (core, skill, rng)
10581 10833 {
10582 10834 return { rolled: true, success: false, moved: false, roll: roll, move: null };
10583 10835 }
10836 var grid = snapshotGrid(core);
10837 if (hasMatch(grid, core.width, core.height))
10838 {
10839 if (memory)
10840 { memory.plan = null; }
10841 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10842 }
10843 if (memory && memory.plan && memory.plan.steps
10844 && memory.plan.index < memory.plan.steps.length)
10845 {
10846 var step = memory.plan.steps[memory.plan.index];
10847 var last = memory.plan.index === memory.plan.steps.length - 1;
10848 if (stepIsValid(core, step, last))
10849 {
10850 var followed = executeBotMove(core, step);
10851 if (followed)
10852 {
10853 memory.plan.index++;
10854 if (memory.plan.index >= memory.plan.steps.length)
10855 { memory.plan = null; }
10856 return {
10857 rolled: true,
10858 success: true,
10859 moved: true,
10860 roll: roll,
10861 move: step,
10862 followed: true
10863 };
10864 }
10865 }
10866 memory.plan = null;
10867 }
10584 10868 var move = findBotMove(core);
10585 if (!move)
10869 if (move)
10870 {
10871 if (memory)
10872 { memory.plan = null; }
10873 var ok = executeBotMove(core, move);
10874 return { rolled: true, success: true, moved: !!ok, roll: roll, move: move };
10875 }
10876 var chance = lookaheadChance(skill);
10877 if (chance <= 0 || !(rng() < chance))
10878 {
10879 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10880 }
10881 var plan = findSetupPlan(core);
10882 if (!plan || !plan.steps || !plan.steps[0])
10586 10883 {
10587 10884 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10588 10885 }
10589 var ok = executeBotMove(core, move);
10590 return { rolled: true, success: true, moved: !!ok, roll: roll, move: move };
10886 var first = plan.steps[0];
10887 var started = executeBotMove(core, first);
10888 if (started && memory)
10889 {
10890 memory.plan = { steps: plan.steps, index: 1, total: plan.total };
10891 }
10892 else if (memory)
10893 { memory.plan = null; }
10894 return {
10895 rolled: true,
10896 success: true,
10897 moved: !!started,
10898 roll: roll,
10899 move: first,
10900 planned: true,
10901 plan: plan
10902 };
10591 10903 }
10592 10904
10593 10905 function pickPlanet (rng, P)
@@ -10635,7 +10947,8 @@ OfflineBattle.prototype._initBots = function ()
10635 10947 core: core,
10636 10948 eliminated: false,
10637 10949 score: 0,
10638 aiAcc: 0
10950 aiAcc: 0,
10951 plan: null
10639 10952 });
10640 10953 }
10641 10954 };
@@ -10784,7 +11097,7 @@ OfflineBattle.prototype.tick = function (dt, playerCore)
10784 11097 {
10785 11098 bot.aiAcc -= BOT_INTERVAL;
10786 11099 if (bot.core.state === 'playing' && !bot.core.drag)
10787 { tryBotRoll(bot.core, skill, this.rng); }
11100 { tryBotRoll(bot.core, skill, this.rng, bot); }
10788 11101 }
10789 11102 }
10790 11103
@@ -10848,8 +11161,16 @@ var api = {
10848 11161 skillForRound: skillForRound,
10849 11162 scheduleForRound: scheduleForRound,
10850 11163 findBotMove: findBotMove,
11164 findSetupPlan: findSetupPlan,
10851 11165 tryBotRoll: tryBotRoll,
10852 11166 executeBotMove: executeBotMove,
11167 stepIsValid: stepIsValid,
11168 lookaheadChance: lookaheadChance,
11169 listMovesFromCore: listMovesFromCore,
11170 listMovesFromGrid: listMovesFromGrid,
11171 PLAN_BUDGET: PLAN_BUDGET,
11172 LOOKAHEAD_START: LOOKAHEAD_START,
11173 LOOKAHEAD_FULL: LOOKAHEAD_FULL,
10853 11174 snapshotGrid: snapshotGrid,
10854 11175 applyColumnMove: applyColumnMove,
10855 11176 hasMatch: hasMatch,
@@ -10569,11 +10569,263 @@ function executeBotMove (core, move)
10569 return true;
10569 return true;
10570}
10570}
10571
10571
10572/**
10573 * Max board evaluations (apply + hasMatch + undo) for a depth-2 search
10574 * in one AI tick. A 10×13 field with typical stacks stays well under this.
10575 */
10576var PLAN_BUDGET = 4000;
10577/** Skill at or below this: never start a 2-step setup (early rounds). */
10578var LOOKAHEAD_START = 0.10;
10579/** Skill at or above this: always look for a 2-step setup when no immediate match. */
10580var LOOKAHEAD_FULL = 0.40;
10581
10582/**
10583 * Probability of searching a 2-step setup after a successful roll
10584 * that found no immediate match. 0 through 10% skill (rondes 1–6),
10585 * then linear up to 1 at 40% skill (ronde 36).
10586 */
10587function lookaheadChance (skill)
10588{
10589 skill = Number(skill) || 0;
10590 if (skill <= LOOKAHEAD_START)
10591 { return 0; }
10592 if (skill >= LOOKAHEAD_FULL)
10593 { return 1; }
10594 return (skill - LOOKAHEAD_START) / (LOOKAHEAD_FULL - LOOKAHEAD_START);
10595}
10596
10597function copyMove (m)
10598{
10599 return {
10600 col: m.col,
10601 fromY: m.fromY,
10602 toY: m.toY,
10603 dist: m.dist,
10604 blockId: m.blockId
10605 };
10606}
10607
10608function movesEqual (a, b)
10609{
10610 return a && b && a.col === b.col && a.fromY === b.fromY && a.toY === b.toY;
10611}
10612
10613function betterImmediate (cand, best)
10614{
10615 if (!best)
10616 { return true; }
10617 if (cand.dist !== best.dist)
10618 { return cand.dist < best.dist; }
10619 if (cand.col !== best.col)
10620 { return cand.col < best.col; }
10621 if (cand.fromY !== best.fromY)
10622 { return cand.fromY < best.fromY; }
10623 return cand.toY < best.toY;
10624}
10625
10626function betterPlan (cand, best)
10627{
10628 if (!best)
10629 { return true; }
10630 if (cand.total !== best.total)
10631 { return cand.total < best.total; }
10632 var a0 = cand.steps[0];
10633 var b0 = best.steps[0];
10634 if (a0.dist !== b0.dist)
10635 { return a0.dist < b0.dist; }
10636 if (a0.col !== b0.col || a0.fromY !== b0.fromY || a0.toY !== b0.toY)
10637 { return betterImmediate(a0, b0); }
10638 return betterImmediate(cand.steps[1], best.steps[1]);
10639}
10640
10641/**
10642 * Legal vertical swaps from a colour grid: contiguous non-null cells
10643 * in a column (gaps break a segment, same as swapToward).
10644 */
10645function listMovesFromGrid (grid, width, height)
10646{
10647 var moves = [];
10648 for (var col = 0; col < width; col++)
10649 {
10650 var start = -1;
10651 for (var r = 0; r <= height; r++)
10652 {
10653 var filled = r < height && grid[col][r] != null;
10654 if (filled)
10655 {
10656 if (start < 0)
10657 { start = r; }
10658 }
10659 else if (start >= 0)
10660 {
10661 var end = r;
10662 if (end - start >= 2)
10663 {
10664 for (var i = start; i < end; i++)
10665 {
10666 for (var j = start; j < end; j++)
10667 {
10668 if (i === j)
10669 { continue; }
10670 moves.push({
10671 col: col,
10672 fromY: i,
10673 toY: j,
10674 dist: Math.abs(j - i),
10675 blockId: null
10676 });
10677 }
10678 }
10679 }
10680 start = -1;
10681 }
10682 }
10683 }
10684 return moves;
10685}
10686
10687function listMovesFromCore (core)
10688{
10689 var moves = [];
10690 for (var col = 0; col < core.width; col++)
10691 {
10692 var segs = contiguousSegments(core, col);
10693 for (var s = 0; s < segs.length; s++)
10694 {
10695 var seg = segs[s];
10696 if (seg.length < 2)
10697 { continue; }
10698 for (var i = 0; i < seg.length; i++)
10699 {
10700 var fromY = Math.round(seg[i].y);
10701 for (var j = 0; j < seg.length; j++)
10702 {
10703 if (i === j)
10704 { continue; }
10705 var toY = Math.round(seg[j].y);
10706 moves.push({
10707 col: col,
10708 fromY: fromY,
10709 toY: toY,
10710 dist: Math.abs(toY - fromY),
10711 blockId: seg[i].id
10712 });
10713 }
10714 }
10715 }
10716 }
10717 return moves;
10718}
10719
10720/**
10721 * A 2-step setup: first swap creates no match, second swap does.
10722 * Prefers smaller total distance, then shorter first step, then the
10723 * same column / fromY / toY ties as findBotMove. First moves come
10724 * from the live core (legal segments only). Budget-capped.
10725 */
10726function findSetupPlan (core, budget)
10727{
10728 if (!core)
10729 { return null; }
10730 var width = core.width;
10731 var height = core.height;
10732 var grid = snapshotGrid(core);
10733 if (hasMatch(grid, width, height))
10734 { return null; }
10735 budget = budget == null ? PLAN_BUDGET : budget;
10736 var firstMoves = listMovesFromCore(core);
10737 firstMoves.sort(function (a, b)
10738 {
10739 if (a.dist !== b.dist)
10740 { return a.dist - b.dist; }
10741 if (a.col !== b.col)
10742 { return a.col - b.col; }
10743 if (a.fromY !== b.fromY)
10744 { return a.fromY - b.fromY; }
10745 return a.toY - b.toY;
10746 });
10747 var best = null;
10748 var evals = 0;
10749 for (var i = 0; i < firstMoves.length; i++)
10750 {
10751 var first = firstMoves[i];
10752 if (best && first.dist + 1 > best.total)
10753 { break; }
10754 applyColumnMove(grid, first.col, first.fromY, first.toY);
10755 if (hasMatch(grid, width, height))
10756 {
10757 applyColumnMove(grid, first.col, first.toY, first.fromY);
10758 continue;
10759 }
10760 var seconds = listMovesFromGrid(grid, width, height);
10761 for (var j = 0; j < seconds.length; j++)
10762 {
10763 var second = seconds[j];
10764 var total = first.dist + second.dist;
10765 if (best && total > best.total)
10766 { continue; }
10767 if (evals++ >= budget)
10768 { break; }
10769 applyColumnMove(grid, second.col, second.fromY, second.toY);
10770 var ok = hasMatch(grid, width, height);
10771 applyColumnMove(grid, second.col, second.toY, second.fromY);
10772 if (!ok)
10773 { continue; }
10774 var cand = {
10775 steps: [copyMove(first), copyMove(second)],
10776 total: total
10777 };
10778 if (betterPlan(cand, best))
10779 { best = cand; }
10780 }
10781 applyColumnMove(grid, first.col, first.toY, first.fromY);
10782 if (evals >= budget)
10783 { break; }
10784 // 1+1 is the shortest possible setup; firstMoves is sorted so
10785 // the first such plan is already the tie-break winner.
10786 if (best && best.total === 2)
10787 { break; }
10788 }
10789 return best;
10790}
10791
10792/**
10793 * True when `step` is still a legal vertical swap on this core, and
10794 * (when mustMatch) would create a 3+ match.
10795 */
10796function stepIsValid (core, step, mustMatch)
10797{
10798 if (!core || !step)
10799 { return false; }
10800 var moves = listMovesFromCore(core);
10801 var found = null;
10802 for (var i = 0; i < moves.length; i++)
10803 {
10804 if (movesEqual(moves[i], step))
10805 {
10806 found = moves[i];
10807 break;
10808 }
10809 }
10810 if (!found)
10811 { return false; }
10812 step.blockId = found.blockId;
10813 if (!mustMatch)
10814 { return true; }
10815 var grid = snapshotGrid(core);
10816 applyColumnMove(grid, step.col, step.fromY, step.toY);
10817 return hasMatch(grid, core.width, core.height);
10818}
10819
10572/**
10820/**
10573 * One AI tick. `rng` is a () => [0,1) function. Success if roll < skill.
10821 * One AI tick. `rng` is a () => [0,1) function. Success if roll < skill.
10574 * At skill 0 the bot never moves; at skill 1 it always looks for a move.
10822 * At skill 0 the bot never moves; at skill 1 it always looks for a move.
10823 * `memory` is an optional object that stores a 2-step plan across ticks
10824 * (`memory.plan`). On a later successful roll the bot follows the
10825 * remaining step if it is still legal and still makes a match; otherwise
10826 * it re-plans.
10575 */
10827 */
10576function tryBotRoll (core, skill, rng)
10828function tryBotRoll (core, skill, rng, memory)
10577{
10829{
10578 rng = rng || Math.random;
10830 rng = rng || Math.random;
10579 var roll = rng();
10831 var roll = rng();
@@ -10581,13 +10833,73 @@ function tryBotRoll (core, skill, rng)
10581 {
10833 {
10582 return { rolled: true, success: false, moved: false, roll: roll, move: null };
10834 return { rolled: true, success: false, moved: false, roll: roll, move: null };
10583 }
10835 }
10836 var grid = snapshotGrid(core);
10837 if (hasMatch(grid, core.width, core.height))
10838 {
10839 if (memory)
10840 { memory.plan = null; }
10841 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10842 }
10843 if (memory && memory.plan && memory.plan.steps
10844 && memory.plan.index < memory.plan.steps.length)
10845 {
10846 var step = memory.plan.steps[memory.plan.index];
10847 var last = memory.plan.index === memory.plan.steps.length - 1;
10848 if (stepIsValid(core, step, last))
10849 {
10850 var followed = executeBotMove(core, step);
10851 if (followed)
10852 {
10853 memory.plan.index++;
10854 if (memory.plan.index >= memory.plan.steps.length)
10855 { memory.plan = null; }
10856 return {
10857 rolled: true,
10858 success: true,
10859 moved: true,
10860 roll: roll,
10861 move: step,
10862 followed: true
10863 };
10864 }
10865 }
10866 memory.plan = null;
10867 }
10584 var move = findBotMove(core);
10868 var move = findBotMove(core);
10585 if (!move)
10869 if (move)
10870 {
10871 if (memory)
10872 { memory.plan = null; }
10873 var ok = executeBotMove(core, move);
10874 return { rolled: true, success: true, moved: !!ok, roll: roll, move: move };
10875 }
10876 var chance = lookaheadChance(skill);
10877 if (chance <= 0 || !(rng() < chance))
10878 {
10879 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10880 }
10881 var plan = findSetupPlan(core);
10882 if (!plan || !plan.steps || !plan.steps[0])
10586 {
10883 {
10587 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10884 return { rolled: true, success: true, moved: false, roll: roll, move: null };
10588 }
10885 }
10589 var ok = executeBotMove(core, move);
10886 var first = plan.steps[0];
10590 return { rolled: true, success: true, moved: !!ok, roll: roll, move: move };
10887 var started = executeBotMove(core, first);
10888 if (started && memory)
10889 {
10890 memory.plan = { steps: plan.steps, index: 1, total: plan.total };
10891 }
10892 else if (memory)
10893 { memory.plan = null; }
10894 return {
10895 rolled: true,
10896 success: true,
10897 moved: !!started,
10898 roll: roll,
10899 move: first,
10900 planned: true,
10901 plan: plan
10902 };
10591}
10903}
10592
10904
10593function pickPlanet (rng, P)
10905function pickPlanet (rng, P)
@@ -10635,7 +10947,8 @@ OfflineBattle.prototype._initBots = function ()
10635 core: core,
10947 core: core,
10636 eliminated: false,
10948 eliminated: false,
10637 score: 0,
10949 score: 0,
10638 aiAcc: 0
10950 aiAcc: 0,
10951 plan: null
10639 });
10952 });
10640 }
10953 }
10641};
10954};
@@ -10784,7 +11097,7 @@ OfflineBattle.prototype.tick = function (dt, playerCore)
10784 {
11097 {
10785 bot.aiAcc -= BOT_INTERVAL;
11098 bot.aiAcc -= BOT_INTERVAL;
10786 if (bot.core.state === 'playing' && !bot.core.drag)
11099 if (bot.core.state === 'playing' && !bot.core.drag)
10787 { tryBotRoll(bot.core, skill, this.rng); }
11100 { tryBotRoll(bot.core, skill, this.rng, bot); }
10788 }
11101 }
10789 }
11102 }
10790
11103
@@ -10848,8 +11161,16 @@ var api = {
10848 skillForRound: skillForRound,
11161 skillForRound: skillForRound,
10849 scheduleForRound: scheduleForRound,
11162 scheduleForRound: scheduleForRound,
10850 findBotMove: findBotMove,
11163 findBotMove: findBotMove,
11164 findSetupPlan: findSetupPlan,
10851 tryBotRoll: tryBotRoll,
11165 tryBotRoll: tryBotRoll,
10852 executeBotMove: executeBotMove,
11166 executeBotMove: executeBotMove,
11167 stepIsValid: stepIsValid,
11168 lookaheadChance: lookaheadChance,
11169 listMovesFromCore: listMovesFromCore,
11170 listMovesFromGrid: listMovesFromGrid,
11171 PLAN_BUDGET: PLAN_BUDGET,
11172 LOOKAHEAD_START: LOOKAHEAD_START,
11173 LOOKAHEAD_FULL: LOOKAHEAD_FULL,
10853 snapshotGrid: snapshotGrid,
11174 snapshotGrid: snapshotGrid,
10854 applyColumnMove: applyColumnMove,
11175 applyColumnMove: applyColumnMove,
10855 hasMatch: hasMatch,
11176 hasMatch: hasMatch,