I'm interested in how bots are usually written.

Here's my situation:

I plan to make an online 2D mecha game in HTML5, and the server-side will be done with node. It is intended to be multiplayer, but I also want to make bots in case there aren't enough players.

How does my game logic see them, as players or as bots? Is there a standard by which I should make them? Also, any general tips and hints will be OK.

  • 1
    \$\begingroup\$ I think there is probably a few ways you could do it. I am currently making a game in a different language, but the principles are the same of course. What i've done is create a base "Player" class and then extended the functionality. For example "HumanPlayer" would receive keyboard input. ComputerPlayer could override the update method and run an AI script. My way might not be the best idea but just thought i'd offer an idea! \$\endgroup\$
    – Davos555
    Jun 6, 2012 at 11:02
  • \$\begingroup\$ You should have worded the question as "How can I add bots to my game to reach a minimum numbers of total players". As it is, you already imply a solution, with a question related to that solution, not to the main point of filling in with bots. \$\endgroup\$
    – Darkwings
    Jun 6, 2012 at 18:48

1 Answer 1


It depends on your game logic but I would say: neither!

Your game should see the players as Mechs and the bots as Mechs, and deal with Mechs accordingly. If your bots see an enemy Mech, what's it matter whether it's a player or a bot? Shoot it!

Your game should differentiate between a Mech who's a player and a Mech who's a bot only when it's necessary - otherwise it shouldn't really need to care! Same with differentiating between a Mech who's on one side and a Mech who's on another.

This could tie into component oriented design where your Mechs might be similar entities but one might just happen to have a player control component and another has an AI control component - it would circumvent any inheritance issues.

Note: Mechs and Mecha are a similar thing with two very different design ideologies and I know the question states Mecha but I've just gone with the Mech term in this answer

  • \$\begingroup\$ Thanks for the great answer! Can you please describe the difference between "mech" and "mecha"? \$\endgroup\$
    – jcora
    Jun 6, 2012 at 16:52
  • 1
    \$\begingroup\$ @Bane Roughly the same difference between "animation" and "anime" \$\endgroup\$
    – Jimmy
    Jun 6, 2012 at 18:14
  • 3
    \$\begingroup\$ While all this can be generally true, computer controlled allies can and should have differences that make the game better for the real players. A bot won't get upset if the game is unfair to it, which means you can probably attack it more and less fairly than you can the player. If the name of the game is team work, it would frustrate the players if their computer controlled ally died and lost the game for them. Don't let that happen. \$\endgroup\$
    – DampeS8N
    Jun 6, 2012 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .