ID:2245236
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
The fact that pick() has its odd syntax has always irked me.
pick(4;0.75, 2;0.5, 1;0.25)


how about:

pick(0.75 = 4, 0.5 = 2, 0.25 = 1)


(ie, make it do it via the same syntax as list())
Agreed, but I imagine changing the syntax of something that's been around as long as pick() would be hairy. I suppose it could throw a warning if it came across pick() with ; on new compiles though.
Bump. I always end up looking the syntax on help and still getting it wrong.
Frankly I never use the probability syntax for pick(); I prefer to roll my own routine called pickweight() and use that instead, the only downside being that you can't pick from a list of numbers because they're not valid associative keys.
Pick would be useful if the weighting was at least accessible at runtime instead of just compile time. It's a giant oversight.
Well, if you had prob accept text and automatically turn into numbers, you'd have an easy way writing a script that picks a var from a list depending on its probability, which might be nice. Might be highly unwhatever in terms of syntax as you'd need pick to take a text var:

area
fightingzone
var/list/moblist=("49"="var/mob/enemy/Wolf","50.5"="var/mob/enemy/Bat","0.5"="var/mob/enemy/THEHIDDENFORESTGOD")

mob/player/proc
GetIntoFight()
var/area/CurrentArea=src.loc.loc
var/EvilEnemy=pick(moblist)

Well, in terms of syntax this is a horrible idea, but it might be useful:, it would be helpful, not needing to somehow separate the prob's value from the actual variable, so easy to store and also easy to write as it doesn't require me to know how long the list is etc.etc.
Personally I would rather the syntax was list(item = weight) instead of list("weight" = item)
Actually pretty good idea. I thought that weight=item would interfere with the list.len, but the way you write it, surely would be cool. Then, we'd just take what MrStonedOne said in backwards, pick(arg=weight) and that would be pretty cool to have.