this post was submitted on 02 Feb 2024
74 points (95.1% liked)

Ask Lemmy

25987 readers
2156 users here now

A Fediverse community for open-ended, thought provoking questions


Rules: (interactive)


1) Be nice and; have funDoxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can't say something nice, don't say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them


2) All posts must end with a '?'This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?


3) No spamPlease do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.


4) NSFW is okay, within reasonJust remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either [email protected] or [email protected]. NSFW comments should be restricted to posts tagged [NSFW].


5) This is not a support community.
It is not a place for 'how do I?', type questions. If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email [email protected]. For other questions check our partnered communities list, or use the search function.


Reminder: The terms of service apply here too.

Partnered Communities:

Tech Support

No Stupid Questions

You Should Know

Reddit

Jokes

Ask Ouija


Logo design credit goes to: tubbadu


founded 1 year ago
MODERATORS
 

Dear mobile game devs. When I play games like that, I always wonder if it's the physics engine that's actually random and produces the result?

Or is the result calculated before the animation happens, and dictates the animation?

I've always wondered. I have some notion of programming, but from far back, and I've been scratching my head long enough about this.

Thanks in advance.

top 26 comments
sorted by: hot top controversial new old
[–] [email protected] 27 points 6 months ago (2 children)

In theory, it could do either -- there's no way of knowing from just looking at a screenshot -- but I'd assume that normally, it's simulating the physics and looking at where the ball winds up to determine the score, and that if the physics engine is deterministic, that any variation from launch to launch in a pachinko simulator would come from slightly varying launch speed and angle.

If you can manage to get a ball stuck in a game, or if the game can fire multiple balls simultaneously, then I'd say that'd be consistent with it just simulating the physics and determining the outcome from where the ball winds up.

I don't really know what the benefit to computing a result in advance would be, unless one has a model that optimizes for player engagement or something.

[–] [email protected] 3 points 6 months ago

One thing I'd watch out for as a developer is that players might find a setup to get max points every time, so I'd fuzz the plunger input to make it more random.

[–] [email protected] 2 points 6 months ago (1 children)

There are only seven buckets. Couldn't you predetermine the result while also giving the illusion of the physics doing it by just simulating a bunch of slightly varied drops and presenting the first one that gives the desired result?

[–] [email protected] 2 points 6 months ago (1 children)

In this mini game you have fine control of the plunger, so it's not just 7 bucket animations but also thousands of launch powers and ricochets you need to account for. I've played this game, you can reliably and finely adjust where the ball falls with the plunger, but the ricochets off the bumpers are so aggressive it's impossible to get a consistent result, plus there could be fuzzing on the plunger input.

[–] [email protected] 1 points 6 months ago

The fuzzing of the plunger input is what I was thinking about. You could run a bunch of simulations right as the plunger is released with slightly different inputs and then pick the one with the desired result to display on the screen. You'd need to have a pretty efficient simulation, but the user would be none-the-wiser.

[–] [email protected] 20 points 6 months ago (1 children)

In case of that particular game, it’s rigged to fuck. Anything that tries to get you to spend money is going to be. So I’d say a previously calculated result dictates the outcome.

[–] [email protected] 3 points 6 months ago

Yup. Both are possible, but if the game is addictive and you keep launching that exact same game among bazillions of other similar games, it’s 100% rigged towards manipulating your compulsive behavior.

[–] [email protected] 13 points 6 months ago* (last edited 6 months ago)

This question isn’t only for mobile game. I remember asking myself this very question with Super Mario Land on Game Boy when finishing a level and you had a chance to get 1up 2up 3up or a mushroom.

[–] [email protected] 11 points 6 months ago (1 children)

If the animations look realistic, it's almost certainly not predetermined. That's by far the simplest way to get the desired effect. However, that doesn't mean it's fair. It could easily use a real physics engine, but still subtly rig the system. For example, bounces off of the pins could have an elasticity factor of 0.4 for bounces towards the big prize, but 0.5 for bounces away from it. Or maybe the hitboxes on the center pins are just a little bit bigger. Stuff that will noticably affect the large-scale statistics, but that you're not gonna notice with your eyes.

[–] [email protected] 2 points 6 months ago

If the animations look realistic, it’s almost certainly not predetermined

You could do a perfectly realistic simulation, record the path for each outcome and then play one of them.

Or, if the physics simulation is deterministic, you could store a set of starting positions and their outcomes.

[–] [email protected] 9 points 6 months ago (2 children)

The cheapest way to do this is to let the animation (the physics simulation) determine the result.

Picking a bin for the ball to go into, then working backward from that to an animation that looks like it’s following the same physics at other animations, is far more computational work.

Therefore, my money is on the animation determines the result. Now, it may be pre-determined from parameters, but that doesn’t mean it’s predictable, due to a concept called “computational irreducibility”.

[–] [email protected] 2 points 6 months ago (1 children)

You could very easily just project the last bounce, and if it's going to go into the good spot, cheat and adjust the path, based on predetermined odds. It wouldn't be hard at all to turn a 1 in 7 chance if the physics would be uniformly distributed without cheating into 1 in 700.

[–] [email protected] 1 points 6 months ago

True. I think this happens with pinball recall for lumosity. The level you’re on isn’t correlated to the number of bumpers on the board, but to path length. I figure they just try paths until one’s sufficiently long to be a challenge to the player.

Unfortunately it has the opposite effect. I look at the board and my eyes instantly calculate all the paths and one’s the longest. No working memory required on my part. And that longest path is where the ball’s coming in 90% of the time. It sucks.

[–] [email protected] 2 points 6 months ago

I'll +1 this by also mentioning that physics, despite seeming fancy, is one of the easiest things to implement in most game engines because they all have built in physics systems at this point. That's why there are so many no budget games that rely on physics heavily.

Now getting physics to be really good and interesting is a whole 'nother can of worms...

[–] [email protected] 8 points 6 months ago* (last edited 6 months ago)

Just like every video game, your odds can be heavily rigged against you if the developer wants it.

Use this game as an example. No one's going to recognise if the developer does intentional weighting (guiding the ball towards smaller wins via additional small vectors other than bouncing)

On a carnival game, game host could use a weighted die to rig the odds towards it? On a video game, developer controls everything.

[–] [email protected] 8 points 6 months ago

It could actually depend,

You could derive the result from a pseudorandom value and then call an animation to reflect that result, or you could derive it from building the visual in a game engine and just letting it play same as it would if it was a physical version of the game.

If I had to guess I'd imagine a mobile game might lean towards the RNG option simply because I personally would estimate it would be less of a burden on the hardware, which for mobile gaming can be a big deal.

[–] [email protected] 7 points 6 months ago (1 children)

The easy way if doing this is just using a physics engine and calculate the result depending on where the ball lands. Prototyping a game like that would take me a few hours probably.

That being said if the game asks for money to do anything it's highly unlikely that that's what it's doing, instead it's probably choosing your result based on how much do they want you to win and then calculate a path for the ball that gets this result.

Something that makes it difficult to do this second alternative is if you have some semblance of control, e.g. if you choose the strength to use for the ball or something, that makes it slightly trickier to pull off because you're against the clock on finding a path and might end up with an unrealistic move (however if those round things make the ball kick around like they do on a pin all machine they can be used to set the course you want).

Long story short it's easier to do the animation deciding the result but if the game asks for money in exchange for anything in-game it's more profitable to do the results deciding the animation.

[–] [email protected] 1 points 6 months ago

I know this game, this is a mini game within the main game and I'm not actually sure how they make money since they have no ads and they shower you with so many power ups that I've never come close to running out. I guess lots of players are just bad at the game so they need to buy power ups? This particular mini game doesn't have any pay to win mechanics, you get balls by beating levels in the main game so it's just there to encourage reengagement.

