Greetings, Am Don, 01 Jul 1999 schrieb Andrew Ritchie: > Now the computer parses the 'RAINING | HAILING | SNOWING' to, let's say, '0 > | 0 | 1', meaning that it's snowing here. Now for OR statements (|'s), I > simply cycle through all the 0s and 1s and make sure that at least one of Not all the 0s and 1s, just until you reach one 1. > them is a 1, or true. > > For AND statements (&), I simply cycle through them and make sure that ALL > of them are set to 1, or set true. What I'm not sure how to do is combine Also it suffices to break out, if you reach a 0. For combination of them without () you need to setup rules for order of evaluation. In C it's strictly from left to right and I advise you to stick to them ;) > the ORs and ANDs into one statement. For example: > > #if SNOWING | (HAILING & RAINING) > > Not sure how I would go about doing this. Obviously, I'd need a function to > parse () statements. Anyone got any ideas? Do stuff recursively: If Snowing is a 1, you can break away already, as it is an OR-statement. If you reach a () you need to call the evaluation function from the evaluation function and determine it's truth-value first, and then check if it's 0 (making the whole statement false), or true (making the statement true, as it's OR). - Chris PS: Anyone ever thought of implementing a PERL-Interpreter within a MUD for mobscripts/itemscripts/roomscripts etc. and has any experiences with it? -- Christian Loth Coder of 'Project Gidayu' Computer Science Student, University of Dortmund sg618lo@uni-duisburg.de - chloth00@marvin.cs.uni-dortmund.de +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST