Need more Gems!

Again, I agree with PSL :smile: (see another post)
If it’s not too hard to put in place, is it possible to have the real XP and gems earned at the end of a level.
Or something like : gems win this attempt / total gems won on this level.
I think we all ask us the question : why I got another count of gems and XP ?

5 Likes

That’s just a bug that we will work to fix; it should show up as already achieved instead of counting up again.

3 Likes

if you are stuck: just skip that place holding level! which can be found here

hop this helps!

3 Likes

I think another relevant metric for ranking might be Lines of Code! Might make people work toward clever shortcuts and efficient code.
(just had the idea after spending an extra few minutes to beat Slalom with 5 lines, rather than the suggested 30+)

3 Likes

While the idea is good, it has some obvious problems:
JavaScript allows the whole code on one long line without line-breaks, so JS-Players always win.

Also one of the loading quotes says the following:

Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

It is of course a valid metric, but one that can easily lead to the wrong conlusions. Having 100 LOC for a Hello-World-Programm is obviously too much, but 10 lines for a complete physics-simulation is also not good.

3 Likes

One the one hand LoC does sound good but for codecombat:

  1. it is hard to compare between languages (example: “for x in y” vrs “index = 0; while index < #; blah = …; index +=1”
  2. is “c=sqrt(pow(a,2)+pow(b,2))” (one line) really better than “aa = aa; bb = bb; c=sqrt(aa+bb)” (three statements/lines) (and that is but a simple example)
  3. etc

As for clever shortcuts:

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it? - Brian Kernighan

:smiley:

Besides, I can do slalom in python with three statements.

3 Likes

To the extent conciseness is to be rewarded, I’d think counting non-white space characters would make more sense than counting lines, and would be really easy to implement.

Maybe slightly better would be to count “tokens” but that would be more work than it’s worth to figure out how to define and count.

3 Likes

This is still not fair over all languages (I believe).
As I recently found out, Python has a really nice construct:

evenSquares = [n**2 for n in range(0,10) if n%2 == 0]

Wow! This little piece of code gives you a list of all square numbers which are gained from even (but not odd) numbers. As far as I know, not every other language has such a construct. Likewise the other languages allow things you can impossibly do (that easy) in Python.

Given this, special problems can be solved with different effort by different languages (that is also the point why there are so many of them). However, our achievementhunter would need to find out and use the shortest language for every level. This by itself is not bad, as it encourages users to try other languages, but I’m 3 month into CodeCombat and didn’t finish one level in Io. Now imagine to find the shortest program for The Trials

Also, counting relevant characters lead to another problem which Vlevo mentioned as second problem:

s=self          # At the cost of 6 letters I now save 3 letters per call to self
n=s.findNearest # Calling this method now saves 12 letters ata one-time cost of 15 letters!
m=s.moveXY      # While I prefer move, moveXY saves more letters, because I only have to give 2 numbers
loop:
    e = s.findEnemies().extend(s.findItems())
    if e:
        p=n(e).pos  # WHAT THE
        m(p.x, p.y) # ****?!?

This program finds and moves to the nearest item or enemy. It is not particular useful, as it does not fight enemies, but I try to prove a point here. Nobody will ever be able to read that again. I tried to save as much letters as possible, but you likely can compress it even more.
This is not the goal of CodeCombat! This is just ugly unreadable code.

(All opinions in this post are the authors own opinions and not necessarily the same as the opinions of any core-team member)

4 Likes

Good points all, but what about if we fixed the statement counting and then did fewest unique statements? https://github.com/codecombat/aether/issues/140

You’d still have differences between languages, but that would be kind of the fun part: championing your chosen language, seeing which can be the most concise per level. Whitespace, comments, and how many letters your identifiers had wouldn’t matter.

3 Likes

How to count statements in different languages is still an interesting question…

how many is:
x=y=z=1 // one seems fine to me, in some that would be the same as x=1 y=1 z=1, but in others (if I remember right) it becomes a truth statement.

But how many statements is this?

for(;;); // one, seems obvious

for(x=1;x<10;x++); // still one? or three? I can go with one, being that it is the “normal” case

for(x=1,y=2,z=3;x<20;z-=x*z,x=z-y,muh=haha); // still one? or seven? or remove the previous three so its 4? or is it two since I snuck something in that has nothing to do with the loop itself…

If still one, then it seems like it should be possible to do “Slalom” in one statement in javascript. (I had a comment in my post above to that effect but removed it since it seemed like cheating.)

I’m not against the idea of having a “score-board” for statement count, just pointing out that it is not as simple as it might seem.

clojure: is “(let [assignment] (action))” two or three? (iow: does the wrapper “let” count)

3 Likes

Well, yeah, if someone wants to turn it into an obfuscated perl contest, they could!

Is counting characters an imperfect method? Yes, very imperfect. My only thought is that it is as simple to implement as counting lines, but somewhat better. I’m just thinking of my own day to day coding in any language. Normally fewer characters => better code in a way that fewer lines doesn’t. Maybe it’s just me.

I don’t completely understand Nick’s suggestion about counting statements but I guess it’s more or less the same as what I meant by counting tokens, however defined. It’s very likely to be a higher quality measure but harder to implement.

Obviously what we need to do it check the size of the byte code or object code or IR… Yes, I am kidding!

3 Likes

If you reward somebody, regardless how trivially, for doing it then they will. I’m really a fan of turning niche practices into general practices.

I almost said ‘bad’ practices but there are doubtless cases where these kinds of contortions become useful. I just don’t think a platform for general education should really reward them.

3 Likes

Well, I think it’s more fair to say some will and some won’t. There are lots of challenges here and whenever we log on here we make implicit decisions as to which challenges are most useful or interesting to us and which aren’t.

Nick used the word “fun” which is the key to counting lines or statements or whatever. It’s not meant to be something that leads to the absolute best coding, it’s just another challenge that folks can take up or ignore.

Also, there still can be learning from non-optimal coding. For example, if you adopt the goal of minimizing lines or statements, 90% of your changes might be bad but 10% might give you some new insight. I think that’s actually one of the minor goals of the obfuscated perl contests, but I can’t even read “good” perl code, so I’m not sure. (I can write bad perl code though!)

It’s so cliche, but coding to minimize the number of lines or statements is what it is. What it’s not is any attempt to generate the absolute most optimal code in some global sense – which can’t be done anyway!

3 Likes

This thread got so meta, but I can’t stop thinking about it… :smile:

Are there any existing ways to score code based on DRY (don’t repeat yourself)? You could somewhat measure that just by zipping the source and checking the compression ratio (although with source code this tiny the zipping overhead probably makes that method useless in practice).

Also, not as easy to explain a compression ratio to users compared to just counting lines. But could just explain DRY and then produce a magic “DRY score” for code.

3 Likes

Good points all. I’m don’t think that lines of code is necessarily the best metric, I just wanted to throw the idea out there that there could be a score based on code efficiency. Perhaps clock cycles would be a good metric (although it’s a bit of a killer for the move() boots!).

And @Vlevo - did you solve in 3 lines before I posted, or did you go back and revise your code to make it more concise? Beause that is exactly what I’m trying to encourage: I think there should be an encouragement to revisit your code and think of it in a different light. This is done to an extent with the leaderboards, but I think that there are multiple approaches to encouraging the revisiting and revising of code.

3 Likes

I usually try to do the level as expected. Then if I feel like it I do it another way . . . so you get the credit for making me feel like it on this one. :smiley:

3 Likes

I have a similar problem as the thread starter - but I’m only level 7 and stuck at “Bekannter Feind” with only 44 Gems. I would like to reset my account without deleting it.

3 Likes

or you could try this post for another idea.

3 Likes

Doing it now. Thank you for your help!

4 Likes

So i’ve done that and simulated some hundred games. But still I don’t have even one more gem. What’s the trick about it? I’m loosing my interest in this game, as I won’t spend money as a workaround for a bad concept. That doesn’t mean I wouldn’t spend, if I stay here … but forcing me that way is just wrong.

4 Likes