Remix.run Logo
▲ Show HN: bouncemarket – a live prediction market game for a bouncing ball(bouncemarket.minhanhday.com)
287 points by mday404 6 hours ago | 87 comments

a ball will fall. trade on where it lands.

I made this game! Some technical details:

The entire drop of the ball is simulated server-side, then streamed to each client as server-sent events with a small buffer. Every drop is deterministic from its starting position, so rounds can be replayed exactly for later analysis, but tiny variations in starting position can change the ultimate outcome.

There's some AI traders to keep the market moving, but they drop out in any round that has more than five people. They operate using a naive set of rules that I wrote for them, so they're not too hard to beat -- it's when the market is full of real people that it gets tricky.

Curious to get feedback on anything you would change, and especially whether the mechanics were clear right away or not.

▲charlieyu1 5 hours ago | parent | next [-]

Fun little game, but the drop needs to be slower so it is easier to bet. Odds jumping from 0.01 to 0.99 in like one tenth of a second makes it hard to play

▲johnnyenn 5 hours ago | parent | next [-]

The drop is pre-simulated over SSE anyway, so adding a bit more delay between frames would fix this. Right now normal ping moves the odds before the click even hits the server.

▲catlifeonmars 3 hours ago | parent [-]

> The drop is pre-simulated over SSE anyway

Trying to understand this phrase but its meaning escapes me

▲chambored 3 hours ago | parent [-]

The server calculates the balls’ motions and uses Server Sent Events to stream the results to the browser.

▲catlifeonmars 3 hours ago | parent [-]

Ah so like a replay! Is SSE a specific term of art or does any event generated on a web server sent to a client count regardless of technology? At the risk of sounding sarcastic (I’m not), why did you capitalize S, S, and E?

▲jaapz 2 hours ago | parent | next [-]

SSE is Server Sent Events https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...

▲savef 2 hours ago | parent [-]

Jinx.

▲savef 2 hours ago | parent | prev [-]

It's a specific web tech: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...

But in colloquial usage I'd expect people probably do use that phrase referring to any system for events sent to clients by servers, such as long polling or websockets.

▲SV_BubbleTime an hour ago | parent [-]

> But in colloquial usage I'd expect people probably do use that phrase referring to any system for events sent to clients by servers, such as long polling or websockets.

I feel seen. I consider async web socket data to be SSE.

▲novia 4 hours ago | parent | prev [-]

this was because of a bot added to the game, it was easier

▲vova_hn2 5 hours ago | parent | prev | next [-]

Completely ignoring the ball and just buying cheap shares is a surprisingly efficient strategy. Often I'm able to get both kinds of share for cheap, so I win regardless of the outcome.

▲cvoss 5 hours ago | parent | next [-]

I would guess that the universe of players not being closed is a source of imbalance. There is a constant stream of new players who are granted 10 credits. Maybe they play for a bit and leave when they get disinterested, which is more likely than not going to occur when they have less than 10 credits.

So if the money supply per capita is constantly increasing, holding a share in anything with a 50% chance of payout has a positive expected return. Diversifying by buying both shares makes your portfolio very resistant to fluctuation. The ideal strategy just rides the inflation on average.

▲marcosdumay 3 hours ago | parent [-]

What you are describing is there, yes.

But the GP's experience is due to a lack of good players with time to plan their bets. This is a well known feature of derivatives markets...

▲novia 5 hours ago | parent | prev | next [-]

it was fun to buy low until someone added a bot to do that which makes the price instantly swing in the opposite direction by the time your click guess through

▲sebastos 4 hours ago | parent | next [-]

I was frustrated by the same until I realized that if it’s that predictable I should be able to take advantage of it. I started getting more success with a buy high strategy, which because of the bot ends up as a buy low strategy by the time your click registers. The bot moves the market so much and so consistently that it ends up just behaving as a phase shift.

▲catlifeonmars 3 hours ago | parent | prev [-]

