I'm new and I'm creating a simple game with words - quiz. Two users will compete guess the hidden word and allow fewer mistakes. At the initial stage, there is a problem that the game have not an even number of users, for example - 5. It is formed 2 pairs players and one user will not be able to play and can wait for your pair for a long time.
How to avoid it? Is it possible to create server-side bots? Is there a code examples of this?
Best Answer
C
Customer Support
said
about 8 years ago
Hi Astraport,
Server side bots are certainly doable on the platform, in fact we'd recommend you code them in Cloud Code so that any tweaks that need to be made can happen without you having to re-upload your game to apple or google etc.
Unfortunately though there is no one solution which works for all. To get you started though, I've come up with a few ideas.
Seeing as the challenges require actual accounts to run properly, I'd create an account for only the bot to use. This account can partake in as many challenges as required at the same time so I wouldn't worry about needing more than one. The trick is that you need to know when to match a player with the bot account, if you can't form a pair for example with the challenge set to "PUBLIC" you could use SendRequestAs call JoinChallengeRequest and supply the bot account's id. This will send the request on the bot's behalf and that account will now be a part of the challenge.
Once all players have been matched you can use StartChallenge to force the challenge into a playable state. The tricky part is the "AI" which will govern the bot. While cant I really help you on this part (not my area of expertise) I can tell you where it would be implemented and roughly how to go about accomplishing it.
So when you want a player to take a turn, you use LogChallengeEvent and a custom event you have defined in the Configurator. This is where you usually store what values/score/times a player has achieved to the scriptData of the challengeInstance and execute the logic to govern who has won. This is also the ideal place to store and execute the logic which governs the bot.
You would check if the player who is logging the event is the player who has been matched with the bot, then store said player's scores/words/times, then before calculating who won that round run a separate function to take the bot's turn(calculating what word they would choose etc), again, using SendRequestAs to LogChallengeEvent to store the bot's choice to the challengeInstances scriptData and also taking it's turn and calculating who wins.
Hopefully that sheds some light on this complex question,
Can you present more on your structure once? You are doing this by challenges and cloud code or just events and cloud code?
A
Astraport Alen
said
about 8 years ago
I still did nothing. Only plan project architecture. And therefore asked.
Customer Support
said
about 8 years ago
Answer
Hi Astraport,
Server side bots are certainly doable on the platform, in fact we'd recommend you code them in Cloud Code so that any tweaks that need to be made can happen without you having to re-upload your game to apple or google etc.
Unfortunately though there is no one solution which works for all. To get you started though, I've come up with a few ideas.
Seeing as the challenges require actual accounts to run properly, I'd create an account for only the bot to use. This account can partake in as many challenges as required at the same time so I wouldn't worry about needing more than one. The trick is that you need to know when to match a player with the bot account, if you can't form a pair for example with the challenge set to "PUBLIC" you could use SendRequestAs call JoinChallengeRequest and supply the bot account's id. This will send the request on the bot's behalf and that account will now be a part of the challenge.
Once all players have been matched you can use StartChallenge to force the challenge into a playable state. The tricky part is the "AI" which will govern the bot. While cant I really help you on this part (not my area of expertise) I can tell you where it would be implemented and roughly how to go about accomplishing it.
So when you want a player to take a turn, you use LogChallengeEvent and a custom event you have defined in the Configurator. This is where you usually store what values/score/times a player has achieved to the scriptData of the challengeInstance and execute the logic to govern who has won. This is also the ideal place to store and execute the logic which governs the bot.
You would check if the player who is logging the event is the player who has been matched with the bot, then store said player's scores/words/times, then before calculating who won that round run a separate function to take the bot's turn(calculating what word they would choose etc), again, using SendRequestAs to LogChallengeEvent to store the bot's choice to the challengeInstances scriptData and also taking it's turn and calculating who wins.
Hopefully that sheds some light on this complex question,
Shane
A
Astraport Alen
said
about 8 years ago
Hi Shane!
Thank you for your ideas. I will think.
A
Ayyappa R
said
about 8 years ago
Adding to that, Another possibility can be
Create a Module in cloud code and name it TakeAITurn. Here is the place where your AI code resides.
When ever you get a request for the turn of AI to play, Call this module from the other response of LogChallengeEvent cloud code to trigger the next action of the AI bot.
I'm not sure on syntax about how to call modules from other cloud script at the moment but this direction should help to decide about the possibilities.
A
Ayyappa R
said
about 8 years ago
I was trying for system where if any matching fails, it will create a bot and continue the random match. I want the bot to be unique lets say with diff name and pic every time user creates a random match.
If we create multiple bots accounts on server side, are they considered in calculating MAU per month?
Mainly is the MAU calculated based on user registrations in GameSparks?
Thanks,
Ayyappa.
Customer Support
said
about 8 years ago
Hi Ayyappa,
You could use a single GameSparks account for your bot.
You could then check if the player has been matched with the botAccount and set it's name randomly in the challenge scriptData. This way the bot's name stays the same for the challenge and looks like many different users across multiple challenges.
No need to rack up an inaccurate an MAU calculation.
Thanks
Oisin.
A
Ayyappa R
said
about 8 years ago
Thanks for the idea Oisin. I guess this works.
I was in the thought of not having custom script data to sync with existing implementation. However, i can do this simple trick to work with single bot name.
Astraport Alen
Hi everyone!
I'm new and I'm creating a simple game with words - quiz. Two users will compete guess the hidden word and allow fewer mistakes. At the initial stage, there is a problem that the game have not an even number of users, for example - 5. It is formed 2 pairs players and one user will not be able to play and can wait for your pair for a long time.
How to avoid it? Is it possible to create server-side bots? Is there a code examples of this?
Hi Astraport,
Server side bots are certainly doable on the platform, in fact we'd recommend you code them in Cloud Code so that any tweaks that need to be made can happen without you having to re-upload your game to apple or google etc.
Unfortunately though there is no one solution which works for all. To get you started though, I've come up with a few ideas.
Seeing as the challenges require actual accounts to run properly, I'd create an account for only the bot to use. This account can partake in as many challenges as required at the same time so I wouldn't worry about needing more than one. The trick is that you need to know when to match a player with the bot account, if you can't form a pair for example with the challenge set to "PUBLIC" you could use SendRequestAs call JoinChallengeRequest and supply the bot account's id. This will send the request on the bot's behalf and that account will now be a part of the challenge.
Once all players have been matched you can use StartChallenge to force the challenge into a playable state. The tricky part is the "AI" which will govern the bot. While cant I really help you on this part (not my area of expertise) I can tell you where it would be implemented and roughly how to go about accomplishing it.
So when you want a player to take a turn, you use LogChallengeEvent and a custom event you have defined in the Configurator. This is where you usually store what values/score/times a player has achieved to the scriptData of the challengeInstance and execute the logic to govern who has won. This is also the ideal place to store and execute the logic which governs the bot.
You would check if the player who is logging the event is the player who has been matched with the bot, then store said player's scores/words/times, then before calculating who won that round run a separate function to take the bot's turn(calculating what word they would choose etc), again, using SendRequestAs to LogChallengeEvent to store the bot's choice to the challengeInstances scriptData and also taking it's turn and calculating who wins.
Hopefully that sheds some light on this complex question,
Shane
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstAyyappa R
Can you present more on your structure once? You are doing this by challenges and cloud code or just events and cloud code?
Astraport Alen
I still did nothing. Only plan project architecture. And therefore asked.
Customer Support
Hi Astraport,
Server side bots are certainly doable on the platform, in fact we'd recommend you code them in Cloud Code so that any tweaks that need to be made can happen without you having to re-upload your game to apple or google etc.
Unfortunately though there is no one solution which works for all. To get you started though, I've come up with a few ideas.
Seeing as the challenges require actual accounts to run properly, I'd create an account for only the bot to use. This account can partake in as many challenges as required at the same time so I wouldn't worry about needing more than one. The trick is that you need to know when to match a player with the bot account, if you can't form a pair for example with the challenge set to "PUBLIC" you could use SendRequestAs call JoinChallengeRequest and supply the bot account's id. This will send the request on the bot's behalf and that account will now be a part of the challenge.
Once all players have been matched you can use StartChallenge to force the challenge into a playable state. The tricky part is the "AI" which will govern the bot. While cant I really help you on this part (not my area of expertise) I can tell you where it would be implemented and roughly how to go about accomplishing it.
So when you want a player to take a turn, you use LogChallengeEvent and a custom event you have defined in the Configurator. This is where you usually store what values/score/times a player has achieved to the scriptData of the challengeInstance and execute the logic to govern who has won. This is also the ideal place to store and execute the logic which governs the bot.
You would check if the player who is logging the event is the player who has been matched with the bot, then store said player's scores/words/times, then before calculating who won that round run a separate function to take the bot's turn(calculating what word they would choose etc), again, using SendRequestAs to LogChallengeEvent to store the bot's choice to the challengeInstances scriptData and also taking it's turn and calculating who wins.
Hopefully that sheds some light on this complex question,
Shane
Astraport Alen
Hi Shane!
Thank you for your ideas. I will think.
Ayyappa R
Adding to that, Another possibility can be
Create a Module in cloud code and name it TakeAITurn. Here is the place where your AI code resides.
When ever you get a request for the turn of AI to play, Call this module from the other response of LogChallengeEvent cloud code to trigger the next action of the AI bot.
I'm not sure on syntax about how to call modules from other cloud script at the moment but this direction should help to decide about the possibilities.
Ayyappa R
I was trying for system where if any matching fails, it will create a bot and continue the random match. I want the bot to be unique lets say with diff name and pic every time user creates a random match.
If we create multiple bots accounts on server side, are they considered in calculating MAU per month?
Mainly is the MAU calculated based on user registrations in GameSparks?
Thanks,
Ayyappa.
Customer Support
Hi Ayyappa,
You could use a single GameSparks account for your bot.
You could then check if the player has been matched with the botAccount and set it's name randomly in the challenge scriptData.
This way the bot's name stays the same for the challenge and looks like many different users across multiple challenges.
No need to rack up an inaccurate an MAU calculation.
Thanks
Oisin.
Ayyappa R
Thanks for the idea Oisin. I guess this works.
I was in the thought of not having custom script data to sync with existing implementation. However, i can do this simple trick to work with single bot name.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics