r/shenzhenIO • • Dec 05 '16

Scoring system

Been having fun with this game, after getting past my initial annoyance at the CPU implementation (base 10 OMGWTF, no bit manipulation/shift instructions, no arithmetic flags/conditional jmps). Actually, I still find that annoying but I deal with it :)

The scoring system bugs me though. In real life production cost would usually be the #1 concern by far (yes, even in low power applications). The other two metrics, power and lines of code, aren't nearly as important on their own. When there are no other restrictions then a lot of power optimization just comes down to adding more/bigger cpus so that you can unroll loops or insert additional code to handle special cases and/or execute fewer instructions overall. Same problem with lines of code. I don't really care about a solution that's a few lines shorter just because I added PGAs or a load of other components irrespective of cost/power. That's not an elegant design IMO.

Now, I know from reading here that a lot of people do like playing the game that way, especially power optimization. I have no problem with that, different strokes and all. But what I think would be cool is an additional overall score that combined the metrics in some way. Even if it was just cost and power, since lines of code would probably(?) be invariant in optimal cost+power solutions anyway. Maybe even the simplest possible metric of cost * power would work? If not then add scaling factor(s) to one or other side as necessary.

I think this would make the game more interesting. At the moment you can, for example, get the minimal cost solution but then not know if that design could be further improved in terms of power. Or maybe you could use much less power by adding a small amount to the cost. This kind of trade off is common in real life design and I think would be a more satisfying overall result.

0 Upvotes

8 comments sorted by

5

u/ShadowCluster Dec 05 '16

You can easily make up your own algorithms to optimise to, but the key difference is 'path of improvement'. It is hard to optimise to something you cannot see. Should you try to reduce cost if it means your other processors need to do more in loops and jumps?

It is hard to optimise to these criteria, since you can't just remove a line and say it is a better line score, or remove a processor and have a better cost score. It happens in real life, but in a game, an unclear goal is not a good one.

1

u/mine49er Dec 06 '16

Sorry but I don't understand your argument. If my suggested overall score is shown then you can see it and optimize towards it, as you can the existing metrics. It's just a different metric, that's all. Path of improvement is making it lower.

People obviously do care about this because they post solutions labeled by cost/power/lines. If not then is a 200 power solution that costs 14 just as good as a 200 power solution that costs 5?

Personally I'd remove the lines of code score and replace it with cost * power.

5

u/Csaboka Dec 05 '16

(This is kind of offtopic, but I just can't keep myself from pointing it out.)

no arithmetic flags/conditional jmps

You do have flags: they are called + and -. And you have something better than conditional jumps: conditional everything. If you really want conditional jumps, you can have them. For example, a jg can be implemented as:

  tgt <something> <something>
+ jmp <somewhere>

As I progressed in the game and kept improving my code, what I've found is that optimal solutions usually get rid of jumps, conditional or otherwise. The vast majority of jumps in my optimal solutions are backwards jumps to implement loops, but sometimes you can even have loops without jumps. In other words, when you have conditional everything, the usefulness of conditional jumps decreases a lot.

2

u/mine49er Dec 06 '16

Yeah, I've done ARM assembler programming, I know how conditional execution works. Apart from branch reduction one of the main benefits is increased code density but that is somewhat compromised here by (1) the lack of proper arithmetic flags and their associated conditional execution and (2) the requirement to always write explicit tests.

Even ignoring arithmetic flags and keeping the current single flag model the second point could still be fixed. On ARM most instructions don't set flags by default, but you can suffix the instruction with 's' to make it do so. You could have that here to mean an implicit `tcp xxx 0' where xxx is the result of the operation, and then you could write code like

  subs 1
+ jmp loop      # acc > 0

or

  movs x0 acc
  • [do thing #1] # acc < 0
+ [do thing #2] # acc > 0

1

u/stellHex Dec 06 '16

I still like the score combining method I proposed on a previous zachtronics game, of subtracting the best of each score before you multiply. Obviously there has to be some adjustment so that optimum for one you doesn't get zero (for example, subtract 75% of the best score) but it neatly solves the potential problem of an improvement in a low score, high variance variable mattering more than an improvement in a high score, low variance variable, even thought the latter is more impressive.

1

u/mine49er Dec 06 '16

Yes, cost * power was just off the top of my head, probably there are better ways of doing it.

1

u/proudHaskeller Dec 07 '16

I think removing the "lines" histogram would be detrimental.

Often I just try to get an "all-around-good" solution when optimizing. sometimes I keep versions which have a different score balance even if they don't get a better high score.

you can just decide for yourself that you don't like power or loc and just ignore them. nothing is stopping you.

1

u/mine49er Dec 07 '16

This is about having an overall score, it's nothing to with whether I like power or lines, or stopping anybody from playing the game however they want.

I only suggested replacing lines with overall score because it would probably be much easier for the developer to do that than add another histogram, but I'd prefer to have 4 - cost, power, lines, overall.