Scoring Battles obtained from API
Using JavaScript to analyze Splinterlands battle data - Scoring teams.
In my previous hive blog, I've discussed how to obtain battle data from player and his 50 previous opponents.
In this post, I've scored the battles obtained.
Analyze Battles
Sorting Battles to teams, summoners, and monsters, and then score their performance by rating 1
if one and -1
if lost. -0.5
to both teams if lost.
const verdictToScore = {w: 1, l: -1, d: -0.5};
verdict being if the team won or lost. Having a helper map separately allows us to assign values to different results without having to edit a lot of code.
Scoring teams one by one follows the below flow. the same for summoners and monsters.
Finally, I get a json which gets sorted by the score and can be used while battle.
team | summoner | monsters |
---|---|---|
You can find the script in my git repo at azarmadr/bot-splinters in file score.js
0
0
0.000
0 comments