- Part 1: introduction
- Part 2: debugging tools
- Part 3: interacting with the game
- Part 4: under the hood
The previous post introduced the Lua scripting framework that lets you program your own Powargrid AI. Now, I'd like to show you the debugging tools we're providing you with. Nobody said this was going to be easy, but we're not sending you in without a little help! You can edit your AI in whatever text editor you like. I like Sublime Text, but the choice is yours! Just get yourself something that has a bit more features than plain ol' Notepad :) Debug Console It's the most basic method of debugging, but it's never let me down: print stuff to the screen. Your AI can write messages to the AI debug console, which is visible if you've checked the "Enable dev tools" box in the Add-ons menu. Simple "print" statements will go there. If you want to get fancy, you can use the Debug.info, Debug.warning and Debug.error functions to write text in different colors according to how urgent a message is. Another important feature is the reload button: you can edit and reload your AI scripts whenever you want, and the changes will take effect on the next turn. MoonSharp debugger We use the MoonSharp Lua interpreter to run user AI scripts. It comes with a pretty decent debugger, which runs in your browser. To open the debugger, hit the "Open debugger" button in the AI console. Your browser should open automatically - if not, just browse to http://127.0.0.1:2705/. The debugger will pause your script at the start of the turn() function, and you can step through the code, set breakpoints and watch variables. Now how do you actually interact with the game? Build stuff and blow things up? We'll cover that in the next post!
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
AuthorWe're Michiel and Willem. Hi! Archives
June 2017
Categories |