Code
Log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
oninit((game, match) => {
console.log("init", game, match);
});
onturn((game) => {
console.log("turn", game);
// 配置されていないエージェントはランダムに置く
// 配置されているエージェントは8方向からランダムに選択し動く
const agents = getAgents();
const actions = [];
for (let i = 0; i < agents.length; i++) {
const agent = agents[i];
if (agent.x === -1) {
// 配置されていないとき
// ランダムなマスを選択
const idx = Math.floor(Math.random() * game.field.tiles.length);
const { x, y } = idx2xy(idx);
actions.push({
agentId: i,
type: "PUT",
x,