Combinatorial logic

Questions about how to create your own dungeons and replacement graphics and sounds.

Moderator: George Gilbert

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Combinatorial logic

Post by terkio »

I found no clean way to make a set of levers open a door when they are all in a given position. I do not want a one shot operation, I want the door state to depend only of the levers position.
I found a solution that will be slow when using many levers.
I found a solution that will be fast when using many levers, but it crashes RTC when a player twiddles a lever too quickly.
I don't see an easy solution that will be fast and crash safe.
How come it is so hard to do combinatorial logic with RTC ?
Am I missing something ?
Is there a solution with relays ? I see boolean fonctions in the relay....AND OR XOR and so on.
Please help me, about the relay. The wiki did not help, telling no more than I can read editing a relay.


I found some answer.
With a counter I can make an AND over several levers. Each lever doing a toggle to the counter.
With a counter I can make an AND over several floor triggers. Each trigger doing a activate, constant weight to the counter.
Last edited by terkio on Mon Aug 20, 2012 6:55 pm, edited 1 time in total.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Combinatorial logic

Post by Gambit37 »

I stopped using RTC, so I'm sorry that I can't really help.

I'm not sure that there's anyone left on the forum who is still doing complex stuff in RTC, but if there are, then I think that would be Parallax, the_master or Joramun.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Combinatorial logic

Post by Paul Stevens »

Using counters to perform combinatorial
logic is like using a drill press to cut a board
in half. The tool does not match the task.

I have never used RTC. But....
You want to use relays, if they have AND
functions.

switch1 AND switch2 AND (NOT switch3) AND ...

So you need a NAND function or a NOT function.
A NOT can be created with XOR if needed.
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: Combinatorial logic

Post by terkio »

I agree from a theoretical point of view.
However, I only find work arounds with RTC.

I did not beleive a counter was a way to go. Amazingly it works nicely.
With a counter I can implement: pad1 AND pad2 AND (NOT pad3) AND ... Where pads are loaded or not loaded.

The trouble with the relay is: I can't figure out how to use its operator and I don't find an example.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Re: Combinatorial logic

Post by beowuuf »

Basic DM had a four input AND gate that you could configure, and counters were seperate, RTC intentionally used counters and relays as the simple building blocks for complex puzzles.

Relays used to be simply that - it took a signal in, and propigated (but could also change its state along the way). It then had added comparative functionality, so you can compare the input and look for it being related to a certain output - a certain champion created the state, a certain item, etc.

For what you want to do, counters and relays (without the complex boolean stuff) should work. If it's not working with the levers, it's because there's some quirk of the lever that's making it work strangely because of the on/off nature of the lever. Try using different input signals with the counter system that works.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Combinatorial logic

Post by Paul Stevens »

I gather that an RTC counter is more than just a
counter. It must be more like an ALU (Arithmetic
Logical Unit) in a CPU.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Re: Combinatorial logic

Post by beowuuf »

The counter in RTC is basically like the counter in DM, except re-useable (it does not disable itself at 0). Using wall_action objects you can set a counter's value . And relays have a secondary comparative ability that can read a value on a counter.
User avatar
Lord_BoNes
Jack of all trades
Posts: 1064
Joined: Mon Dec 01, 2008 12:36 pm
Location: Ararat, Australia.

Re: Combinatorial logic

Post by Lord_BoNes »

Where counters are concerned, ACTIVATING the counter makes its value decrease by 1, DEACTIVATING the counter makes it increment by 1. This might seem a bit backwards, but it works this way for a reason (most probably for the puzzles in the original DM games).

To work with a bunch of levers and such, you can just have each lever with ITS OWN COUNTER that you toggle with said lever. Whenever a lever changes state, just use a series of relays to check the value of each counter... if they're all what they should be, then trigger the effect (open a door or whatever)... and if they're not what they should be, then deactivate the effect (close the door again).
 
Image

1 death is a tragedy,
10,000,000 deaths is a statistic.
- Joseph Stalin

Check out my Return to Chaos dungeon launcher
And my Dungeon Master Clone
Post Reply