Powargrid
  • Home
  • Blog
  • Buy
  • Demo
  • Media
  • Press
  • The Daily Blobbie
  • Blobbie Meme Maker
  • Forums

AI scripting interface: debugging tools

25/9/2016

0 Comments

 
  • 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.
Picture

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.
Picture
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.

    Author

    We're Michiel and Willem. Hi!
    This blog is about the development of Powargrid and our experiences in doing so.

    Archives

    June 2017
    May 2017
    November 2016
    October 2016
    September 2016
    July 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    March 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    September 2012
    August 2012

    Categories

    All
    Game Design
    Marketing
    Progress
    Slacking
    Tech

    RSS Feed

© Wee Free Studio | Steam | Twitter | Facebook | RSS feed | Press | Contact