Nifflas,
@Nifflas@mastodon.gamedev.place avatar

Function naming problems!

So, you know floor/ceiling/round

But, what do I name one that given the input 3.25 has a 75% chance of rounding it to 3 and 25% chance of rounding it to 4?

I realize it's going to be an incredibly useful function for adaptive music.

But... what do I call it?

jpojecp,
@jpojecp@mastodon.gamedev.place avatar

@Nifflas raound? randound? raoul?

deKay,
@deKay@mastodon.social avatar

@Nifflas regardless of their purpose, I always name my variables and functions after cheeses. So I suggest Wensleydale.

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@deKay omnomnomnom

I have no cheese in my naming, but all my custom file formats uses the Hotdog library (sort of library? I guess it's a library, I don't know the strict definition), which means the word Hotdog appears a LOT in my code.

deKay,
@deKay@mastodon.social avatar

@Nifflas 🌭

Nifflas,
@Nifflas@mastodon.gamedev.place avatar
deKay,
@deKay@mastodon.social avatar

@Nifflas ah, so you can calculate how fast the hotdog is going!

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@deKay Haha :) This one is a key velocity, as in, how hard you play the note on the musical instrument.

risingtail,
@risingtail@mastodon.gamedev.place avatar

@Nifflas maybe_round_up_or_possibly_down()
flexible_round_based_on_chance()
🤷‍♂️

mcc,
@mcc@mastodon.social avatar

@Nifflas randomized_round or round_upward?

You can think of "rounding modes" as being like "round up" "round down" "round to nearest" or "round toward zero". So "round randomized" would fit very cleanly into the existing classification (eg in the IEEE standard).

mcc,
@mcc@mastodon.social avatar

@Nifflas I would also be so tempted to find an excuse to use the word "stochastic" but I don't think it helps and it has a lot of letters

mcc,
@mcc@mastodon.social avatar

@Nifflas If you're gonna have a variety of these with different hardcoded probabilities then maybe something like round_low_75 or round_down_75 with the number being the probability of rounding down, so you don't ever forget which way the polarity goes

Craigp,
@Craigp@mastodon.social avatar

@Nifflas "flump"!

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@Craigp I like it, very catchy! It's like "lerp" which is one of my favorite things to say and type when I make games.

frozenfire92,
@frozenfire92@mastodon.gamedev.place avatar

@Nifflas weighted round?

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@frozenfire92 That... makes so much sense :)

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

Basically, the decimal part determines the weight of the chance it'll be rounded up or down

miblo,
@miblo@mas.to avatar

@Nifflas TryToRound()?

xeophin,
@xeophin@swiss.social avatar

@Nifflas Wikipedia calls it stochastic rounding? https://en.wikipedia.org/wiki/Rounding

xeophin,
@xeophin@swiss.social avatar

@Nifflas One of these things where you learn one method in school, and that's all you know – until years later you stumble over the Wikipedia article and … 🤯

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@xeophin Ooh nice! :) Thank you!

runevision,
@runevision@mastodon.gamedev.place avatar

@xeophin @Nifflas When I read the description of the method I thought “that’s stochastic rounding” without ever having heard of the term stochastic rounding. It’s just - that’s what it is! It should be clear to anyone who knows the word stochastic and the word rounding.

Nifflas,
@Nifflas@mastodon.gamedev.place avatar

@runevision @xeophin Yeah, I think the choice for the name of the function is extremely obvious now :)

I'm going for

int StochasticRound(float value)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • mdbf
  • DreamBathrooms
  • everett
  • magazineikmin
  • modclub
  • Durango
  • rosin
  • Youngstown
  • slotface
  • love
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • thenastyranch
  • provamag3
  • khanakhh
  • GTA5RPClips
  • tester
  • normalnudes
  • cubers
  • ethstaker
  • osvaldo12
  • cisconetworking
  • Leos
  • anitta
  • tacticalgear
  • megavids
  • JUstTest
  • All magazines