Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
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! –  Davos555 Jun 6 '12 at 11:02
    
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. –  Darkwings Jun 6 '12 at 18:48
add comment

1 Answer

up vote 7 down vote accepted

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

share|improve this answer
    
Thanks for the great answer! Can you please describe the difference between "mech" and "mecha"? –  akled Jun 6 '12 at 16:52
1  
@Bane Roughly the same difference between "animation" and "anime" –  Jimmy Jun 6 '12 at 18:14
3  
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. –  DampeS8N Jun 6 '12 at 18:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.