It's a standard match 3 game but I play it as a fidget game since there are no ads and the levels are reasonably beatable with the tons of power ups they give you.

[–] [email protected] 6 points 6 months ago (2 children)

Physics engines are rarely deterministic, which means most of these games use what you would call the "animation deciding results"

It is very rare that it works the other way around contrary to what others have commented it is non trivial to make weighted deterministic random in this manner

While technically possible, only very specialised games with reasons good enough to budget the programming required will go the route you describe as "result calculated before the animation"

[–] [email protected] 9 points 6 months ago (2 children)

I just want to say, having worked in the lottery industry and having made one of the first predetermined pachinko games, it's actually fairly easy.

[–] Sethayy 3 points 6 months ago (2 children)

And with how cheap 2d simulations are (even cheaper on a gpu) they could pretty easily run a a couple hundred then pick their favorite odds, save the path trace as a bezier, ship those weights with the game and no one could tell the difference

[–] mindbleach 2 points 6 months ago

This 200-pixel-tall plunger could have every possible input scored, and it'd take approximately no time and no space. If it somehow has a full 16-bit range then the score table would only weigh 256 KB. (Assuming you can't score five billion on one ball.)

It would be nearly trivial to then nudge inputs onto lower- or higher-scoring values, nearby, at whatever rate maximizes player spending. Because that is the only metric these vampires care about.

This assumes they don't just rely on the placement of the pegs to work like they do in real life. You know. Like actual pachinko games. High-scoring targets are marked that way because fewer balls go there.

But here's what I think they actually do:

There might only be 30-odd real positions for the plunger. You can pull it as precisely as you like. It'll animate like that matters. But you're just picking a bucket, and in each bucket there's a range of launch speeds. The game's been trying random speeds behind-the-scenes. It knows how much each speed will score, when it picks it from that bucket.

That way they can place the pegs and bumpers wherever they damn well please, and the game can still hand you good scores and bad scores at its sole discretion.

[–] [email protected] 2 points 6 months ago

That's it in a nutshell.

I had to implement the system in a special way, but that's due to the nature of the lottery industry, auditability, security, etc being critical.

There was really two systems at play. One was a "entry code" that the player would acquire either by scratch ticket or other means which they would enter into the system. That would tie their entry to an outcome. The winning decision could have been predetermined at the time the codes/entries were generated, or there could be an instant probability-based determination on the server end.

At any rate, what would be presented to the user then is the ability to drop 10 little pucks anywhere they want, and watch them fall and bounce around, but regardless of where they dropped them, they were going to in the same bins either way. Then the prize would be revealed.

At the time there was no easy physics systems, so I had to code my own but it wasn't that hard. I just brute forced it to drop a million pucks overnight, going left to right in tiny sub pixel increments. Built a table of animation strings which provided a convincing animation for the puck to go into any bin, regardless of where the player dragged it in the interactive portion of the play.

In the end, even though it was an incredibly innovative lottery product at the time, the first of its kind actually, we could not deploy because every state/intl lotteries thought it was far too convincing that the player had influence on the outcome, even though it was fully disclosed no action that their actions had no bearing on the outcome.

[–] [email protected] 1 points 6 months ago

It may be considered easy, and for sure this one probably is, but it doesn't compare in complexity to normal physics engines. The whole thread read like it was, so I felt I should provide a better perspective on it.

[–] [email protected] 1 points 6 months ago* (last edited 6 months ago)

There are plenty of deterministic physics engines. In this case I don't think it would make sense to add extra complexity to rig the result, this mini game already has plenty of obstacles to make getting max points hard. What they might do is fuzz the plunger input randomly so you can't memorize the perfect location and get max points every time.

[–] [email protected] 4 points 6 months ago* (last edited 6 months ago)

I've played that mini game, definitely don't think it's rigged. I've gotten max points plenty of times, it's just hard since the 10 is in the middle and there are obstacles in the way. I would guess they fuzz the plunger so you can't memorize the perfect location for max points every time.