The Let's Play Archive

SHENZHEN I/O

by Quackles

Part 32: Assignment #13: Three Kingdoms Tokens

Three Kingdoms Tokens



They used to say TV was “Life with the boring parts cut out,” and I guess this also applies to amusement parks! Honestly, I shouldn't really be surprised that there is a Three Kingdoms Land here... If Disney World can have areas themed after parts of the American past, it only makes sense for China to do the same.
Anyway, let's see the spec.








Seems pretty straightforward, though (even with I/O expanders) this is definitely a 2+ MC job - ringing the bell and giving change should probably be done by separate MCs, just because it'll be a complete pain to coordinate otherwise. It's also worth noting that when giving change, all 5-銖 coins have to be given before all 1-銖 coins.

In the same vein, the first MC has to be the one accepting input. So...

[ ~ ]





So far so good. The code I've written up to this point adds the inserted coins' value to acc - then tests it against the price. It'll ring the bell and notify the change-giving MC (not yet in) how much change to provide, but that code isn't written yet.

I know what I'm doing next.

[ ~ ~ ]



 

I've added the second MC, though right now it only gives change in 5-銖 coins. The first MC's almost complete, except for the bit where it rings the bell - it subtracts the price from the total inserted and passes that value on to the second MC.

Just a bit more work left on this one!

[ ~ ~ ~ ]



 

Here's the final version. It's ¥11 and uses 326 power per run, on average. It turns out the change-making MC needed 10 lines to make change (once I added the code that gives out 1-銖 coins), and I couldn't get it down to 9, so I had to bump it up to a MC6000.
In addition, the first MC rings the bell.

Honestly, I don't think there's any big optimizations to be made with this design. It seems pretty solid, though it really would have been nice to do it for ¥9 as I'd originally envisioned.



More ancient wisdom: They say he who runs in front of a car gets tired, while he who runs behind gets exhausted.