It seems too abstract to even comprehend the task.
There’s a visual display of whats happening in the game, but there are no objects to manipulate or gain data from, there’s no api to interact with
So how should i know how the hell i should code it?
Example; the mountain height game:
The spaceship flies over the mountains, but i have to, out from my own variables calculate the height? but how does that correspond to the game? How do i know if the spaceship crashes? Theres no API to pull the mountain height from and compare them.
Or well, theres the print out statement, but no intellisense that gives suggestions.
Am i totally wrong here? or how is this site supposed to work?
The website doesn’t use any API because they want us to be able to code with any regular language without needing some shoot(), move() etc…
The model of the website is to communicate via text, your program is given inputs and you need to print out your move. So in the case of the mountain descent your program is fed in 8 integers heights and you need to print which mountain to shoot on. When you open any of these puzzles there is a code sample that reads in all the inputs, does nothing with them, and outputs a possible move as an example. Also the problem statement has info on inputs and outputs.
Hope this helps.
That doesn’t really make any sense to me, strictly working with text input, how should that improve an understanding of all the aspects there is of coding? It’s not your problem, i know, just more of a speculative question.
To me it seems a bit too abstract in the way it’s set up, to help me improve on my code.
But yes, thanks.
You are correct to say this site cannot help training “ALL” aspects of coding - UI programming, web interface, graphics, sounds, database connection, networking and server configs - too many sub-tasks of a programming project are left out.
But it is the beauty of it. Coders here can concentrate on the back-end algorithms, logic, data structures, AI and mathematics of game programming, which skill can be extended to all other kinds of application developments. Real-world programmers do rely on text input-outputs. You mentioned “pulling data from API” but do you know data going in and out of API are still the same text I/O?
Just spend a few minutes (or hours) solving a few puzzles here. You will know whether it could help your coding skill.
Yes i know. All those things you mentioned are kinda “backend” stuff anyways, systems you have to build, which is fine they dont teach that here.
Yes logic, math, data structures are a good thing to learn.
Hmm i would argue that in games, you rely on text input / output, yes maybe for debugging purposes, but what i meant with pulling data from the API, is that; there’s no objects behind the scene i can interact with, i cannot acces any variables, methods, objects, or extend the system thats there, in any ways (if my understanding of this site is correct).
I know everything in a computer is I/O, but im not writing in machine language, im writing in an abstract OO language, that i expect should handle all those things. Not just sit here and make a text application Because having to do with outputting and inputting text in a game, that has a visual representation, like the “demo” that plays has, doesnt really reflect the skills i would use when i was coding in an engine or anything like that.
But then again, i might have misunderstood the purpose of this site
EDIT: i forgot to mention i clearly see the point of working with text when you’re still learning to code, so theres not that many confusing things to have to focus on.
You say “text” like it’s a bad thing. The text is only a representation of some data. Converting one representation of data into another representation happens all the time. That’s why you need to know how to do it.
Think about it this way: reading from stdin is like your program is asking some API what the current system state is. Printing to stdout is like your program is telling the API what to do next. All you have to do is: (1) convert the input into something you can use. (2) Do your thing. (3) Convert your data into the format the API expects.
Compare that to an API on the web where you get a JSON string, aka. “text”, and do step one with
JSON.stringify(input) and step three with
Nono, you misunderstand me.
Text is a good thing. It’s just a conceptual conflict.
I understand that text gives a good way to learn to code or it’s a good thing to think in, so there’s not alot of abstract stuff to consider when coding.
When printing to stdout, you explicitly tell the program what to do, in a very “simple” manner. If you had an object, that is more versatile and flexible than a simpe method that prints out text, it would help give a better overview of what programming includes overall (you know, oop). Or well what ideology you want to follow, but that’s another discussion.
And the json examples you came up with are the same as the stdout and stdin, it takes in text and prints out text.
Passing variables to the same method all the time is very restrictive.
I don’t understand this topic
I do not either, anymore
But what i got from the responses so far, is that all data is manipulated through text handling
This thread makes me feel a little uneasy about having spent so much time on algorithm and so little on the profound and metaphysical topic of IO when playing with CodingGame…
I’ll try my best.
This website allow us to code in (nearly) whatever language we want to solve puzzles. We have a nice displaying of what is going on for some puzzle (the viewer is not available for all puzzles as you’ll see later).
Codingame can’t make an API/framework/bundle of object to manipulate data because they’ll have to develop it for all the languages. Impossible. So they have to use something standard between all the language on the planet. There’s only one thing for that : Standard input, Standard output and Standard error output (well, you also have process signals, but it’s harder to manipulate them). So there’s no choice. Our code must communicate with standard input/output.
You interaract with the outside world with standard input/output. It is text (because this is how standard intput/output works) but most the time it will be something else soo you have to parse it. But codingame provide “starting template” for all puzzles. The data parsing is (most of the time) already working when you start a puzzle.
For your example (moutain heights), the mountain heights are given in the standard input. The start template already read it. But you have to code what to do with it.
Just read the statement of the puzzle.
Yes, yes, that makes sense.
Guess i have to adapt my bias to this way of programming, because it seems really abstract to me!
Thanks for clarifying abit, I’m just really confused.
I’ll try some stuff and return if i have any questions.
That’s just how my brain works, i can’t stop thinking about how it works on all levels, im usually a simple guy. But this can make my brain fart on an entire other level. Just like math, i always wonder about why the formula is as it is, rather than just “plugging and playing”.
Did you now that 1 / 998001 will display all number from 000 to 999 in order. (0,000001002003…999) and there is no valid sudoku with less than 17 clues. How about that.
Nope! i didnt know that, thats quite impressive, why does it show the numbers like that?
how do i text in codingame
Or rather the other way around:
JSON.stringify(output) (with input and output being JSON strings).
I agree with Angelo1337 , codingame games are confusing. This site relies on text output (println , System.out.** ) . When solving algo questions, I just need the method signature and I will implement.
I don’t want to waste time to print the output in infinite loop to see the animations. While I appreciate the work on the animations, I am in the camp to solve problems in the shortest amount of time (not get distracted by the bells and whistles )
Totally agree with you. I’ve never seen problems that do not define possible movement (like four directions, eight directions, distance etc.) of a 2-D problem until I visit this website.
Which problem is it? Do you have the link?