Live data from Hacker News

How to Shuffle Songs? (2014)

engineering.atspotify.com

51–60 of 66 posts

Re: How to Shuffle Songs? (2014)

#51
post #15
post #10

Earlier quoted context omitted.

> When people say they want to "randomly shuffle a playlist", they really don't want that. Same in games. "I had an 80% chance to hit and didn't" is a perfect example.

Leading to features like "Karmic Dice" in the recent Baldur's Gate 3

There is a consideration there that isn't necessarily a problem with randomness itself. (Though I agree that the randomness does bring its own problems.)

Say you're playing through someone's electronic D&D module and you try to do something with a 90% chance of success. Then you roll a 2. You didn't make a mistake when deciding what to do, so that feels wrong -- this is a problem with randomness.

What do you do? You reload from right before you tried to do the thing, and you reroll. The game can't actually make you accept randomness if you don't want to. So they have to do something else.

Re: How to Shuffle Songs? (2014)

#52
post #19

Earlier quoted context omitted.

Rob Pardo (Blizzard, World of Warcraft (2004)) said they decided to model randomness after how players thought it worked. > ..at least once a week, a developer would come to my office, and say "the random number generator is broken, we need to look at it."--It's because they hit a streak. [1] [1] https://www.youtube.com/watch?v=FhC0NaB6ock&t=2343s He shares more details about game design choices in the video.

