A same-word game that runs in the browser: state, scoring, and the tie problem
Two players join a room, get the seed word "moon", and type a word each in secret. If both write "night", they score. If one writes "night" and the other writes "star", the round ends with nothing, even though both answe
Two players join a room, get the seed word "moon", and type a word each in secret. If both write "night", they score. If one writes "night" and the other writes "star", the round ends with nothing, even though both answers are perfectly good associations.
That gap is the whole game. I built SameWord, a word-association game for two to four players that runs in a browser tab with no account and no install. The interesting part was never comparing two strings. It was deciding what a round is, how a round is won, and what happens when the room does not agree.
Here are the three parts that took the most thought.
A round has one state, and everyone shares it
A game is five rounds. Each round has the same shape: the server picks a seed word, every player submits exactly one word, then everything is revealed at once.
The reveal is the only moment anything is shared. Before that, the room shows a counter like "2 of 3" and nothing else. Nobody can see which words are in, so nobody can copy an answer. When the last player submits, or the clock hits zero, the words appear together with the name attached to each.
Two timers have to agree for that to work: the round clock (30 or 60 seconds, chosen when the room is created) and the reveal. The round clock is the authoritative one. If it hits zero with someone still typing, the round is scored on the words that arrived; an empty slot is skipped rather than filled with a placeholder. That rule matters in practice, because a four-player room with a 60-second clock will almost never have everyone submit early.
The host presses Start on each round, which creates an obvious failure mode: a distracted host freezes the room. The reveal advances on its own 20 seconds after it appears, so the game keeps moving even if nobody clicks.
Two ways to win, and no partial credit
A round scores when one of two things is true.
A match: every submitted word is the same word. The comparison trims spaces and ignores capital letters, so "MOON" and " moon " are the same. Plurals are not. "rabbit" and "rabbits" are different answers, and so are "ocean" and "sea", because the game cannot score a synonym as a match on its own.
The second path is the same-meaning confirm. The words differ, but every online player taps a button saying they treat the words as one answer. Then the round counts.
That button exists because word matching fails exactly where language is interesting. Plural forms, synonyms, and typos are all things a room can agree on and a string comparison cannot. But a confirm that any one player could trigger would be a free point, so it needs unanimity.
There is no partial credit. A round is a win or it is not, and the result screen counts wins out of five. Players who want a finer signal have asked for per-round closeness scores; I left them out because "you were sort of close" turns a five-round game into a spreadsheet.
The tie problem is the default, not the edge case
The seed for round two comes from round one. After a win, the next seed is the word the room agreed on. After a no-match round, the next seed is the word that appeared most often.
That rule has a hole, and the hole is the normal path whenever two people play.
In a two-player room with no match, the two words appear once each. The frequency is 1 to 1 every single time, so "most frequent" never picks a winner. Three players can produce a three-way tie; four players tie two and two quite often. A tie-breaker is not a rare branch in this game, it is the road most rounds take.
The rule I settled on: when words are tied on frequency, the word that was submitted first becomes the seed. It is deterministic, it needs no extra round, and every client can compute it from the same reveal data.
The cost is real. Submission order is a function of typing speed and network latency, so in a two-player game the next seed is often decided by who was faster rather than by anything about the words. A player who types immediately after the seed appears gets to steer the following round. I considered three alternatives. A random pick from the tied words is fairer but makes the game feel arbitrary. Replaying the round punishes everyone for a tie. Carrying the previous seed forward breaks the chain that gives round two its context.
None of those were clearly better, so the fast-finger rule stays. If I were starting over, I would show the tie resolution on screen instead of resolving it silently. Players already suspect the seed is not random; telling them the rule is cheaper than letting them guess.
Unanimity breaks before anything else does
The same-meaning confirm asks every online player. With two people that is two taps and a small cost. With four it is the most fragile part of the game, because one player who does not tap turns a round everyone else agreed on into a no-match.
"Online player" is doing quiet work in that sentence. Someone who closed the tab cannot confirm, so they cannot block a round either. Someone who is still connected but walking away can. The rules put no timer on the confirm, so a four-player room can stall on a decision that three people already made.
I have not solved that one. A majority rule would make the four-player mode feel fairer, but it would also let two players outvote the third, and the entire game is built on the idea that the room is the unit, not the individual.
What a browser-only room actually costs
No accounts means the room code is the only shared object: six characters generated when the room is created, copied into whatever chat the group already uses. There is nothing to install and nothing to sign up for, and the host's player list is the only social proof that anyone is there.
The constraint shows up in small places. Words are capped at 24 characters and limited to letters, spaces, hyphens and apostrophes, which keeps the comparison simple and stops the input from becoming a message box. The one-phone mode exists for the same reason: two people, one device, hand it over between turns, words stay hidden until the reveal.
None of this is exotic. A five-round game with a room code and a countdown is about as small as a multiplayer browser game gets. The state machine, the unanimity rule, and the tie-breaker are where the game actually lives, and all three are decisions about what the room is allowed to disagree on.
SameWord is free at playsameword.com, and the rules are written up at playsameword.com/how-to-play.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.