I read this as “trading is easy until the quants get involved”. So basically just like a real market.

▲imeanwhatdoikno 5 hours ago | parent | prev | next [-]

Yeah feels like either the market is quite inefficient or there's a bug because just buying up sub-0.05 shares on both sides makes it too easy

P.S. still genius idea. Might need some refining

▲mday404 5 hours ago | parent [-]

Just checked my logs -- the market maker is actually up slightly (around 46 points). Lots of people are profiting, but it's balanced by losses from other players. Around ~400 points move around per round at the moment.

▲aniceperson 5 hours ago | parent | prev [-]

its is missing trading fees indeed.

▲geoffschmidt 33 minutes ago | parent | prev | next [-]

This is super cool! The rabbit hole goes a bit deeper than I first thought.

Because anyone can tell Opus "go win bouncemarket.minhanhday.com" and with just those words get a pretty good bot, this is in practice a "battle of the bots".

The only unknown is the fractional part of the start position of the ball, which is revealed gradually by the chaotic path of the ball, and a frontier model will quickly realize this and write an exact solver for it. This gives the optimal estimate at time t of the probability of each outcome given the information revealed so far.

Of the bots running now, some seem to have an exact solver while others have a lower quality probabilistic solver. Some bots seem to only bet when there is enough information to be certain, others are willing to bet early when the market is mispricing the risk.

The rate limit of 10 bets a second means that, past a certain point, a bigger bankroll doesn't help. It also means that bets are a scarce resource. You want to bet at the moments when the market maximally misprices the risk, but you don't know when those moments will be because that's a function of what other players do.

To win, you need to do some combination of:

1) Be the first to buy when a bounce reveals new information

2) Be the first to buy when another player makes a non-optimal buy

Both require low latency to the server to win. Only market orders are possible, so if you are not the first you might be severely punished, because if N bots all see an event at the same time, they will pile on (not seeing each other's buys due to the latency in market quotes) and move the market far past fair value, and the Nth bot may buy at a really bad (and unintended) price. Which could then produce a swing in the other direction, so I guess we should expect the market to oscillate. In practice these mispricings seem hard to exploit because they are large but short-lived and so difficult to harvest with market price orders.

Since you asked for feedback, my advice would be:

1) Allow orders other than market orders (eg, add a limit price to the API)

2) Consider running some kind of an auction (once per frame or other time interval) rather than processing orders one at a time

That would make it not be a winner-take-all game based on your distance from the server. On the other hand maybe in this case an orderly marketplace is uninteresting! In that case, if you do #1 but not #2 then you open up some new betting strategies, like trying to catch mispricings due to overcorrection.

▲akshayp29 an hour ago | parent | prev | next [-]

There's a lag! The odds seem to be updating quicker than the ball animation for me, which makes it really hard to trade...

▲mday404 an hour ago | parent [-]

I actually think the bots may have started trading on buffered frames...

Streaming directly from server to client leads to jitter due to inconsistent frame delivery times, so the client actually holds a few frames "in the future". Given that the price seems to be almost clairvoyant at times, I think the most likely explanation is that someone is reading the buffered frames before the client is supposed to be displaying them haha

▲whycombinetor an hour ago | parent [-]

It's deterministic physics. Knowing the ball's precise position and velocity at any 1 point in time should allow you to predict the end outcome. They don't give a formula for their physics engine, but it should be easily derivable from observing repeated runs.

▲mday404 an hour ago | parent [-]

that's true towards the end, but it's harder than it sounds because you don't actually have the precise position and velocity -- you just have the position rounded to the nearest 0.1px.

I ran the physics simulation and a 10^-12 px change in starting X position yields a different outcome more than 30% of the time, so knowing the ball's position to the nearest 0.1px only gives you a good guess, not an oracle

▲qoez 3 hours ago | parent | prev | next [-]

