Hacker Newsnew | past | comments | ask | show | jobs | submit | igpay's commentslogin

Hey all, I'm the author of Probabilistic Tic-Tac-Toe. I'm currently working with Louis to integrate this solver into the game itself so that people can play against it. I'm hoping to have it released by EOD and will update this comment when it's ready.


I can't edit my original comment but I have updated the game with "Impossible" difficulty mode as implemented by Louis.

Based on a suggestion from a sister comment, I have also added a "Tutor" mode. When hovering over a square in tutor mode, it shows the probability of winning the game given that you a) select that square and b) continue to play optimally for the rest of the game. Both of these options are in the settings menu in the top right of the game.

Finally, I've added a little writeup to the bottom comparing the strengths of the two AI implementations. Enjoy!

https://www.csun.io/2024/06/08/probabilistic-tic-tac-toe.htm...


I posted in your original thread about making a physical version of the game with tiles and real dice. Did you experiment with using other "dice" than a 20-sided? It seems to me as if just a regular 6-sided die would be more than enough to provide a board where every tile is different (there are still way more than 9 different combinations of possible tiles) and I think that means there is just as much strategy as in the original game? It makes presenting percentages a bit ugly (the nice 5%-intervals obviously look better) so I would not recommend it for the digital game, but I think 6-sided dice could be used to make more readable physical tiles (printing the ranges for happy and sad, together with numbers of smileys equal to the number of positive and negative outcomes, to make tiles easily readable from all directions at a glance; I do not think there is a need to spell out the neutral outcomes).


The D20 was the first die shape I tried and I ended up just sticking with it. My reasoning was basically the same as yours - 5% intervals look better.

Agreed that 6 sided dice would not detract from the amount of strategy in the game. I think it could be cool to try a physical version of the game where you shuffle premade tiles and place them in the grid - maybe a fun game to teach kids probability :)


If using just 1d6 and also by including tiles that have zero neutral (i.e. no) outcomes, you get 15 possible tiles, which should be enough to build... very many different tic-tac-toe boards (I am too lazy to count, but combinations of 9 from 15 and then 9!=362880 different configurations of the tiles for each combination, although all mirrors and rotations should be excluded so in reality there are fewer than that, but still more than what you need for a (re-)playable game and probably never see a board you saw before).


I'm actually interested in being coached by the solver, so it can tell me when I made a suboptimal move and what the optimal move would have been.

Like in chess, playing against stockfish isn't very fun, but having it as a way to get better is fun.


Hey there, I thought this was a good idea so I added it to the game as "Tutor" mode. Thanks!


Thanks, this was very interesting. I was happy to see that my play was indeed near optimal.


Have you considered making probabilistic Chess or Go? One way to do it is before each move a coin is flipped to decide who’s turn it is.


Hmm, but party of the strategy of this one is that different cells have different odds, and you know those odds. It's not just a random 50% chance, that wouldn't be so interesting.

I could see probabilistic cheese working as each grid square having an odds that the move will "work." Those odds stay the same the whole game. If you try to move from that square, the odds dictate whether you do your move or just lose it and skip your turn.

This would mean that certain squares become very valuable. A queen on a 95% square is much more powerful than a queen on a 40% square. But those squares may not may not be in useful positions. And the battles may be over who gets to put good pieces on those squares.


An additional possible variation: The probability of a square could determine not just whether you can successfully move from it, but also whether you can successfully capture a piece on it. So, for instance, a queen on a 40% square is much less powerful offensively, but much more powerful defensively, because 60% of the time you can't capture it. You could "hide" powerful pieces on low-probability squares, and you'll have a hard time getting them back out but your opponent will have a hard time capturing them and might not try. (You could either have capture failure leave the piece that attempted capture on its original square, or have the piece that attempted capture get captured.)

Sticking your king on a 20% square would be a great way to probabilistically buy yourself time to bring other pieces to its defense, at the cost that the king can't easily try to escape.

That has a nice symmetry to it, where rather than making 95% always "good" and 40% always "bad", they're both valuable for different reasons.


Like chess on a Scrabble board


Yes, the AI mostly just looks for plays that have high certainty and are connected to other potential winning squares (for either team). Then it weights plays positively or negatively based on whether or not the "bad" chance outweighs "good"


I don’t think this is right though. I watched it pick a 70 it didn’t need over a 60 I used to win.


Yes, those should go straight to a "Tie" result.


I'm not 100% sure, but I think it didn't display the outcome of the dice in this case. And it would be nice to have some hint that shows that this game ends in a Tie.


Thanks! I've added a fast forward button to the top left so that you can play faster.


Agreed that 3D is overkill. I'm fastest at prototyping in Unity though and this was only a couple day project, so I'm unlikely to port it to anything else.

Probabilities are mostly randomized during board generation but skewed in a way to make gameplay feel a bit better. There's a cap on the likelihood of the neutral event, and a bias towards the good event rather than a bad one.


I got the die to settle on an edge in the corner of the playfield, which triggered a re-roll.

Is this actually simulating a d20 with physics?


Can you please share the specifics? I'm trying to make my own AI for this game, and would like to compare mine against random play to estimate its strength.

Also, in your listing of your ai beating the random, how are you counting drawn games?


The current code for board generation is as follows:

  var neutralChances = Random.Range(1, MaxNeutralChances + 1);
  square.GoodChances = Random.Range(MinGoodChances, 20 - neutralChances);
  square.BadChances = 20 - (square.GoodChances + neutralChances);
MaxNeutralChances and MinGoodChances are both set to 6 in the release build. Note that one chance is equal to one face of the die, so 5%. Also, this overload of Random.Range() has an inclusive min value but an exclusive max value.

I guess I didn't include ties in that little blurb I wrote up, but the real results of my 10k trials were around 5:1:11.5 (lose:tie:win) for the AI vs random actor.

Would love to see your AI when it's done! Please shoot me an email if you want. My email is in my profile / in the site footer.


Why an AI? Just for the fun of implementing it (totally valid, just curious)? Given the probabilities of the outcomes couldn't you just "solve" for the best way to play it based on expected value?

If there are 65% and 50% to complete a row in one direction, and a 35% and 20% in another direction, you don't really need AI to tell you which one would be more advantageous to go after?


Yes, I've made what is intended to be a perfect solver (Although it in some testing it's clearly making mistakes, so I have some debugging to do yet). I'm making it because I was nerd sniped into thinking through how to handle some of the trickiness with the solving. It's not an AI in the LLM or machine learning sense, but in the previously common use of the term (eg, deep blue), or in the video game sense.


Very cool! Best of luck working on it!


That's cool — use what you're comfortable with.

Myself, I am trying to create lightweight 3D code to sit on top of Canvas and HTML5. That may be why I was sensitive to the "overkill", ha ha.

https://github.com/EngineersNeedArt/Phosphor3D


That's good feedback, thanks. I've added a fast forward button to the top left.


You overdid it.

1x is right at first, but 2x is really fast.


3x is great


Thanks for that, I added a loading bar. It should be visible now if you refresh the page.


I love this website - such a great repository of knowledge that presumably would've been lost to time otherwise. Although I don't remember there being so many ads last time I visited the site.

His wife, Harriet Fell, was one of my Computer Science professors at Northeastern. I really regret that I never took the time to talk to her about Sheldon. It always crossed my mind but never seemed like the right time.


https://www.csun.io/

pretty random assortment side projects


Negatives are the same shape as their positive counterpart, but the inverse. So where there would normally be a shape for the number, there's instead a void or impression that wants to be filled.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: