跳到正文
DEV Community· Ant Games·· 2 小時前AI 評分45

WARSHIP WORKSHOP 如何透過互相對戰為 100,000 艘 AI 太空船排名

How we ranked 100,000 AI spaceships by making them fight each other

AI 導讀

Ant Games 團隊以遊戲本身的戰鬥規則,讓 100,000 艘 WARSHIP WORKSHOP 對手太空船互相對戰並按結果評分,建立六個級別的排名。排名測試共記錄 500,000 場對戰;同一批太空船在 4 個及 6 個工作執行緒下重播,結果逐字節相同。編者註:原文標題未明確點名遊戲,因此標題主體取自正文。

正文

WARSHIP WORKSHOP: two 3D warships exchange fire above a planet

Play WARSHIP WORKSHOP free in your browser. It is a 3D space auto battler: you build a ship from parts, press FIGHT, and watch it battle a rival on its own. This post is about one problem behind it that turned out to be harder than the ships: how do you decide how strong 100,000 rival ships are, so that every match you pick is a fair test?

A note on how it was made: the game was built with AI coding tools, directed and checked by our team at Ant Games. It is free, there is no pay to win, there is no sign-up, and it plays in the browser with nothing to install.

The setup: you build, it fights

You choose a hull, paint or cut its cells into your own shape (with mirror and undo), and drag guns, shields and engines onto it. There are 500 parts and 20 hulls to unlock by playing. Two bars limit you: BUDGET and POWER. Then you press FIGHT and take your hands off. You can pause at any moment and step through every part on both ships, and you can replay any fight afterwards.

The rules of a fight are short. A ship with no reactor, or no working gun, is out. At 90 seconds, the less damaged ship wins. That is all the game tells you, because the interesting part happens before the fight, in the build.

That raises the design problem. If the player only makes one decision (the build), then the quality of the opponent decides whether the decision means anything. A rival that is far too strong teaches nothing. A rival that is far too weak is a free win. So the rival has to be chosen with care, and "with care" needs a number for how strong each rival is.

Tiers, budgets and the line you can see

The game has six ranked tiers. Your budget runs from 440 in the first tier to 5,200 in the last. Rivals are built with between 1x and 2x your budget, and the exact budget line for both ships is shown on every match.

We chose to show that line rather than hide it. If a rival has twice your budget, you see it before you build. Then a loss has a readable cause: you were outspent, or you spent badly. Nobody pays to change that. Credits come from fighting, and parts are unlocked with credits.

Ranking 100,000 rivals without guessing

There are 100,000 ranked rivals across the six tiers. Nobody can playtest 100,000 ships by hand, and nobody can estimate their strength by reading their parts list. A railgun next to a small shield might be great or might be useless, depending on where the engines are.

So the ranking is made by the ships themselves. Our tooling plays rival ships against each other in duels, in rounds, tier by tier, and rates each ship from its results. The same kind of rating system chess players know (our own notes talk about "Elo") is the idea: win against a strong ship and you go up a lot; lose to a weak one and you go down.

A sketch of the idea, not our code:

for each round in 1..10:
    for each tier:
        pair up ships near each other in rating
        run each pair through the real fight rules
        move the winner's rating up, the loser's down
write the final table into the game's data

The important detail is "the real fight rules". The duels are not a model of the game. They are the game's own combat, run by our tools instead of by a person with a mouse. In the pass that ranked the 100,000 rivals, our logs show 500,000 duels.

Checks that can fail

A ranking is only useful if it matches what a player will feel, so we kept asking whether the table agreed with the game. Here are three things our own notes record, including the unflattering ones.

A check found a real fault. In an earlier pass over 70,000 rivals, 829 ships carried more than two reverse drives, which are engines that push a ship backwards. A ship with several of them does not behave like a ship that kites its opponent. We counted newly legal placements at 25,131 against a bar of 5,000. The fix made each drive keep its requested direction through the final layout. A second run then found too few ships with exactly one reverse drive (3,051 against a floor of 5,000), because a later generator step had added a second drive anyway. That was fixed at the source rather than by moving the threshold. Ships with exactly one went from 3,051 to 7,268, and none had more than two.

The tournament gave the same answer when run differently. A ranking that changes with the number of CPU cores is a bug. When the same ships were replayed on 4 workers and on 6 workers, the results came out byte for byte equal.

Some checks stayed red, and we said so. One check asked whether the top ten rivals in the first tier beat the bottom ten (they did, 20 of 20) and whether they beat the starter ship (they beat it 6 times in 10, against a bar of 8). Another found that rivals carrying certain devices rated more than 60 Elo above their hull class in 12 of 139 comparisons. We recorded both as known balance issues instead of quietly changing the bar. A later test with the device switched on and off showed it was not the device itself: the flagged ships won through their builds.

One more rule: no dead fights

A fight with a ship that cannot move is boring to watch. So a ship with no engine is not simply stuck: it drifts in at the base speed and cannot back away or slide. That keeps every fight a fight, and it keeps the rule easy to state.

What we would do again, and what we would not

What worked: using the game's own fight rules to rate the rivals, and keeping the budget line visible, so the player's information and the ranking's information are the same.

What we would do differently: the ranking took far longer than we had planned for. One tier ran at about 340 duels a minute, much slower than expected, and the team had to rebalance the workers mid-run. If your game needs a ladder of thousands of opponents, build the tournament harness before the opponents, not after.

If you make games with generated content, the lesson is general: measure the content with the same code that plays the game. Then a number in your table means the same thing as a result on your screen.

Try it

The ranked ladder, the build screen and the replay are all in the page, free, with no account. Build a ship and press FIGHT, then pause mid-battle and step through the parts one by one.

來源:DEV Community · dev.to