Author Topic: Embryonic online galaxy viewer  (Read 5048 times)

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Embryonic online galaxy viewer
« on: June 06, 2013, 09:10:10 am »
Got a tangled up galaxy map and you wish you could drag around the planets and that they would move around on their own?

Is it a spokes map?
http://www.cmears.id.au:8000/view/ef45e3676952e235bba983c1733bfd3a

Lattice?
http://www.cmears.id.au:8000/view/abe8d86ffe6fb9db3aa1abc376552d58

Crosshatch?
http://www.cmears.id.au:8000/view/bde1a7b907e3e8ffe680322a18a5c6ea

Concentric?
http://www.cmears.id.au:8000/view/60a428103c01fbb0c503c159c69c4abe

(concentric doesn't work so well)

Click the only button on the page! Drag the planets around!

Want to upload your own save game?
http://www.cmears.id.au:8000/
(only UNCOMPRESSED saves will work!)

No warranty of usefulness, reliability, etc. Click at your own risk. :)

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #1 on: June 06, 2013, 09:31:26 am »
That is ludicrously awesome :)  Seeing it in motion is particularly impressive, really gives it an illusion of 3D, etc.

Do you need anything else on the technical side for handling compressed saves, or for writing the save back out with adjusted positions?  For the latter it'd probably be better to just do some replaces on the original strings (just changing the location fields) so the "reserialization" doesn't break every time I add a new field somewhere, etc.

Of course, the actual coordinate system that works in the game is a little tricky in that it's really quite small.  Untangling a graph is one thing, untangling it into something fitting within a defined width and height is rather another.

Anyway, congratulations :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Qatu

  • Full Member
  • ***
  • Posts: 139
Re: Embryonic online galaxy viewer
« Reply #2 on: June 06, 2013, 09:34:34 am »
a+++ , would push buttons again

Offline Mick

  • Hero Member Mark II
  • *****
  • Posts: 911
Re: Embryonic online galaxy viewer
« Reply #3 on: June 06, 2013, 10:10:20 am »
This is amazing.

Now... how hard would it be to get this into the game itself?  :D

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #4 on: June 06, 2013, 10:14:49 am »
This is amazing.

Now... how hard would it be to get this into the game itself?  :D
Actually probably not very hard, if I had the code.  I just looked at the .js file but it looked like it was generated by something that put it all on 4 or 5 lines, so not particularly intelligble :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline LaughingThesaurus

  • Master Member Mark II
  • *****
  • Posts: 1,723
Re: Embryonic online galaxy viewer
« Reply #5 on: June 06, 2013, 04:15:58 pm »
I'd love to have this in-game as some kind of 'disentangle galaxy' function when you alt/rightmouse on the galaxy view screen.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #6 on: June 06, 2013, 04:20:00 pm »
I'd love to have this in-game as some kind of 'disentangle galaxy' function when you alt/rightmouse on the galaxy view screen.
That would be a good place to put it, yes.  Though I'd probably have some of the map types (spokes, snake, tree, etc) just run it automatically after mapgen before showing the map in the lobby.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline LaughingThesaurus

  • Master Member Mark II
  • *****
  • Posts: 1,723
Re: Embryonic online galaxy viewer
« Reply #7 on: June 06, 2013, 04:29:03 pm »
Yeah, true enough. The really messy ones should probably just use it automatically. I was thinking along the lines of maps like concentric or mazes that I would rather keep their neat default shapes.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #8 on: June 06, 2013, 04:30:07 pm »
Yeah, true enough. The really messy ones should probably just use it automatically. I was thinking along the lines of maps like concentric or mazes that I would rather keep their neat default shapes.
Right, those map types are designed to be planar (or very close to it) and drawn without overlap.  Largely because we didn't want to deal with untangling :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline LaughingThesaurus

  • Master Member Mark II
  • *****
  • Posts: 1,723
Re: Embryonic online galaxy viewer
« Reply #9 on: June 06, 2013, 04:33:28 pm »
This is going to be such a cool update if you can get this working then. I'll be able to play on spokes and tree and stuff without having to bend my mind around not only how to beat the AI but how to understand the map. But, Snake never really worked out to be that bad to me, and there are only really two ways to go on snake anyway. ;)

