Zakeru's Recent Forum Activity

  • [quote:2z500p6m]Try to set the "Send message" Peer ID to Multiplayer.PeerIDAt(Multiplayer.PeerCount-1).

    (I'll explain that if it actually works)

    It does work . So what is the difference between "Multiplayer.PeerIDAt(Multiplayer.PeerCount-1)" and "Multiplayer.FromID" ?

  • [quote:tpjbgdmw]I would just have the host broadcast one single message that will start a timer for the peers.

    But when would I send this message ? If someone joins after the message was sent, this peer won't have a timer. And for the scoring system I will need to be sure everyone send their answers upon host's signal (on the precise tick when timer reaches 0). Well anyway, this part is working for now. So that's not the most important.

    [quote:tpjbgdmw]try to test whether messages are actually received with a simple debugging text object before changing the actions/methods.

    I tried to do that after including "int(value)", but it stills doesn't work for the group value. The peer never gets their message upon connection, so there must be a problem on host side.

    Another try with the .capx: https://www. dropbox.com/s/palq7rp46p2k687/ChatProject.capx?dl=0

  • Thank you again for your answer.

    [quote:3mbk4f6l]Also, why don't you just broadcast the variable directly?

    Why does it have to be in the dictionary first?

    It was just an alternative solution I wanted to try because I already tried and failed with sending the variable directly. I also already tried with "int(variable)" but the peers always get 0 (the same problem happened in the thread I sent on my previous message). I will try with "str(variable)" this time, hopefully that will work.

    The "timer" is here so that everybody as X seconds to answer (probably 90 seconds for each creature). I want players to be synchronized on that and the timer to be displayed for them. The first round will be empty of creature, just so players have time to connect and synch with host and exchange a few messages with other players in their group. Then, every 90 seconds the content of "AnswerText" is sent to host and then comes the scoring system (not yet implemented).

    Concerning the dictionnaries, thank you for this simple example, this is what I thought but I wasn't sure. I did not have time to test a lot of stuff and everything failed so far, so I supposed I was doing something wrong.

    And here is the latest .capx : https://www. dropbox.com/s/i9d67roqu2jtql6/ChatProject.capx?dl=0

    On the debug, I can see the "Spawn" variable changine exactly as I want to, so I don't think that is the problem. But I may be wrong ^^

    Edit randomly : YEEAAAAAAHHHH !!! The str(variable) worked ! I can't believe I spent so much time on such a trivial thing ! But I guess that is what we call "learning" lol. Thank you ! Next : the scoring system. I will try something and send a new .capx.

    • Arf, actually it doesn't work with the "Group" value. I think I am doing something wrong with the "send message" action. I tried :

    For host : On peer connected >> send message, ID : Multiplayer.FromID, tag : "Group", message "str(GroupGenerator.Next)

    For peer : On peer message, tag "Group", set "Group" to "Multiplayer.Message"

    And since that did not work, I tried to first save "Multiplayer.FromID" in a global variable or in a dictionary and sending to that value instead, but it doesn't work either.

    "Timer" works fine because I use the "broadcast message" action instead of "send message".

  • Hey ! No problem, it's very cool that you keep answering and helping me <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    So, concerning the synchronization of global values, this is pretty much the same idea I had (found in this thread : https://www. scirra.com/forum/how-do-i-sync-global-variables-over-multiplayer_t101878). The problem is that the peer always gets a NaN value for the timer. Apparently, there is a problem with sending a variable as a message. The guy in the thread had the same problem and found an alternative solution which is not clearly explained, so I am stuck here.

    I will try the other stuff too and come back. (Just mentioning "randomly" in my edit will give you a notification ?)

    Edit randomly : Concerning the use of families. I looked at your .capx and I understand quite clearly how this work, but still, I can't think of a way to spawn my creatures according to my "Spawn" variable. As you can see in my .capx, I already have a "Creatures" family with all the sprites in it, and I have several events using this like : on start of layout > delete "Creatures" (and that's convenient). I also have the "index" instance variable set accordingly for each sprite, as you explained me. But I don't know how to say to the game "you have to spawn the creature who's "Index" value is egal to the current "Spawn" value". I tried your idea of "picking "Creature" by evaluating "Index = Spawn" but that did not work. That's the only detail that I am stuck with.

    • Concerning the smart random "next" expression. After some testing, it appears to be more simple than what you explained. "Start" expression always give you the lowest possible value in the range (useless in my case), but "next" actually starts from the first value of the sequence. Proof is in this .capx : https://www. dropbox.com/s/5l7ztd8kndlsov8/Next.expression-test.capx?dl=0

    Notice that the two first value you get are always different, which proves they belong to the same loop, thus the first time you click on "next" you really get the first value in the sequence. If you started at the second value, skipping the first one, then you would start at the edge of a loop and have a 50% chance that the first value of the next loop is the same.

    Illustration : with a sequence like 2-1 / 1-2 / 1-2 / 2-1 / ...

    The two first value you get using only "next" is this : 2-1 / 1-2 / 1-2 / 2-1 / ...

    And never : 2-1 / 1-2 / 1-2 / 2-1 / ...

    Which is what I want anyway. So that's cool. Now I have to think of the way to always send the "next" value to every peer upon connection. Of course, I tried "upon peer connected" > send message, tag "Group", message "Groupgenerator.Next". But that wouldn't work since "Groupgenerator.Next" is a number and not a string (damn, that limitation is troublesome).

    Here is another idea I just tried, but it failed (too bad! I was confident this time ah ah) : I created a "GlobalValues" dictionnary. The host task is to add a "Timer" key every second with the value "Timer" (global variable's current value), and add a key "Group" on peer connected, with the value "GroupGenerator.Next". Then, broadcast a message every second, tag "Timer", message "GlobalValues.Get(Timer)" and send a message on peer connected, ID "Multiplayer.FromID", tag "Group", message "GlobalValues.Get(Group)". For the peers : on peer message, tag "Timer"/"Group", set "Timer/Group" (Global variable) to "Multiplayer.message".

    And of course, it doesn't work for both : "Timer" gets a NaN value and "Group" doesn't change at all.

    • Concerning dictionnaries, I think I have a hard time understanding how the informations can be transmitted from host to peer. It seems the "AsJSON" expression is the key, but I don't really get it. For example, I suppose I could send the "GlobalVariables" Dictionnary as JSON and make the peer load it somehow and then set their global values accordingly. But I have troubles with this whole "host transforms into JSON > send to peers > Peers transform back to dictionnary objet" process. I think I would need a concrete example on that one.
  • Hey ! Sorry for the double post, but I have done a lot of changes to the game so I wanted to post the new .capx : https://www. dropbox.com/s/tqpq5zedfi9iw1f/ChatProject.capx?dl=0

    Thanks to your explanations and some testing, this whole multiplayer thing is getting quite clear. I now have a license and two computers connected in LAN to do some testing.

    There are two points with which I am struggling :

    • I can't find a way to synchronize the "timer" global value. Everybody should have the host "timer", but I see no way to broadcast a number value.
    • I can't find a way to send to each peer, upon connection, the next value in the smart random to set there "Group" value.

    And a less important one :

    • Is there a way to simplify the list of 30 events for spawning creatures using family ?

    I feel like dictionnaries and arrays will come in handy here, but I am not yet familiar with those. Anyway, next step will be implementing the scoring system, so I will have to learn about it quite soon.

  • [quote:2vr3wg1l]In case one player disconnects, he simply has to login again with the same alias. The host will then assign the player the group number that is stored under his name in the dictionary.

    Well, actually I don't want them to have an alias since I don't want them to recognize each other in the actual room and try to communicate not using the chat. I deleted that option and made everybody's alias "player" so they will just be called "playerX". But actually, if anybody gets disconnected, then that player just has to connect back several times until he falls back in the right group (they will be informed of which group they are in). With the smart random set like this, it will take at most 3 tries to get back to the right group, so it's not a major problem.

    Concerning the multiplayer, I think some things are a little more clear now, I will try a few things and send another capx soon so you can give me your opinion about it (well, if you want, of course).

    Edit : - Just a naive question on the way smart random works. I see no way to ask for the "first" value in the meaning of "the first of the randomly generated string of value" but only in the meaning "lowest possible value (the opposite of end value)". So I suppose asking for the "next" value for the first time will actually give the first value in the string (and then the second for second time you ask for the "next" and so on). I don't know if I am being clear, but basically, I just want to be sure not to skip the first value everytime I use smart random just because I overlooked something.

    • I know I haven't put every creature sprites in a family yet, but for now I put another smart random on the "spawn" value. So it changes from 1 to 30 (using all values only once before going to game over) as I wanted, but I still have no idea why my ugly big black numbers that I use as sprite for now dont want to appear. Any idea ?

    I simply wanted to create something similar to what is shown here, but I can't figure out what I'm doing wrong : https://www. scirra.com/forum/create-random-object-every-x-seconds_t63037

    ==> Problem solved. I did a long list of 30 conditions to create the 30 sprite at the same time XD. I actually had to just separate them in different events. Yeaaaaah one fewer problem!

    • Actually I have trouble now I am using families (I could get the license, yay !) :

    [quote:2vr3wg1l]Try this:

    Add a family containing all the sprites, e.g."Sprites"

    Add a family instance variable, e.g. "index"

    Edit that variable for every Sprite and set it to the Sprite's number (don't set it in the event sheet, set it in the object properties)

    Delete that long chain of conditions you referred to (Spawn=X, Spawn=Y,...) and replace it by this:

    Image

    ____________________________________________________________

    This does not seem to work, or maybe I am doing something wrong...

  • Ah ah thanks. It's actually combining several of your ideas that made me think about it.

    I see one problem with using that solution though : in case anybody is disconnected and has to connect back, he will get a new number. So a single disconnection would ruin an entire gaming session. Well, disconnections are a problem anyway, it would be better if that does not happen. But that is something I should think about maybe (but later ).

    Concerning the multiplayer, I read that tutorial, but it is still unclear to me how events work in multiplayer. What is hard to understand, in particular, is what is common to all players and what is specific to each. For example, when you have a global variable, it's neither in the host or peer related event so it applies to both, but when you put an event to change that variable, each player can get a specific value (like in our example above). Another example, when I create an object such as a dictionnary on any layout, how does this work in a multiplayer ? Does every player gets its own dictionnary or do they all write in the same one ?

    And when you say to give that task to the host, do you mean the host is the one generating the smart random and then send their numbers to each peer ? Or even the peer has access to the smart random once it is create and so the host just has to create it ?

  • Well it is still very confusing to me how this whole multiplayer thing work, so maybe my explanations are not good. But let's suppose I don't actually put a limit to the number of member in a group. So nobody check for that (neither host nor peer nor the system or whatever).

    Instead, the group value is just given to every player by one and only infinite string of "1-2-3" loops (in random order) generated by the smart random. Upon connexion, every player gets the next value in the smart random list. Of course, this would work only if it is possible to use the same string of "1-2-3" to set the group value of every player. If this is possible, then, everytime the total number of player is a multiple of 3, I would automatically get a balanced distribution of player. The advantage is that I would not need to make any modification if I want to have bigger groups, just keeping sure the total number of player is a multiple of 3 would guarantee that the groups are balanced.

    I don't know if this is more clear...

  • [quote:2a1zbnt8]Since there is a player limit for each room, you need to take into consideration whether the room is already full or not.

    But with a threshold of 0 in the smart random, I would always get a balanced distribution. So even if I do not check if the group is full, the balance would still be maintained. For example, if the smart random generates something like this : 1-3-2 / 2-1-3 / 3-1-2 / 3-1-2 / 3-2-1 / 2-3-1 / 1-3-2 / 1-2-3 / 1-3-2 / ... (where "/" represents the end of a loop)

    As long as I have a number of player that is a multiple of 3, I would always get the exact same number of players in each group, right ? I am sorry to insist, I just want to be sure I understood what is wrong with this solution.

    [quote:2a1zbnt8]Did you try what I wrote on my first post? This would make it more compact and easier to handle.

    I wanted to try it, but I am using the free version for now, so I can't use "families" right now. I will have to keep that for later (I mentioned it in one of my edits above, but since it's a mess, you may have missed it XD)

    Edit : By the way, I will go for a non separated host for now and think about an alternative if the game is really running too slow. Because that is one fewer computer to put in a room, and that is a non negligible advantage

    Once again, thank you very much for your help (you definitely earned a special place in my thesis' acknowledgments section ha ha).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So your advices made me think about something : let's consider that everybody is on the same room, but the host acts as a filter for messages and thus creates the "groups" of players.

    All I need is a global variable "group" for each player that is set on connection by smart random (start 1, end 3, threshold 0). Doing this would guarantee the balance between groups right ?

    This solution, if it works, would be good for several reasons. I actually need to create several versions of the game with slightly different parameters. Sometimes, I would need more than 3 groups (so I would need to change only the "end" value of the smart random). Sometimes, I would like to have just 1 player being able to see messages from 2 or more groups (so I would just need to add "& X & Y" to his "group" value).

    What do you think about it ? I haven't tried it yet, I'm actually thinking about how to do it properly.

    Also, when you say it will be hard for the host CPU, do you think that would actually take a lot of time to deal with all the comparisons ? More than 30 seconds ? Several minutes ? Of course it depends on the computer, but it's just to get an idea of how long it would take.

    Do you think it is best if the host is not a player and I just use my best computer only to deal with the host's tasks ?

    Edit : Ok, I tried something but I don't know if that would work. So, upon joining the room, each player get a random group value (smart random, 1, 3, threshold 0)

    When you are a peer, you send message with a tag corresponding to your group value. And even if you get messages from everyone, you display only those that has a tag corresponding to your group value.

    When you are the host, you also send message with a tag corresponding to your group value and you broadcast every message you get. However, you only display those who have a tag corresponding to your group value.

    I updated the capx. file, I edited the yellow information texts in event sheets to explain what I intended to do. Do you think that would work ?

    dropbox.com/s/247hslkh28garey/ChatProject.capx?dl=0

  • Wow, what a long and detailed answer. Thank you very much for your help, I will try everything you suggested !

    Also, I realized the login/login events layouts does not appear when you open the .capx, maybe that is why you couldn't see what I did to send players to different rooms.

    Edits :

    • I can't use families right now because I am using the free version, but I should be able to buy a license soon, so I will keep that for later.
    • By the way, concerning the CPU power. I'm planning to have everybody playing in the same place, so I guess I could use a LAN and that would help a lot, right ?
    • The changes I made to login/login events layouts have not been save apparently, my bad.
  • Hello again everybody,

    I am sorry for the double post, but I wanted to narrow down my questions and share my capx for people who think they can help me.

    So the link is here : dropbox.com/s/vzce7mxqet4o12d/ChatProject.capx?dl=0 (I don't know if I am doing this right)

    As you can see, the game is not very sophisticated. Actually, I don't have the sprites I want to use in the end, so I just use random pictures for now. I have 3 major problems so far:

    • I found a way to lead players to different chatrooms, but I am not satisfied since I have no way to keep balance between the different rooms. For exemple, I know I will be working with exactly 18 players, so I want to have exactly 6 in each room, but it has to be random.
    • I want the "creatures" (presently represented with big numbers from 1 to 30) to appear in a random order and appear only once. A new one should appear every time the timer reaches 0. Here, I can't even make them appear at all and I don't understand why.
    • I still have no idea at all for how to compare what players wrote in the "answer" textbox and give them point for every other player that gave the same answer. Also it would be cool if I could save what is written so it could appear on the "previous creatures" page later.

    Once again, I don't want you to do it for me, but just to tell me if you think this seems possible and what tutorial I should read. Thank you in advance for your help.

Zakeru's avatar

Zakeru

Member since 5 Dec, 2016

None one is following Zakeru yet!

Trophy Case

  • 7-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

9/44
How to earn trophies