Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

76 changes: 0 additions & 76 deletions TESTING.md

This file was deleted.

112 changes: 65 additions & 47 deletions src/app/telos.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
~(tap by ratings)
has-player-in-ratings
player.action
|= [=game (map player player-data)]
|= [=game (map player rating)]
^- card
:* %pass ~ %agent [our.bowl dap.bowl]
%poke %delete-player-from-game !>([game player.action])
Expand Down Expand Up @@ -326,7 +326,7 @@
ratings (~(put by ratings) [game.action ~])
==
=/ new-ratings
(compute-ratings-game (flop (~(got by archive) game.action)))
(compute-ratings-game game.action (flop (~(got by archive) game.action)))
=/ new-ratings-list
~(tap by new-ratings)
:_ %= this
Expand All @@ -337,34 +337,34 @@
:: update subscribers to this game
%+ turn
new-ratings-list
|= [=player =player-data]
|= [=player =rating]
^- card
:* %give %fact ~[/ratings/(scot %tas game.action)]
%telos-player-rating !>([player r.player-data])
%telos-player-rating !>([player rating])
==
::
:: update subscribers to one player in any game
%+ turn
new-ratings-list
|= [=player =player-data]
|= [=player =rating]
^- card
:* %give %fact ~[/ratings/(scot %p player)]
%telos-game-rating !>([game.action r.player-data])
%telos-game-rating !>([game.action rating])
==
::
:: update subscibers to one player in this game
%+ turn
new-ratings-list
|= [=player =player-data]
|= [=player =rating]
^- card
:* %give %fact ~[/ratings/game/(scot %p player)]
%telos-rating !>(r.player-data)
%telos-rating !>(rating)
==
== :: end of list of lists of cards
== :: end of server actions
== :: end of mark branches
::
++ on-watch
++ on-watch
|= =path
^- (quip card _this)
?+ path (on-watch:def path)
Expand All @@ -379,13 +379,13 @@
%+ fall
%+ bind
(~(get by ratings) game)
|= ratings=(map player player-data)
|= ratings=(map player rating)
~(tap by ratings)
~
|= [=player =player-data]
|= [=player =rating]
^- card
:* %give %fact ~
%telos-player-rating !>([player r.player-data])
%telos-player-rating !>([player rating])
==
::
:: ratings updates for a player
Expand All @@ -397,10 +397,10 @@
~(tap by ratings)
has-player-in-ratings
player
|= [=game players=(map ^player player-data)]
|= [=game players=(map ^player rating)]
^- card
:* %give %fact ~
%telos-game-rating !>([game r:(~(got by players) player)])
%telos-game-rating !>([game (~(got by players) player)])
==
::
:: ratings updates for a player in one game
Expand All @@ -411,11 +411,11 @@
?> (~(has by ratings) game)
:_ this
%+ turn
^- (list player-data)
^- (list rating)
(drop (~(get by (~(got by ratings) game)) player))
|= =player-data
|= =rating
:* %give %fact ~
%telos-rating !>(r.player-data)
%telos-rating !>(rating)
==
== :: end of path branches
::
Expand Down Expand Up @@ -456,8 +456,8 @@
~(tap by ratings)
has-player-in-ratings
player
|= [=game players=(map ^player player-data)]
^- [^game (pair player-data (list match))]
|= [=game players=(map ^player rating)]
^- [^game (pair rating (list match))]
:- game
:- (~(got by players) player)
(skim (~(got by archive) game) (curr has-player-in-match player))
Expand All @@ -476,8 +476,8 @@
~
%+ bind
(~(get by (~(got by ratings) game)) player)
|= =player-data
:- r.player-data
|= =rating
:- rating
%+ skim
(~(got by archive) game)
(curr has-player-in-match player)
Expand Down Expand Up @@ -513,8 +513,8 @@
?~ players=(~(get by ratings) game)
~
%- ~(run by u.players)
|= =player-data
r.player-data
|= =rating
rating
::
:: return all ratings for a player
:: .^(noun %gx /=telos=/ratings/~sampel-palnet/noun)
Expand All @@ -530,9 +530,9 @@
~(tap by ratings)
has-player-in-ratings
player
|= [=game ratings=(map ^player player-data)]
^- [^game @rd]
[game r:(~(got by ratings) player)]
|= [=game ratings=(map ^player rating)]
^- [^game @ud]
[game (~(got by ratings) player)]
::
:: return rating for one player in one game
:: .^(noun %gx /=telos=/ratings/chess/~sampel-palnet/noun)
Expand All @@ -547,8 +547,8 @@
~
%+ bind
(~(get by (~(got by ratings) game)) player)
|= =player-data
r.player-data
|= =rating
rating
::
:: return ratings within a range for one game
:: .^(noun %gx /=telos=/ratings/chess/.~1250/.~1750/25/0/noun)
Expand All @@ -571,12 +571,12 @@
%+ skim
%+ skim
~(tap by (~(got by ratings) game))
|= [player =player-data]
(lth r.player-data hi)
|= [player =player-data]
(gth r.player-data lo)
|= [=player =player-data]
[player r.player-data]
|= [player =rating]
(lth rating hi)
|= [player =rating]
(gth rating lo)
|= [=player =rating]
[player rating]
== :: end of scries
::
++ on-agent
Expand Down Expand Up @@ -605,45 +605,63 @@
our.bowl
==
::
=/ new-ratings
(update-ratings (~(got by ratings) game) winner loser draw)
=/ new-game-ratings
%- %~ put by
%- %~ put by
(~(got by ratings) game)
:- loser
%: update-elo-rating
game
draw
loser
(~(got by ratings) game)
:-(new-match (~(got by archive) game))
==
:- winner
%: update-elo-rating
game
draw
winner
(~(got by ratings) game)
:-(new-match (~(got by archive) game))
==
::
=/ winner-new-data
(~(got by new-ratings) winner)
(~(got by new-game-ratings) winner)
::
=/ loser-new-data
(~(got by new-ratings) loser)
(~(got by new-game-ratings) loser)
::
:: confirm results
:- :~ :: update players with their new ratings
:* %pass ~ %agent [winner game]
%poke %win !>([id loser r.winner-new-data])
%poke %win !>([id loser winner-new-data])
==
:* %pass ~ %agent [loser game]
%poke %loss !>([id winner r.loser-new-data])
%poke %loss !>([id winner loser-new-data])
==
:: update other subscribers
:* %give %fact ~[/ratings/(scot %tas game)]
%telos-player-rating !>([winner r.winner-new-data])
%telos-player-rating !>([winner winner-new-data])
==
:* %give %fact ~[/ratings/(scot %tas game)]
%telos-player-rating !>([loser r.loser-new-data])
%telos-player-rating !>([loser loser-new-data])
==
:* %give %fact ~[/ratings/(scot %p winner)]
%telos-game-rating !>([game r.winner-new-data])
%telos-game-rating !>([game winner-new-data])
==
:* %give %fact ~[/ratings/(scot %p loser)]
%telos-game-rating !>([game r.loser-new-data])
%telos-game-rating !>([game loser-new-data])
==
:* %give %fact ~[/ratings/game/(scot %p winner)]
%telos-rating !>(r.winner-new-data)
%telos-rating !>(winner-new-data)
==
:* %give %fact ~[/ratings/game/(scot %p loser)]
%telos-rating !>(r.loser-new-data)
%telos-rating !>(loser-new-data)
==
==
%= this
ratings (~(put by ratings) game new-ratings)
ratings (~(put by ratings) game new-game-ratings)
archive (~(put by archive) game :-(new-match (~(got by archive) game)))
==
::
Expand Down
Loading