Introducing the SpringRTS kernel

Introducing the SpringRTS kernel

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Introducing the SpringRTS kernel

Post by gajop »

Hello everyone!
In the past few days I have been making a SpringRTS IPython kernel for the Jupyter notebook.
Jupyter notebook is a very popular tool for datascience and teaching, and many of you may already be familiar with it.
I've now made it work with SpringRTS and I feel this can help speed up development greatly.

To begin checkout these things:
- The github repository: https://github.com/gajop/spring_kernel/
- Youtube guide to setting it up and running it: https://www.youtube.com/watch?v=wXigmhrm52k
- Example notebook https://github.com/gajop/spring_kernel/ ... rial.ipynb (takes a few moments to load)

Happy coding!
raaar
Metal Factions Developer
Posts: 1094
Joined: 20 Feb 2010, 12:17

Re: Introducing the SpringRTS kernel

Post by raaar »

Thanks

So this is a context where we can run spring and then do real-time changes to the luaui, edit variables and capture screenshots?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

So this is a context where we can run spring and then do real-time changes to the luaui, edit variables and capture screenshots?
LuaUI, LuaMenu and synced/unsynced LuaRules. I suppose I could add it to LuaGaia as well if there's interest, but I figure the current ones are what really matters.

The point of this is that you can run arbitrary code without having to restart Spring/recreate the situation, all the while it's displayed nicely within a notebook, making it easy to experiment and prototype.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Introducing the SpringRTS kernel

Post by AF »

This looks very useful
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Introducing the SpringRTS kernel

Post by smoth »

forgive me but what is this?
[last]Butters
Posts: 15
Joined: 10 Aug 2014, 20:32

Re: Introducing the SpringRTS kernel

Post by [last]Butters »

Is this tool for devs?

Is this Spring rewrite in Python/IPython? What is Spring Kernel?
(sry, this might be noob questions, but anyway))
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

smoth wrote:forgive me but what is this?
More superpowers for me! viewtopic.php?f=9&t=35912&p=581509#p581509
[last]Butters wrote:Is this tool for devs?

Is this Spring rewrite in Python/IPython? What is Spring Kernel?
(sry, this might be noob questions, but anyway))
Yes it's a tool for devs.
No it's not a Spring rewrite. The python element is there to interface with Jupyter (IPython) Notebook and Spring (engine).
The "Kernel" part is what is used to execute Lua code.

Check this image: http://jupyter.readthedocs.io/en/latest ... onents.png
I've developed the "Kernel" part and interfaced it with Spring. So in my case you would have another box called "Spring" that runs the Lua part of the kernel (which is in charge of code execution) and sends the results back to the Python Kernel.
Essentially you have something like this:
User->Browser->Jupyter Server->Spring Kernel(Python)->Spring Kernel(Lua)
And it is a bit more complicated as we have multiple Lua states as well. 90% of code is just messaging.
I chose not to implement the entire Kernel as a Spring Lua widget/gadget as that would introduce complicated networking and message passing that the existing Python kernel takes care for me.
[last]Butters
Posts: 15
Joined: 10 Aug 2014, 20:32

Re: Introducing the SpringRTS kernel

Post by [last]Butters »

So is it like Python interface to Lua interface to Spring? =)
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

No. Python is just the implementation program for messaging passing. It's really just regular Spring Lua code.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Introducing the SpringRTS kernel

Post by AF »

Jupyter lets you write up notebooks that contain code that runs. E.g. you can include a data set then tell it to print out a lot of graphs and it will go away and do all the necessary work. You can write python directly in the doc and transform the results and do some basic data science and analysis, draw correlations, interactive stuff, etc

It's very powerful, and this project allows the notebook to reference a running Spring Engine instance, as well as make changes and run Lua code. For example, with this you could plot the firepower of various units, or their cost across a spectrum, graph build trees, plot images of maps by their gradients or accessibility, etc
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

Yes, it's used often in datascience and explorative data science is certainly one thing it's pretty good at.
However it's not something I expect this to be good at as it is mostly pure Spring Lua and I don't think it would be worth for me to spend time implementing a powerful plotting library. If there's a lot of data to process I think it might be better to save it to a file and use a Python/R kernel instead.

Currently this is most useful for early function prototyping and testing. I tend to create new functions in it, test them out fully in the notebook and once I'm satisfied it works I copy them into existing Lua script files.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Introducing the SpringRTS kernel

Post by smoth »

can windoze users utilize this?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

I suppose they can, but I haven't tried. Installation is very simple so it shouldn't take much effort to try.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Introducing the SpringRTS kernel

Post by AF »

I'd suggest using Anaconda to install Jupyter, which has a windows installer. The rest is primarily python, so in theory it should all be doable

https://www.continuum.io/downloads

My understanding is that Jupyter already has some plotting stuff, it just needs a data source, which you've provided
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Introducing the SpringRTS kernel

Post by gajop »

I think you're confusing things. It's iPython with these abilities (along with matplotlib and %matplotlib inline magic to embed the plots), and not the Jupyter server, which just allows you to execute arbitrary code.
fwiw, I'm using Jupyter daily for data science so this isn't an uninformed guess.
Anaconda can be good if you're also doing data science, but I think it might be an overcomplication in this case, as you still need to install my kernel with pip. I'd recommend a simple virtualenv + pip install for everything.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Introducing the SpringRTS kernel

Post by AF »

Ah, when I tried using it I was directed towards Anaconda and similar as it was easier to get up and running quickly
Post Reply

Return to “Game Development”