Offline Aklyon

  • Core Member
  • *****
  • Posts: 2,089
Re: Embryonic online galaxy viewer
« Reply #10 on: June 06, 2013, 05:11:18 pm »
This is awesome. Reminds me of boxcar2d in how stuff can bounce around.

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Embryonic online galaxy viewer
« Reply #11 on: June 07, 2013, 06:19:56 am »
Thanks to everyone who tried it out; I hope you enjoyed dragging the circles around.

I should point out that the layout itself is not my own work. It's done by the force layout module of d3.js (https://github.com/mbostock/d3/wiki/Force-Layout). In particular, I based it on the example here: http://bl.ocks.org/mbostock/950642.

Thanks again to Keith for offering even more help. I think I know how to handle the compressed saves, and how to rewrite the coordinates safely too. I'd have to change the layout slightly to make sure they fit in the game's permitted rectangle, which might not be so easy.

I do have a couple of questions:
  • The in-planet locations of wormholes are not in the save file? It seems like instead the map's seed is stored, and then the wormhole locations are regenerated on loading.
  • Is it the same for metals and crystals? If not their locations, is the number of metal/crystal deposits on a planet recorded anywhere in the save?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #12 on: June 07, 2013, 09:22:22 am »
Thanks to everyone who tried it out; I hope you enjoyed dragging the circles around.

I should point out that the layout itself is not my own work. It's done by the force layout module of d3.js (https://github.com/mbostock/d3/wiki/Force-Layout). In particular, I based it on the example here: http://bl.ocks.org/mbostock/950642.

Thanks again to Keith for offering even more help. I think I know how to handle the compressed saves, and how to rewrite the coordinates safely too. I'd have to change the layout slightly to make sure they fit in the game's permitted rectangle, which might not be so easy.
Well, not to short-circuit your experiment here, but it would actually be great if I could get a usable version of the code involved and just have the game do this either automatically for some map types, or on-demand for others.  Not that we have to do it that way, but it seems like the most convenient way for players to benefit from it :)

That said, if you're able to figure out the "stay within rectangle X,Y,W,H" part first that wouldn't be bad.

I poked around the D3 pages you linked and didn't see anything about licensing, is it GPL, LGPL, Public Domain, or what?  Or is there some general policy for GitHub stuff (I haven't checked)?  To the point: are they ok with me rewriting the relevant bits into C# for use in an existing commercial game?  Any conditions on that?

Quote
I do have a couple of questions:
  • The in-planet locations of wormholes are not in the save file? It seems like instead the map's seed is stored, and then the wormhole locations are regenerated on loading.
  • Is it the same for metals and crystals? If not their locations, is the number of metal/crystal deposits on a planet recorded anywhere in the save?
The metal and crystal and wormhole spots are indeed regenerated on load.  This can actually lead to them moving or changing in number if I change certain things in mapgen.  Though I think wormholes tend to not move nowadays even when I do that.  But I can't find any reason in the code for them not to do so ;)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Embryonic online galaxy viewer
« Reply #13 on: June 07, 2013, 09:23:07 pm »
It would be very convenient to have this sort of thing in the game! Hidden in the bottom corner of the d3 page (http://d3js.org/) it says it is BSD licensed. Even if that license is not suitable, implementing a force-directed layout from scratch is not so hard --- and you might have to fiddle so much with an existing implementation that the amount of work is similar anyway.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Embryonic online galaxy viewer
« Reply #14 on: June 07, 2013, 09:33:53 pm »
It would be very convenient to have this sort of thing in the game! Hidden in the bottom corner of the d3 page (http://d3js.org/) it says it is BSD licensed. Even if that license is not suitable, implementing a force-directed layout from scratch is not so hard --- and you might have to fiddle so much with an existing implementation that the amount of work is similar anyway.
The BSD license is quite accommodating, actually (the 3-clause one in use here). I think all I have to do is include the license in our own eula file though I may check up some more on that.  We do something similar with Michael Lidgren's networking library (which is wonderful).

As for fiddling, I think it will be substantially less work to rewrite their structure in c# syntax than to figure out a programmatic implementation of the force approach myself.

Anyway, thanks for the pointers on this :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!