As an experienced programmer, how do you get started with Code Combat


#1

I am new to CodeCombat and obviously the forums, so forgive me if this is posted int he wrong place or anything like that.

I am struggling a little bit with how to play this game. The Javascript isnt what I am struggling with, I know Javascript and general programming concepts well enough already, after all I have a BS in comp sci and develop for a living . What I am trying to learn is how to make my dudes do what I want. I know what I need them to do, I know how to declare methods and variables and flow control and all that, but I have no idea what methods I can call to make them do it. Or even what commands I am limited to.

I have been playing the intro campaign levels today, but some of them I have gotten stuck where it wont let me advance the story even after completing all goals. But usually I have to look at the guide or solution because I dont know what methods I can call. Or when I do know a method idk what data I pass or parameters mean. For instance this.say() on a unit. I can send it a message string and a data bundle, but I have no clue what messages I am limited to or how the data is used. This is an example, not my specific problem.

I feel like I am missing something. What I need is an API to look at, and maybe an introduction to the code combat framework. My Google-fu didnt get me very far with that. I have checked out the Code Combat source to maybe use that to try to figure out what API I have to work with. If nothing like that exists, how did you guys get started?

tldr; How did you get started learning the Code Combat API? Are there any guides or documentation out there I can reference?


#2

I completed the initial tutorials (which were boring for me as I’m an experienced coder). After that I started playing BrawlWood (which is a blast). In BrawlWood to see what functions/attributes are available for each unit or building type you just click on one of those units or buildings and it gives you a list of available functions/attributes for that unit in the code editor under the code. You can hover over each function for an example summary of what it provides. There are multiple tabs that you can click on which show different types of functions. I found these references more than adequate. Each type of unit has it’s own script, so you need to click on each unit and script out what you want them to do. Each of those scripts is shared across all units, so if you want a specific unit to do something different than the others you’d have to use an if statement to match against the unit id or index to make it do something else. One thing to be aware of is that these scripts are executed in a sort of loop and that only one attack or movement action can be performed per cycle, so you need to use if statements to have different actions performed under different conditions. These can be based on many different world conditions that can be accessed via functions. An example would be doing this.now() which tells you the current elapsed game time in seconds. You can use that to time out actions.


#3

Thanks for the tips. I tried out Brawlwood for a few minutes and it definitely seemed more interesting. Alot of that I suspected from the tutorials, sounds like Ill just have to keep playing and Googling to figure some things out.

About the list of available functions and attributes for a unit, can that list change between games? For example, I have a ranger in Game A a ranger in Game B. Will they always have the same abilities (read methods and attributes)?


#4

Each unit has a pre-defined script assigned to it so the functions/attributes available to each type of unit will not change (unless the developers decide to change something for the sake of balance).


#5

I would say that the base functions available do vary between levels, for example in some of the levels you move with functions like: moveRight(), moveLeft(). On other levels you have the more versatile moveXY(6,9)

So yes, with each level that a person creates they allow or disallow certain functions and abilities. The multi-player levels have much more common ground than the learner levels.

I would definitely recommend the more advanced levels if you are an experienced programmer. That and creating your own basic level, this will help you understand what goes into the levels and the variance between levels. (The editor is not super intuitive though, so be patient with it!)