Decision-making code, which one?

Started by
4 comments, last by Alpha_ProgDes 20 years ago
when having an agent make a decision in a program, when do you choose between a Binary tree and if-else statements? when there's pointers involved or when the code has become very godly in size? do programmers worry about speed performance or just getting the job done? [edited by - Alpha_ProgDes on April 12, 2004 2:40:19 PM]

Beginner in Game Development?  Read here. And read here.

 

Advertisement
well I posted it somewhere else in this forum..Python is great.Read this Python Tutorial(tells you about what it can do and gives you a short class..it all must be typed on notepad.but can be testing in python shell..or you can change the notepad file so that it has .py or something at the end of its name).it seems to be easy to use its optimal for games since it make things abit smaller and speeds the game up quite abit..here is the link:

http://www.python.org/doc/current/tut/node3.html

here is the download page:

http://www.python.org/

[edited by - BES on April 12, 2004 11:53:15 AM]
quote:Original post by Alpha_ProgDes
do programmers worry about speed performance or just
getting the job done?


A good general rule is to just get the job done. Then, if performance isn''t what you require, profile your code and go after the problem areas.

Of course, there are exceptions to every rule. For instance, if your solution is so slow that it would make the entire project unfeasable, it''s obviously nice to find that out sooner than later.
quote:Original post by BES
Python... all must be typed on notepad...
Nope. You can get ActivePython for Solaris, Linux and Windows.
quote:Original post by Oluseyi
quote:Original post by BES
Python... all must be typed on notepad...
Nope. You can get ActivePython for Solaris, Linux and Windows.

Oh thats good to know i been doing it in notepad...lol

As this is a general programming question, it does not need to rely upon any language for a relevant response.

My general rule is:- Can I understand this code NOW?

If the answer is not a definite Yes, then I''ve used the wrong approach to the task.

If I have my doubts about it today, just when I''ve written it, I''m not going to be able to maintain my code next week, month, year or whenever I may need to use it again or modify it.

IF THEN ELSEIF ENDIF ELSE are constructs that will mislead after a certain depth (in my case 8), so an alternative approach is called for at that point (in my case).

For involved testing structures, I would use binary flags set in response to simple conditions (an IF this = true THEN flag6=flag6 OR 4 type of thing)

Then an involved decision will only need a single test sequence on the flags:- an IF (flag6 AND $17)=$17 then result=true will serve the purpose.

As for speed -v- geting the job done, this depends upon the end result. For real time 3D animation, speed is obviously the main criterion but for Database maintenance, getting the job done accurately is far more important.




Stevie

Don''t follow me, I''m lost.
StevieDon't follow me, I'm lost.

This topic is closed to new replies.

Advertisement