I wish people leaned into making prediction markets about pure random events like this. In theory they should be just as legal as sports betting in the sense of being considered "financial contracts", but no one has actually done the experiment (with real money not fake like here) as far as I'm aware.

▲lesam 3 hours ago | parent | next [-]

The CFTC disagrees (IANAL):

> Gaming contracts are likely to be contrary to the public interest, the CFTC indicates, if they involve games of random chance, as trading in such contracts would not provide useful or meaningful information.

https://www.congress.gov/crs-product/LSB11441

▲qoez 3 hours ago | parent [-]

Would be interesting to know/test where the line is. If a person gets to place the initial placement of the ball is that now slightly a game of skill? Maybe the 'chat' votes on it. There's already coin tosses in sports games sometimes (to determine who goes first and stuff like that) so some kind of mixing of pure randomness is allowed.

There's also already weather contracts that are allowed which are very 'random'/a very chaotic system very hard to fully predict. A coin toss is technically fully determined/not random if one knew all the atoms and their momentum etc.

▲pjc50 3 hours ago | parent | prev | next [-]

Am I the only one going "this is just gambling! No!" Here?

Used to be electro mechanical toy horse racing games for this purpose.

▲retsibsi 3 hours ago | parent [-]

> Am I the only one going "this is just gambling! No!" Here?

