Game of rock paper & scissor, multiplayer

It is also possible on two devices. You have to "connect" two phones with each other. This can be done in several ways. You can use an online database, eg CloudDB. You can also use bluetooth or wifi.

Person 1 takes an action on their phone and sees the result on their screen.

The action is uploaded to an online database eg Firebase.

Person 2’s phone queries the database and the action is taken on their phone and they see the result on their phone.

Eg in chess:

At the start of the game both players’ phones show the chessboard and pieces in their initial positions. Firebase is updated to reflect the position of every piece.

Player 1 moves a white pawn. They see its new position immediately. When they move the pawn Firebase is updated with that pawn’s new position.

Player 2’s phone queries Firebase and discovers the white pawn is in a new position. Player 2’s phone will move the pawn to the new position.

Then it’s Player 2’s turn to move a black piece and you basically do the same as above except it’s Player 2’s phone that will update Firebase, and Player 1’s phone will query Firebase and move the black piece to its new position.

1 Like

I started a sample RPS game on CloudDB, and ran into several complications over synchronization between players.

  • Should each player rely on the CoudDB DataChanged event to watch for opponent moves, or should he poll via a Clock Timer?
  • How to deal with clearing old moves from CloudDB, and separating them from the next round?
  • How old is old, in the previous point?
  • Who is responsible for clearing old moves from CloudDB, the person who made the move, or his opponent?
  • How do we insure we are scoring each move in each round exactly once?
  • The CloudDb block to add an item to a list is attractive for its ability to add items without overlap by opponents. However, cleanup of the list is tricky, possibly doable by including a timestamp in each move and a residency time limit for each move, say ten seconds.
  • The CloudDB remove item from list block, after depleting a list, leaves it as an empty dictionary, and not an empty list, as seen after retrieving the empty list.

(I am still debugging)

can u give me example of this also as u previous told !

After sleeping on the problem, I came up with further record keeping requirements in the shared data base for each game.

  • Each game round must have a deadline(ms) for accepting moves.
    • moves before the deadline are stored under the game round name by player name but are not available for inspection and scoring.
    • after the deadline has passed, the moves are available for scoring and inspection, but not for updating.
  • Each game should have a retention expiration date, for cleanup purposes. That can be implied from the move deadline plus some standard value, like a week.

I am new for coding can u please guide me for the preparing this app as per my requirnment, i tried but not got solution .I want by using two devices same game play by 2 users like ludo....

@priyankakonde, do you want it to be Online or via Bluetooth?

With CloudDB, one way is that One person could create a game and the second person can join it (like Among Us). We can track the moves of the player of a playing "pair", using unique tags.

Bluetooth will be easier for coding point-of-view (we don't have to track who has to play with whom)

according to u which one was an esy ? bluetooth was esy so iam ok with that !!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.