-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
45 lines (35 loc) · 974 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react'
import ReactDOM from 'react-dom'
import _ from './lib/_'
import { Briscola, Deck } from './lib/game'
import { Table } from './jsx/Table.jsx'
const $app = document.getElementById('main')
window.addEventListener("load", function(event) {
main()
});
function main() {
const player_id = 'MAX'
const game = new Briscola(['MAX', 'MIN'], Deck())
let ms = 0
game.start()
render(_.clone(game), null, ms)
while ( ! game.terminal_test()) {
game.result(_.random(game.actions()), false)
ms += 1000
render(_.clone(game), null, ms)
game.result(_.random(game.actions()), false)
ms += 1000
render(_.clone(game)._before_reset, null, ms)
ms += 1000
render(_.clone(game), null, ms)
}
function render(state, command, ms) {
setTimeout(() => {
ReactDOM.render(React.createElement(Table, {
player_id: player_id,
state: state,
command: null
}), $app)
}, ms)
}
}