Skip to content

Instantly share code, notes, and snippets.

@alxgrk
Last active June 3, 2020 09:30
Show Gist options
  • Save alxgrk/e8918d9c697a779d9301fbcbbdbb3a8d to your computer and use it in GitHub Desktop.
Save alxgrk/e8918d9c697a779d9301fbcbbdbb3a8d to your computer and use it in GitHub Desktop.
Twitter-User Contributor-Algorithm
actAsContributor(previousSession) {
r = Random(0, 1)
currentSession = null
if (r <= 0.7 && previousSessions != Sessions.ScrollTimeline) {
currentSession = Sessions.ScrollTimeline
scrollTimelineSession()
} else if (r <= 0.9 && previousSessions != Sessions.Posting) {
currentSession = Sessions.Posting
postingSession()
} else if (r <= 1 && previousSessions != Sessions.Follow) {
currentSession = Sessions.Follow
followSession()
}
if (Random(0, 1) <= 0.3) {
// sometimes we want to immediately append another session
actAsContributor(currentSession)
}
// might be of interest at some later point
// if (Random(0, 1) <= 0.1) {
// browseTrends()
// }
// if (Random(0, 1) <= 0.05) {
// editOwnProfile()
// }
// if (Random(0, 1) <= 0.02) {
// sendMessageToFriend()
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment