+ Reply to Thread
Results 1 to 4 of 4

Thread: How to realise game bots?

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to realise game bots?

    Hello,
    there is a complicated task to write a plugin which will add bots into different rooms (common user emulator), depending on real users quantity. Bot must know how to send messages to the sever plugin of the current room. Please, help me do that.

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    There are different ways to do this, depending on how you want the bot to work. Most of the time I have a room plugin (on the server) that is attached to the room, and the plugin decides when to spawn a bot or despawn one. For example, I'll make a Java class that is the AI for the bot, and the plugin has a scheduled callback that calls a method on the AI class every so many milliseconds to see if it needs to make a move. When the AI needs to do something that the humans in the room need to know about, a plugin event is sent with the needed information, and client interprets the information as if the AI were another human.

    In some two player games it's easier to implement the AI on the client. In this case the client adds a boolean to the plugin requests that come from the AI to indicate that this is coming from the AI, and the plugin checks for this boolean so that it can process the message as if it came from the AI instead of the human.

    It's possible but not usually desired to spawn a process on the server that creates a full command line type Java client to log in and join the game to be the AI.

    See the unfinished Reversi example for an AI opponent on a plugin, with a turn based game.
    Quote Originally Posted by tcarr View Post
    Reversi.zip

    Please note that this was implemented using an older version of ES5 then put aside. The Java client will need to have all the ES5 imports fixed to use the current version of the api. The extension should work just fine if you implement your own client, but mostly the idea is to give you a code example of how a turn taking game would work.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for not answering you so long, thank you for code samples. But I can't yet understand how to make a notification of users that a bot has entered the room?

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Look at the Reversi game example for one way to handle this. Another way is to simply send a plugin message to the room when the bot enters - and it will be less confusing if you also send a similar plugin message about human players entering the room (either in userEnter, userDidEnter, or after the client sends an "init me" plugin request).
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts