Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Decision-making code, which one?

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

## Recommended Posts

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]

##### Share on other sites
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

http://www.python.org/

[edited by - BES on April 12, 2004 11:53:15 AM]

##### Share on other sites
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.

##### Share on other sites
quote:
Original post by BES
Python... all must be typed on notepad...
Nope. You can get ActivePython for Solaris, Linux and Windows.

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 10
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632199
• Total Posts
3004733

×