← 返回 openai 的题目列表Optimal Turn-Based Monster Battle Simulation with Ordering and Revival Decisions
类型:online_judge
Problem: Optimal Turn-Based Monster Battle Simulation (Ordering + Revival Decisions)
You have two monster teams A and B. Each monster has:
hp (positive integer)
atk (positive integer)
optionally special abilities (exact rules provided in the interview)
Core Rules (build an extensible simulator)
The battle proceeds in turns (who attacks first / simultaneous attacks depends on the provided rules).
The two active monsters attack, reducing the opponent’s HP.
When a monster’s hp <= 0, it is defeated and removed.
Controllable Decisions
You can choose a strategy to maximize win probability, including:
Deployment order: choose the order in which your monsters enter battle (and possibly when to swap, if allowed).
Revival decisions: under certain conditions, defeated monsters may be revived; you decide whether/when/which to revive (if applicable).
Extension: Revival Mechanism
A revival rule exists (e.g., revive at partial HP, limited number of revives, or skill-triggered revival). Your implementation must support it and incorporate revival decisions into the search.
Goal
Implement an algorithm to find an optimal strategy maximizing overall win probability. Requirements:
Fully simulate all possible battle paths and revival decisions (search the strategy space).
Provide an efficient solution via state representation, pruning, memoization, etc.
Suggested I/O
Input: two teams and parameters describing abilities/revival rules.
Output: maximum win probability (or win/lose in deterministic settings), optionally also an optimal strategy.
Sample Tests (Illustrative)
Because exact rules were not specified in the post, these tests are structural:
Deterministic fight with no revival.
One-time revival available.
Multiple monsters where order matters.
Example
Input
(illustrative)
A: [(hp=3,atk=2)]
B: [(hp=4,atk=1)]
no revival
Output
deterministic win/lose per rules