That was my first reaction too, but I think that was their point: prediction markets are already being used as a loophole to allow sports betting in jurisdictions where it is supposed to be banned, and (according to them; I haven't checked this) the legal theory that justifies that would also justify 'prediction markets' on random outcomes, i.e. really blatantly just pure gambling. So it could serve as a kind of reductio of the sports betting loophole.

▲whycombinetor 3 hours ago | parent | prev [-]

Casinos definitely exist, lmao.

▲qoez 3 hours ago | parent [-]

The point would kind of be to make fun in almost a performance art way of the "sports are financial contracts" idea. Though as someone else commented I'm incorrect about this specific ruling.

▲whycombinetor 2 hours ago | parent [-]

You can walk up to any craps or roulette table in a casino and participate in a legal prediction market for the random events happening on the table. That's not a performance art.

▲amenhotep 2 hours ago | parent [-]

Casinos aren't regulated by the CFTC, which is the whole point of the bit.

▲suzukivenom 6 hours ago | parent | prev | next [-]

bouncemarket: bought Right x52 at avg 0.19, landed Right, +42.21 in one round https://bouncemarket.minhanhday.com/r/FYv-qiLU

▲tantalor 6 hours ago | parent [-]

This guy bounces

▲xp84 5 hours ago | parent | prev | next [-]

It’s too hard to buy multiple shares. The price changes super fast so I’d like to have buy 5,10,100 shares buttons too. Or something like that.

Super fun though. Love the idea and the execution.

▲theophrastus 5 hours ago | parent | prev | next [-]

If it is an approximal simulation of Galton board[1] then wouldn't wagering on the side the ball starts on have a positive outcome over time?

[1] https://en.wikipedia.org/wiki/Galton_board

▲nayuki 4 hours ago | parent | next [-]

Also https://en.wikipedia.org/wiki/Pachinko

▲danielmarkbruce 5 hours ago | parent | prev [-]

Wagering has a pricing element.

▲Lightbody 3 hours ago | parent | prev | next [-]

Fun! Can you update it so double tapping the bet buttons doesn’t zoom in on mobile? Should be a one line CSS tweak.

▲mday404 3 hours ago | parent [-]

should be fixed now!

▲trwhite 4 hours ago | parent | prev | next [-]

The latency on the button press is much too slow to actually make a decision about the price. It feels pretty random as to what price you’re gonna get

▲Andr2Andr 3 hours ago | parent | prev | next [-]

Could be expanded with futures, indexes, hedge funds, shares etc. to teach the general public about the financial topics. A user is first prompted to play a few rounds, and then has the ability to invest, to buy some shares etc. I think it could become the go to page to understand the financial markets. Just my thoughts what to make of this in future

▲2bird3 3 hours ago | parent | prev | next [-]

Nice! Claude was able to recreate the simulation pretty quickly- it might be worth adding a little randomness to the bounces.

▲mday404 3 hours ago | parent [-]

I'm curious, were you able to actually trade on the simulation's results?

My assumption was that the data you get as a browser doesn't have sufficient resolution to reverse-engineer the simulation, since the simulation operates on full 64-bit floats and you only get 0.1px granularity in display, so you don't know where the ball "really" is to guess it super early.

▲e1ghtSpace an hour ago | parent [-]

I made a bot with claude. Yes it does get to 100% accuracy before the ball lands. However most of the time the entire market jumps to 0.99 at this point. However you can usually get in slightly earlier before that point or the market sometimes dips so you can get the shares cheaper.

Heres some results: calls 146/146 right · 146/181 rounds called · profit +98.80

Sometimes the bot can't calculate where the ball will land in time so those rounds are skipped.

Claude is now working on a new version to basically determine the seed for the random number generator used to set the ball's starting position. That way we can buy before anything even happens and get it right. However I'm not sure yet whether this is actually possible. I'll wait and see.

▲frenchmajesty 6 hours ago | parent | prev | next [-]

Surprising fun and awesome! Love it.

It was not immediately clear how the game was played but it came to me soon enough. I think one or two "trial/tutorial" rounds would go a long way to give me a proper shot at the leaderboard.

I wasted my first 2-3 balls as I was looking at the UI trying to understand how to play.

▲mday404 6 hours ago | parent [-]

Thanks for the feedback! I'll work on some kind of tutorial to start the game

▲theturtletalks 4 hours ago | parent | prev | next [-]

This is actually how the formula for options came about!

▲matthova 5 hours ago | parent | prev | next [-]

Love the concept. Great implementation

▲darepublic 3 hours ago | parent | prev | next [-]

I would prefer if it were a known 'fair' plinko machine that was being automated physically and you were live streaming that. It would make it a lot more interesting to me. That or a roulette wheel

▲joshribakoff 5 hours ago | parent | prev | next [-]

So fun, and easy to profit, at least for a few minutes. Seems like if you played this professionally 40hrs a week full-time it would get tiring fast. Maybe there is a metaphor in there.

▲hellojomp 4 hours ago | parent | prev | next [-]

I had a similar idea a few months ago https://hellojomp.com/mob-market/ but instead of a ball bouncing it was about the dynamics of webpage links turned into hawks and pigeons and random predictions regarding them i.e. will X spawn Y times in _ seconds.

▲imeanwhatdoikno 6 hours ago | parent | prev | next [-]

This is kind of genius

▲echoangle 5 hours ago | parent | prev | next [-]

Is there a way to sell shares before resolution?

▲mday404 4 hours ago | parent | next [-]

No, I thought about it but I wanted to keep the UI as simple as possible. Definitely would make the market more interesting in a future update!

▲gpm 5 hours ago | parent | prev [-]

Buying a share on the opposite side is effectively selling a share.

▲gpm 5 hours ago | parent | prev | next [-]

I'd like to see how much the market maker is making/losing.

▲dpmartinez 5 hours ago | parent | prev | next [-]

This looks fun, but I imagine someone somewhere in a financial exchange company looking at this and thinking:

"bouncing ball futures contracts, would be a thing to offer our sophisticated clients."

▲folli 5 hours ago | parent | prev | next [-]

"AI Traders" - "naive set of rules". Definitive proof that if..else is AI now.

Jokes aside, cool game. Introducing trading fees would be interesting to make it more realistic in terms of buying both sides.

▲furyofantares 4 hours ago | parent | prev | next [-]

Hilarious and fun. Btw if I tap furiously on a button the page zoomed in every time the button ends up disabled.

▲mday404 3 hours ago | parent [-]

should be fixed now!

▲elisgillberg 6 hours ago | parent | prev | next [-]

Hehe this is awesome!

▲jojogeo 6 hours ago | parent [-]

Agreed; throwing all my "free money" on one side, after guessing correctly several times in a row with small stakes had me literally shouting in excitement, just before losing it all :')

I can see why people throw money at gambling, if its easy enough to do.

▲deadbeefer 5 hours ago | parent [-]

Y'know, the more I think about it... a lot of the games that hook ya have this element of prediction. Even (especially?) stuff that's deterministic without true RNG. Even really fast-paced twitch games tend to push your reflexes to the point where you have to predict in advance. Sorta triggering that gambler's reflex. Pre-aiming hitscan weaps at corners and pre-firing projectiles where feet will land in many shooters feels like they trigger something similar.

▲bee_rider 3 hours ago | parent | next [-]

That’s an interesting thought.

Whether pre-aiming has a downside or not seems to depend on map design? Like if there are multiple plausible corners, you have to pick one, so there’s a cost of not picking the other. Other games have simpler maps, if there’s only one plausible corner I guess there isn’t much cost to aiming at it.

Of course, defining plausible corners relies on map knowledge. Actually I think that’s one of the reasons I quit playing online shooters didn’t want to put in the level of effort required to make those gambles fun. Random death is boring.

▲cogythea 3 hours ago | parent | prev [-]

Yep, having that "I can see where this is going" moment is what pulls you in, especially when you get it right. And then for gambling, it's when you start to think "I can see where this is going better than other people can", that's when you see real opportunity to win your fortune. For games like Poker, that's rare but entirely possible, but for games like OP's it's borderline impossible - but that doesn't stop the brain thinking it.

▲cush 4 hours ago | parent | prev | next [-]

Fun idea! The page shouldn’t zoom in when you tap rapidly - makes it impossible to play on iOS

▲mday404 3 hours ago | parent [-]

fixed!

▲jdorfman 4 hours ago | parent | prev | next [-]

That’s it I’m opening up a Kalshi account. Going to be rich.

▲dandaka 4 hours ago | parent | prev | next [-]

Please add keyboard controls

▲mday404 3 hours ago | parent [-]

added! Reload the page to see

▲ljubomirsinadin 34 minutes ago | parent | prev | next [-]

cool game for time wasting

▲JonnieCache 5 hours ago | parent | prev | next [-]

Do it with a camera and a real ball lol

▲rickcarlino 5 hours ago | parent | prev | next [-]

Finally a useful application for predictive markets.

▲franze 5 hours ago | parent | prev | next [-]

make it so that the important stuff is the height of the viewport above fold. i don't see the ball falling at the start

▲idiotsecant 2 hours ago | parent | prev | next [-]

This is pure dopamine, fantastic. Now the question is whether it will replace my urge to be wolf of wall street or whether it will enflame it.

▲ex-aws-dude 5 hours ago | parent | prev | next [-]

This is what I pretend my stock buying strategy is not underneath

▲eterm 5 hours ago | parent | prev | next [-]

It annoys me we can't put in limit orders, as with a touch screen the latency kills you as the price changes underneath you!

( Annoys is too strong a word, it's just a game! )

▲andai 5 hours ago | parent [-]

Sounds like you may be interested in my new real-time neural interface, ball2brain.

▲hei-lima 4 hours ago | parent | prev | next [-]

Really cool!

▲d--b 4 hours ago | parent | prev | next [-]

A prediction market should allow us to sell

▲iamgopal 5 hours ago | parent | prev | next [-]

are there keyboard short cut ?

▲mday404 3 hours ago | parent [-]

just added! left and right arrows

▲setnone 5 hours ago | parent | prev | next [-]

cool! up next: bouncemarketbot

▲mday404 4 hours ago | parent [-]

In hindsight I'm realizing I should have had a bot high scores and real player high scores since both require skill but in different ways

▲NooneAtAll5 5 hours ago | parent | prev [-]

another gambling website?