Can we debug the code with hero.say in new multiplayer like Mages Might?

I notice that many new multiplayer modes does not have hero.say() in the method banks despite that the description in one of those method does mention hero.say(). It is very helpful to debug the code with something like this! Otherwise, it is like driving in the dark.

Is hero.say() is intentionally removed in these modes? If yes, how should we debug our code?

A great application of experimenting to see if it works! In this case, hero.say does not appear to function in Mages’ Might. This is where each language’s native logging function comes in.

console.log is JavaScript’s standard way of logging information, print is the standard for python.

CodeCombat provides both functions for both languages, but it’s probably best to stick to the language specific output — most interpreters do not. I have not tested either function in other languages on CodeCombat.

The output will be sent to the browser’s console (there are plenty of online resources to help you find it), and will unfortunately be buried among plenty of other messages, but the information is there.

Keep in mind to prevent console spam CodeCombat will limit the number of debug messages to 200; if it does so, you will see the message “Log limit 200 reached; shutting up.”

console.log("My debug message")
print("My debug message")

4 Likes

Oh I didn’t realize that we can debug through the console. This is very helpful. Thanks!

1 Like