Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect stuck balls #480

Open
arthurkehrwald opened this issue Sep 8, 2024 · 3 comments
Open

Detect stuck balls #480

arthurkehrwald opened this issue Sep 8, 2024 · 3 comments

Comments

@arthurkehrwald
Copy link
Contributor

arthurkehrwald commented Sep 8, 2024

Problem

Inevitably, the ball will get stuck occasionally. Sometimes due to the physics engine, sometimes due to an oversight in the table design. It would be good to have some kind of reset mechanism when this happens. There are two problems here: Detecting when a ball gets stuck, and making it 'unstuck'.

Detection

The easiest solution I can think of would be to check whether the ball is moving around. The algorithm would go something like this:

  1. Record the ball's position x times per second
  2. Check if distance between the two furthest apart points recorded in the past y seconds exceeds threshold z
  3. Also check if the player is holding down a flipper button or, alternatively, if the ball is in contact with a flipper. This ensures the ball won't be reset when held by a flipper.
    The only problem I see with this is that it could still lead to false positives when table authors trap balls in the play field intentionally. Maybe we could allow author's to place triggers that suspend stuck detection for any balls inside.

Resolution

Teleport the ball back to the exit kicker and eject it into the plunger lane. Log a warning to communicate what just happened to the table author.

@freezy
Copy link
Owner

freezy commented Nov 16, 2024

Well, table nudge will eventually be implemented. Don't you think that'll be sufficient? For VPX, it seems to be the case anyway.

@bernarma
Copy link

bernarma commented Nov 28, 2024

I'll weigh in here with my own opinion. I would prefer to follow as close as possible to how real tables work - i.e. as @freezy suggested, nudging to dislodge the ball from wherever it got stuck.

If that fails implementing a "reposition ball function" to simulate how it is done in tournaments. The director is called over, the glass lifted, the ball is "located" and repositioned at their discretion to a specific location. This location would be defined during table design (so table designers would have to add support for this once the feature is implemented). This exists over and above existing ball search functionality.

I see this working as follows:

  • ball stuck on left of playfield (within bounds), reposition to lower left flipper (must be cradled up)
  • ball stuck on right of playfield (within bounds), reposition to lower right flipper (must be cradled up)
  • ball stuck in other location (i.e. it fell off the table or out of table boundaries), place into plunger lane

In a way, this feature could be turned on / off for all tables without any change to the actual table design other than a couple of typical set of coordinates to position the ball at various places and a standard way of handling balls (including active and not active).

Just my 2 cents worth.

@freezy
Copy link
Owner

freezy commented Nov 28, 2024

Sounds good - but the tricky part is still the detection. Rather than just looking at the flipper when the ball doesn't move, which doesn't cover all the other zillion use cases authors will come up with for blocking balls deliberately, I would instead go like this:

Given that no ball is moving:

  • Wait x seconds for ROM ball search, timer resets on key press
  • Wait y seconds for table nudge, resets on key press other than nudge
  • Wait another z seconds for ball movement
  • If still no ball movement, show a non-blocking notification to the player that by pressing <whatever key>, they can reposition the ball (like @bernarma described)
  • Keep the ball reposition function active for n seconds, or disable it after execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants