0-indexed vs 1-indexed

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Side-Scrolling Game "Vikings VS Skeletons" with complete Source-Code (.c3p) + HTML5 Exported.
  • i would not mind having to dump old event sheets, either. there's no place for sentimental backwards compatibility at this time :)

    but i do worry about the changed behavior. by deviating from the 'norm', you do not only make it harder for people with (even small) experiences in other languages to adjust to construct, but also to allow beginners who've learned construct to jump into other pools. i also doubt that indexing is a much easier task for beginners in a 1-indexed environment ...

    now don't get the impression that i'm zealously opinionated about this point, i'd just like to contribute to the discussion :) as long as it gets documented somewhere, this won't kill me... immediately.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Or leave random the way it is and explain in the program (by extra info, displayed when clicked on it, for example) that it starts at 0.

    (and perhaps redirect to the wiki to explain and give examples why)

    Either way I personally don't mind random starting at 0 or 1, at this moment.

    Scirra's new slogan will be: Random starts at 0, deal with it.

  • Yeah, but the fact is that there are so few reasons to have it start with zero, and so many to have it start with one.

  • What about negative values in the Random() function? Would Random(-10, 10) work?

    Also, what would happen if you put a higher number first, i.e. Random(10, 1)?

    Just curious.

  • In all cases we can offset it with an addition... like -10+Random(11) would range from -10 to 10. But Random in its current form is confusing; one expects that the N will be included (11). Also, one would also expect that Random (1) would give boolean results (0 for false, 1 for true), but in fact you have to do Random(2) (gives 0 or 1).

    Changing it to 1-indexed could also cause confusion; Random(2) would return 1 or 2, but not 0. Those used to the zero could easily get confused.

    What I say is, decide on a convention and stick to it! Also explain it well in tooltip and in documentation.

  • Perhaps there should be a separate call for for a random pick of either true of false, 1 or 0.

    Something like Rndbool?

    Any way there are time's like when you want a random angle where zero might be ok, and there are times when zero will not do like in getting x, or y, but currently setting that up right is a bit confusing.

    How about Rndbool for 0 or 1

    Rndnoone for starting with zero

    and just Random for starting with 1?

    ehh then again Randnoone(1) would get the same as Rndbool.

    Dam you guys are confusing as hell...

  • How about letting it accept characters as well, IE:

    random('C', 'G') gives CDEFG

    if char get ASCII code, random(ascii1, ascii2) etc.

  • Hi, I'm new to Construct but proficient with many programming languages.

    Here's my point of view: I agree with changing all loops to 1-indexed when possible.

    As for random() I don't see a reason to change it, either leave it like that or force the use of two parameters

  • Would just like to point out that 99% of my caps use the Array Object. I have 267 caps in total. 99% of 267 rounds out to 264 caps.

    Assuming it takes an average of about a minute per cap, I am looking at 4 hours, 24 minutes of time wasted fixing my files.

    Can we at least have this as an option within the object itself rather than a permanent change? Or at the bare minimum still supply a 0 indexed array object as well as a new 1 indexed version?

    Thanks.

    EDIT: The above post was made due to frustration with a change that seemed unnecessary and has subsequently broken the majority of my cap files. I'll deal with it, even if no changes are made. But I'm letting it be known that I don't exactly approve.

    To understand the scope of my annoyance, I use the array object for things as simple as private variables within a function, and for things as complex as the rotation matrix, vertex information, and Z buffer in my 3D engine. This is not something I can fix in a few scant minutes.

  • If you compile your projects with older versions, they will still work. But if you want to open your projects and update them with newer version of construct, then yeah, you have to fix everything...

  • You could copy/paste the old array.csx from a previous install into your plugins dir; you don't have to use the new one.

    It's a much needed change though, being the only object which was 0 based, there's no doubt it could cause confusion or lack of clarity. Most changes we make are bound to break something now, unfortunately, but they're nearly always for the better.

  • You could copy/paste the old array.csx from a previous install into your plugins dir; you don't have to use the new one.

    Yeah, I actually thought of that after posting.

    As I said though, I'll deal with it either way. I've always been a big advocate of consistency in programs/programming so I believe it is a welcome change overall.

  • It's the sort of thing that's way better to bite the bullet now rather than further down the line.

  • So things now start from 1?

    Everything else starts from 0...

  • It shouldn't do, everything should start from 1, with the exception of random(). If you find anything else 0-indexed, report it as a bug.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)