Video games are rife with randomness manipulation. - X-Com 2 lies in favor of the playing when displaying a chance of hitting of 85% [ https://www.gamedeveloper.com/design/jake-solomon-explains-t... ] - Baldur's Gate 3 "Karmic Dice" will prevent streaks of very high or lows rolls - Tetris games doesn't use Math.random for piece distribution. Most modern Tetris (like Tetris Effect) uses Fischer-Yates with 7 pieces (in…

there was a whole HN post about the Tetris RNG a few months back. I'm too lazy to search rn but it might be worth a read for others.

Re: How to Shuffle Songs? (2014)

#53
Any shuffle algorithm is fine but the problem is Spotify's brainlessness: it routinely plays songs it just played. If you are any long-term user then you have playlists of hundreds of songs and my guess is that you haven't heard some of those songs in ages which means ... the FEATURE IS BROKEN.

I'd prefer a weighted shuffle based on the staleness of a song in a playlist. That way you eventually get through all of the music but in a pseudo-random order.

Re: How to Shuffle Songs? (2014)

#54

This is one of my favourite things about psychology, perception and programming. When people say they want to "randomly shuffle a playlist", they really don't want that. They want the perception of randomness, but _true_ random doesn't abide by rules. If you're actually random, there is a probability that it might just play all the songs straight through. Or just pick songs by a single artist back-to-back.

> there is a probability

There is a probability that entropy will decrease, it's just small enough to neglect. Playing songs straight through isn't really a concern.

Re: How to Shuffle Songs? (2014)

#55
post #19

Earlier quoted context omitted.

Rob Pardo (Blizzard, World of Warcraft (2004)) said they decided to model randomness after how players thought it worked. > ..at least once a week, a developer would come to my office, and say "the random number generator is broken, we need to look at it."--It's because they hit a streak. [1] [1] https://www.youtube.com/watch?v=FhC0NaB6ock&t=2343s He shares more details about game design choices in the video.

Video games are rife with randomness manipulation. - X-Com 2 lies in favor of the playing when displaying a chance of hitting of 85% [ https://www.gamedeveloper.com/design/jake-solomon-explains-t... ] - Baldur's Gate 3 "Karmic Dice" will prevent streaks of very high or lows rolls - Tetris games doesn't use Math.random for piece distribution. Most modern Tetris (like Tetris Effect) uses Fischer-Yates with 7 pieces (in…

Jonathan Blow did a good talk on this, but unfortunately the only version of it I know of is concatenated by some youtube uploader with a silly twitch stream (also by Jonathan Blow, but less interesting, and not even sure he is correct about that particular game being rigged?) so just stop watching after the presentation: https://www.youtube.com/watch?v=l0KEDYFWbVc ("Explicit Lying" seems to be the title of the talk?)

Re: How to Shuffle Songs? (2014)

#56
post #19

This is one of my favourite things about psychology, perception and programming. When people say they want to "randomly shuffle a playlist", they really don't want that. They want the perception of randomness, but _true_ random doesn't abide by rules. If you're actually random, there is a probability that it might just play all the songs straight through. Or just pick songs by a single artist back-to-back.

Rob Pardo (Blizzard, World of Warcraft (2004)) said they decided to model randomness after how players thought it worked. > ..at least once a week, a developer would come to my office, and say "the random number generator is broken, we need to look at it."--It's because they hit a streak. [1] [1] https://www.youtube.com/watch?v=FhC0NaB6ock&t=2343s He shares more details about game design choices in the video.

An easier solution is to not say e.g. "this attack has a 25% hit probability" but rather say "this attack will hit every 4th time".

Then you are not lying to the users, and your tooltips/docs etc. are correct as well.

Re: How to Shuffle Songs? (2014)

#57
I once implemented an algorithm that went the entire different direction, because I wanted to shuffle across my entire collection. This is back in the era of the filesystem being the main driver, so I had my files arranged in [Very Broad Genre]/[Artist]/[Album], and what my algorithm did was that when it came time to pick, it picked something out of the current album with ~80% probability, kept the artist but switched album with like ~10%, and switched the genre entirely with ~10%. It also excluded the last N songs played, with that number generally larger than the number of songs in one album, so if it shuffled its way through one album it would be forced to jump up at least one level. The last few albums were also kept in the block list, so if it left one album it wouldn't go back to it for a while. (Genres I didn't worry about so much.)

The idea is that it was random, but that it tended to keep the same mood, and once it did switch, it would tend to stay in that mood for a while. (I suppose I would have also made it sticky once it did switch genres, but I didn't get to use it for long enough to matter.) This also trivially gives you three "No, not this, go to next" buttons, one for the album level, one for the artist level, and one to switch out the genre entirely.

Unfortunately, I have not had time to pour over the mp3 players around to see who has pluggable shuffle algorithms exposed conveniently enough to make this work, and unfortunately it's a lot of work to tag MP3s enough to make this work since those "genre" tags are generally pretty bad, so I haven't had this in a while and I've gotten used to just manually curating my genre mood shifts.

I don't like any of the cloud service shufflers I've used, though. They are concerned about aspects of the song I'm not and oblivious to the ones I do care about and the net effect is about like listening to a radio station, where I end disliking every third song or so no matter how I tune it. Fortunately, I've been building my personal MP3 collection for over 20 years so I'm not even remotely dependent on them.

Re: How to Shuffle Songs? (2014)

#58
post #44

Earlier quoted context omitted.

Video games are rife with randomness manipulation. - X-Com 2 lies in favor of the playing when displaying a chance of hitting of 85% [ https://www.gamedeveloper.com/design/jake-solomon-explains-t... ] - Baldur's Gate 3 "Karmic Dice" will prevent streaks of very high or lows rolls - Tetris games doesn't use Math.random for piece distribution. Most modern Tetris (like Tetris Effect) uses Fischer-Yates with 7 pieces (in…

I don't know if that's still the case (haven't played in more than three years), but Magic the Gathering Arena (digital version of the collectible card game) used to rig the opening hands to make them "more average". This had consequences on competitive play; they wouldn't even tell you how exactly the algorithm worked, so the only way to build a deck was lots and lots of simulations.

There are also specific physical shuffling techniques used in physical magic the gathering games, in order to distribute mana more "evenly".

Re: How to Shuffle Songs? (2014)

#59
post #44

Earlier quoted context omitted.

I don't know if that's still the case (haven't played in more than three years), but Magic the Gathering Arena (digital version of the collectible card game) used to rig the opening hands to make them "more average". This had consequences on competitive play; they wouldn't even tell you how exactly the algorithm worked, so the only way to build a deck was lots and lots of simulations.

There are also specific physical shuffling techniques used in physical magic the gathering games, in order to distribute mana more "evenly".

Yeah, but those are cheating, and it's not particularly easy to cheat in that specific way. In a high level match, whenever you shuffle your deck, your opponent can (and in fact is required to) also shuffle it, and they're the last to touch it.

Cheaters, like in any game, tend to look for methods that maximize the combination of impact and plausible deniability. Marked sleeves, sleight of hand (pun very much intended) etc.

Re: How to Shuffle Songs? (2014)

#60
post #36
post #20

Ok, so this article proves that they know how to do it, but they seem to have forgotten over the intervening 9 years - according to some, the shuffle function now prefers similar songs to "keep the vibe", but according to the Spotify support pages, that's a "smart shuffle" feature, and I don't have that because I'm too cheap for the paid plan. Anyway, shuffle should play the songs in a playlist in random order, but m…

Winamp had it right.

That's why it whipped the llama's ass.
Post reply on HN