Top
Best
New

Posted by mday404 6 hours ago

Show HN: bouncemarket – a live prediction market game for a bouncing ball(bouncemarket.minhanhday.com)
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.

294 points | 89 comments
charlieyu1 5 hours ago|
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||
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||
> The drop is pre-simulated over SSE anyway

Trying to understand this phrase but its meaning escapes me

chambored 3 hours ago|||
The server calculates the balls’ motions and uses Server Sent Events to stream the results to the browser.
catlifeonmars 2 hours ago||
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|||
SSE is Server Sent Events https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...
savef 2 hours ago||
Jinx.
savef 2 hours ago|||
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 1 hour ago||
> 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.

johnnyenn 3 hours ago|||
[dead]
novia 4 hours ago||
this was because of a bot added to the game, it was easier
vova_hn2 5 hours ago||
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||
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||
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 4 hours ago|||
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|||
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|||
I read this as “trading is easy until the quants get involved”. So basically just like a real market.
imeanwhatdoikno 5 hours ago|||
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||
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|||
its is missing trading fees indeed.
StingyJelly 5 hours ago|||
[dead]
geoffschmidt 58 minutes ago||
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.

ml_comms_eng 7 minutes ago||
make a reliability diagram for the last N for (end_time-0.2s), (end_time-0.4s)... to see if bots are calibrated
akshayp29 1 hour ago||
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 1 hour ago|
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 1 hour ago||
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 1 hour ago||
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||
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||
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||
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|||
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||
> 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||
Casinos definitely exist, lmao.
qoez 3 hours ago||
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||
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||
Casinos aren't regulated by the CFTC, which is the whole point of the bit.
suzukivenom 6 hours ago||
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|
This guy bounces
xp84 5 hours ago||
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|
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||
Also https://en.wikipedia.org/wiki/Pachinko
danielmarkbruce 5 hours ago||
Wagering has a pricing element.
More comments...