Created
August 10, 2020 13:50
-
-
Save wand125/f0577a40ed76e58a1681aafab4090c6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { WholeHistoryRating } = require('whr') | |
const AllData = require("./alldata") | |
const whr = new WholeHistoryRating({w2: 4}); | |
const firstDate = new Date(1953, 9, 19); | |
const names = {}; | |
const beginTime = new Date(); | |
console.error(`${AllData.length} records`); | |
AllData.forEach((e, i) => { | |
const dateArr = e.date.split('-').map(e=>parseInt(e)); | |
const date = new Date(dateArr[0], dateArr[1] - 1, dateArr[2]); | |
const day = (date.getTime() - firstDate.getTime()) / 86400 / 1000; | |
if (e.firstWin || e.secondWin) { | |
names[e.firstPlayer] = true; | |
names[e.secondPlayer] = true; | |
whr.createGame(e.firstPlayer, e.secondPlayer, e.firstWin ? "B" : "W", day, 0) | |
} | |
if (i % 100 == 100 - 1) { | |
whr.iterate(1) | |
console.error(`game: ${i+1}, day: ${date.toString()}, time: ${((new Date()).getTime() - beginTime.getTime()) / 1000}s`); | |
} | |
}); | |
whr.iterate(100) | |
const result = {}; | |
Object.keys(names).forEach((name) => { | |
result[name] = whr.ratingsForPlayer(name); | |
}); | |
console.log(JSON.stringify(result)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment