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