Jump to content
  • Advertisement
Sign in to follow this  
moeen k

best game algorithm

This topic is 2076 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi. IVE BEEN WORKING  on game projects for a while but i had problems on working on many part of games that isolved them anyway but i think there are basic simple solutions for them. some basic standard algorithms for them that is same in all aengines and languages and api,s. for example in a game there are some moments that a charcter moves to a new position. you want to say if a player moved to that postion hes,the winner. as you know a game runs at least 30 times in asecond and the code runs 30 seconds in a second to. if you say if(position==...) or if(pisition>...) that part of code runs as many times as your charcter is in that situation and you just want that part of code runs at just one frame. or many other algorithm like spawning enemies in diffrent places or diffrent ai for diffrent kind of enemy creature or...........

i think there should be a resource for these kind of algorithmes.

thank you for helping

Share this post


Link to post
Share on other sites
Advertisement

There are a lot of solutions to various problems we face in game design, and what works on one game may not work on the next. The only requirement on what is the right approach is that it works.

 

For detecting if a player passes a certain point, it sort of relies on your libraries being used and other design decisions. You might have that in your collision detection, and that might be handled by your physics library. But your game might not allow that, and you might have the detection attached to updating character position. Or you might be polling position as you described.

 

For spawning enemies, I suppose there is a common algorithm since we apply a matrix to the model to convert it to world space and call it either world or model matrix. That is largely dictated by the hardware and graphics APIs, so it is more widely used.

 

And for AI, I'm sure we all wish there was a lot more commonality in AI solutions. Maybe a pseudo-object oriented approach is the most common, in that you have base behaviors and extend that with individual behaviors for the specific creature or whatever. But the whole "my AI is OO" sounds a lot better than it looks in code. AI code is notoriously bad for needing to know stuff that OOP says it shouldn't worry about, so the code just becomes a freaking mess and you hope and pray somehow it accidentally works. At least, that seems to be the common approach. This breakdown in object orientation is because you just can't afford to calculate what you really want to know, so you cheat and steal information wherever you can get it to approximate the actual thing you'd want to know. Like object orientation would suggest we really want AI to respond to whatever it sees, but obviously we can't render the scene 100 times for 100 enemies and then use image processing to decipher what each enemy sees, then react to that information. So we hack the heck out of it. At least, that's my experience. If anyone knows how to avoid that, I'd love to read some awesome articles about how to civilize artificial intelligence coding techniques.

Share this post


Link to post
Share on other sites

There is no best algorithm. The algorithms you describe are very situational based on the genre and the layout of the game.

If you really want your check position to verify winning the game code to run per frame: just have a if else statement. The if would be checking the values less than the position you need to win. The else would just be anything besides that.

Simulating behavior is just state management.

Spawning monsters is just drawing the added monster from a list that can contain them.

Edited by warnexus

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!