1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import * as connect4 from "https://esm.town/v/saolsen/connect4";
import { connect4_agent } from "https://esm.town/v/saolsen/connect4_agent";
function rand_action(state: connect4.State): connect4.Action {
let player = state.next_player;
while (true) {
let column = Math.floor(Math.random() * connect4.COLS);
let action = { player, column };
if (connect4.check_action(state, action) === "ok") {
return action;
}
}
}
export default connect4_agent(rand_action);