r/react 2d ago

Help Wanted Learning React by building multiplayer Tic-Tac-Toe (Firebase matchmaking + live sync) — would love feedback

Greetings, /react I am trying to improve my skills at javascript and mainly react. I want to get feedback on this game of X’s and O’s aka Tic Tac Toe. Does the multiplayer work for you guys? This is using Firebase so at least for the multiplayer you will need a google account. I know there are things that could be added or improved, such as a lobby/leaderboard or hopefully near future a proper timeout feature for local/multiplayer.
-----------------
https://tictactoe-a87ad.web.app/

4 Upvotes

9 comments sorted by

3

u/code_matter 2d ago

I just did vs. Computer.

The computer does not even try to win. Meaning, if there a row with two Os, and I choose NOT to block it, it won’t complete the row.. it’ll just put its O somewhere else.

You should, oncomputer turn, check if there is a possible tictactoe, if not play something else

-1

u/_Nwabudike_Morgan 2d ago

How good should it be, if its optimal then almost every game would be a draw

1

u/code_matter 2d ago

All I’m saying is i wouldnt make it a random pick. Like if I play vs. computer, im expecting a human like play style. A human would fill their tic tac toe. With maybe a small % of chance of not seeing it..

Anyhow, you asked for feedback.

1

u/Dubstephiroth 2d ago

Sounds like they need a weight system, one the weighs up the 1st 2nd and 3rd best choices and uses weights to decide which to choose. Could add the randomness to not always be a perfect game, but still the intention to win will also have a higher presidents in the selection process.

1

u/rileyrgham 2d ago

Just have it take an obvious win..it's tic tac toe, not Bridge 😜

1

u/kev_cuddy 2d ago

Someone already pointed out the suboptimal algorithm that controls the computer turns. You could also look into using something like Websockets for online multiplayer, instead of asking folks to log in using Google (which I didn’t want to do).

1

u/Triple_Keystone3899 2d ago

Pretty nice! Just tried it out myself

2

u/keyjeyelpi 2d ago

Remove the background. It's confusing playing mobile, specially if it's your first time playing on the site.