MatchMaking not working

I am currently making a tic tac toe game for my school project, and i am planning on adding a matchmaking system in order to allow 2 devices to play the same game. however, no matter how i tried to fix my
code, it just wont work. please i need help🙏 (ignore the other screens, i am trying to do them on my own thx)


tic_tak_toe_1.aia (6.0 MB)

Matchmaking over a shared data base is hard.

It raises a lot of questions:

How do you coordinate the match making?

How many players will be using the service at the same time?

How many games will a player be able to run at the same time, against how many opponents?

How will you know which player in which game is X, versus O?

What tags will be used for the various functions of matchmaking and playing the game(s)?

How will you tell the purposes of the tags when they arrive with a value in a CloudDB Event?

How will you handle some one who asks for a match but walks away before a match becomes available?

Regarding your code, look at the two different ways this code uses the global variables:

The CloudDb GotValue event needs an if/then test on the tag to see how it should treat what arrives.

This procedure is confusing to me.

Are global variables Player_O and Player_X names of players for a prospective match, since they are chosen from Players_list?

If so, what is the list kept in CloudDB1 under the tag for that player name?

Also, what is the point of keeping lists of which players are playing X and which playing O?
What if they are engaged in multiple matchers?

I have some ideas for you on what tag patterns to use in CloudDB, to keep things straight:

  • that long name for the list of names of people queued up waiting for matches (It returns a list, so the length of list block should tell you how many people are waiting after it arrives)

  • match names, in the form of Player1_vs_Player2, with value a list of the moves made so far in the match of Player1 vs Player2. So tag ABG_vs_poggers_real might contain the list 1,2,5,9 for the game where X (ABG) played square 1, O (poggers_real) played square 2, ABG played square 5,... (Assume Player1 will always be X)

  • player names, with lists of the games currently being played by that player, regardless of X or Y: ABG = tag, value = ["ABG_vs_poggers_real", "Karpov_vs_ABG", "ABG_vs_ABG1",...]

So when CloudDb returns a single value, you would check the tag first to see which pattern it matches:

  • that long fixed text (for the waiting for match player name list)
  • a match, because it contains a "_vs_" you can use in a text split block to get the player names,
  • an exact match against the current player name from TinyDB.

Further thoughts on managing that list of player names awaiting a match ...

That list does not need to grow to more than one item, since a player looking for a match either finds it empty, or with a player name at item 1 he can use as his opponent in setting up a match.

So the rule would be to look first, and add to the list only if it is empty.

Here is an example for match up with others, almost same idea as @ABG
match_up_with_clouddb.aia (9.7 KB)

known issue:

  1. if you are waiting for match but quit your app,you still in the waiting line.
  2. suitable for 2 user match up only.