GSim 0.32

What did you draw?
Post Reply
User avatar
Site Admin
Posts: 1140
Joined: Mon Nov 19, 2012 7:54 pm

GSim 0.32

Post by testtubegames » Thu Aug 11, 2016 4:43 pm

I just wrapped up a big update to the Gravity Simulator, trying to hit most of the bugs / feature requests we had listed. I'm pretty happy with how it's looking and performing.

You can grab the update from Humble, or if you don't have the full version yet (?!) you can get it here.

Version 0.32

Wow. So much. Where to start?

(Pretty Planets!)
-There are image categories that you can load in the sim. There's the default, vanilla one, or there's others to try out, like a realistic set of images based on the planets in our solar system
-The planet images are completely mod-able. You'll find them in the data folder for the sim, and you can change / replace / add to them. Make your own categories, bring in your own images (maybe make a solar system with your face as the star?), whatever!
-There are more colors to choose from. Namely, all the colors. There's about 16 default colors, but you can change them or add to them at will with the new color picker.
-In addition to changing the color, you can change the image of an object
-You can increase the (visual) size of all the planets by a multiplier value if you'd like
-There's a mode where you can make the colors of the planets be based on their mass

-Finite trails are back
-You can turn trails on and off for individual objects
-You can change the color of trails independently from the color of the objects
-You can change the width of the trails

-You can change the color of the background / grid / UI / text.
-There's a new feature that writes out the world coordinates of your mouse for you

(Pictures / GIFs)
-There's a new menu that lets you take screenshots and GIFs of the simulator easily, and it's saved to your disk (in the data folder)

(Editing Planets)
-Before, you always picked from Fixed Star, Star, Planet, Asteroid, and Dust. Well, now, the menu of objects you pick from to add is completely customizable. Add in more types, make an object type massless or massive, make it feel or ignore gravity, change its image, etc.
-You can even set an object in that menu to 'random' colors and just spam the world with confetti.
-The editor for changing an existing planet has many more features, too.
-You can now edit the position / velocity of an existing planet using your mouse.
-Massless objects now have a 'radius' value, which lets you define what size they should be.
-'Comment' system is now hacked in. Simply add in a planet with (a) a name, (b) m=0, so it doesn't affect anything, (c) make it ignore gravity if you don't want it to move, (d) you can even make it invisible, so you just see the text.
-If you select two objects, the menu will tell you their distance and force (this is a quick-and-easy way to have a 'ruler')

(Save Codes)
-You can save a history from t=0 (like before), or just save where everything is at a certain time.
-The code syntax has completely changed. My goal was to make it more readable and more powerful.
-Each line of the save-code now represents either (a) the general settings, (b) the properties of a *type* of planet, or (c) an object or group of objects you're adding
-You can not only add in single bodies... but now you can add lines, circles, and disks of planets in a single line! You want to add a circle of planets that is expanding outward and moving with vx=2? Do it! Want to make a disk with 5000 planets and see if your computer can handle it? Rad!
-Fixed the problem of merging planets. Now, even if planets have merged, the save codes will be accurate.
-The save files automatically copy into text files in the data folder of the simulator. You can copy paste from there, if you'd like. (Though note it only *imports* them when you start up the simulator... so beware of your changes getting overwritten while the simulator is running)

(Quick Saves)
-You can 'quick save' a state with a new button I added, then 'quick load' it whenever you'd like. This would help if you wanted to quickly run an experiment several times.
-There's also a rewind button that moves the simulation back ~50 units of time. (Different from just setting the simulation to having negative time, since this is really replicating the old state... orbit lines included)
-You can also press control-z to undo your last change to the sim. (Undo an added planet, for instance)

(Nuts and Bolts)
-Various optimizations (planets are much more lightweight)
-Moar Zooming! You can now zoom in from x.01 to x100 (instead of just x.2 to x5)
-Collision animations are improved (a bit better looking, and also in the right place now)
-You can right-click on buttons
-Your settings are saved between sessions
-Menus now fade if you don't move your mouse


Okay, I think that about covers it. Suffice it to say, it's been a lot of changes. So give it a try, see if you can figure out all the new features, and, as always, feedback / comments / requests welcome!

To Do:
-Better SFX
-Update the web version to match

-More Science Equipment (protractor, etc)

(Sim Additions / Overlays)
-Polar Grid, Apsis view, eclipses (viewtopic.php?f=7&t=156&start=140#p2937)
-Inertial Mass != Gravitational Mass? (viewtopic.php?f=7&t=156&start=160#p3281)

(Under Discussion)
-Changing Newton's Laws (viewtopic.php?f=7&t=156&start=160#p3281)
-Use dr/dt as a variable in force law (viewtopic.php?f=7&t=156&start=170#p3455)

Edited: 8/11

User avatar
Site Admin
Posts: 1140
Joined: Mon Nov 19, 2012 7:54 pm

Re: GSim 0.32

Post by testtubegames » Thu Aug 11, 2016 9:19 pm

A little bit about the new save codes.

-First up (and importantly) the *old* style of code will still work in the new simulator. There may be a couple color changes and whatnot, but any of the older codes from the forums here should run fine.

Okay, an example:

Code: Select all

//Gravity fun at TestTubeGames
_settings(gravity: r^(-2), zoom: 0.7084251);
_type0(m: 1000, col: 2, lcol: 3, pic: 0, noGrav);
_type1(m: 0, col: 1, lcol: 3, pic: 2);
_add(type: 0, x: -51.7, y: 17.37, t: 0);
_add(type: 0, x: 74.64, y: 20.12, t: 11.6);
_add(type: 0, x: 9.93, y: 102.62, t: 25.6);
_add(type: 1, x: -6.23, y: 57.37, a: 17, t: 48);
_add(type: 1, x: 24.35, y: 38.45, a: 235, t: 71.2);
_add(type: 1, x: -3.8, y: 29.47, a: 136, t: 84.4);
The settings line comes first, and contains the force law(s), zoom, etc. If any of the variables are missing it will just revert to that variable's default (the same goes for all the variables in the save code). The variables you can post in settings:

Code: Select all

gravity: <written out force law, default is r^-2>,
tangravity: <written out tangential force law, default is 0>,
x: <offset of the world, default is 0>,
y: <offset of the world, default is 0>,
zoom: <default is 1>
After that, there's a list of the planet types. These contain info that's generally shared by a whole bunch of objects. This way, when you spam a whole bunch of blue planets with mass = 100, the save code just has to write all that info once. The variables you can post in type:

Code: Select all

m: <mass, default is 0>,
col: <the color of the object, based on an indexed list, default is 0>,
lcol: <the color of the trail, based on an indexed list, default is 0>,
pic: <image type>,
rObj: <radius of the planet, used if it is massless. Default is 3>,
d: <density of the planet, used if it is massive.  Default is .3>,
noGrav <included if the object is fixed and ignores gravity. No value / colon needed>,
textSize: <the size of the object's text, default is 30>
The types, I'll note, are optional. If you'd rather, you can wrap any/all of this information into the codes for the individual objects themselves. If a variable is included for both, the individual-info overwrites the type-info.

Once that's locked down, the objects themselves follow. Depending on the prefix, different objects get added. The default "_add" just throws in a single object. The variables:

Code: Select all

name: <a written name that appears on screen. defaults to blank>,
type: <which type's properties this inherits>,
x: <the x position>,
y: <the y position>,
vx: <the x velocity>,
vy: <the y velocity>,
a: <the angle of the object, defaults to 0>,
rotspeed: <the rotational speed of the object in degrees per unit time, defaults to 0>,
t: <the world time that this object appears, defaults to 0>,
...and any of the variables from 'type'
You can add cool new sets of objects as well (woo!). There are lines, circles, and disks of planets. To add them:

Code: Select all

name: <>, type: <>, 
xMin: <the x-coordinate of one endpoint>, 
xMax: <the x-coordinate of the other endpoint>,
yMin: <the y-coordinate of one endpoint>,
yMax: <the y-coordinate of the other endpoint>,
vx:<>, vy:<>,
vt: <the tangential velocity of the line, so the whole line spins about its midpoint>,
vr: <the radial velocity, from the center of the line>,
num: <the number of planets>, 
randomColors <if included, this randomizes  the colors. No value / colon needed>,
randomAngles <if included, this randomizes the angles. No value / colon needed>,
t: <>,
...and any of the variables from 'type'

Code: Select all

name: <>, type: <>, x:<>, y:<>, vx:<>, vy:<>, vt:<>, vr:<>,
r: <radius of circle>,
num: <>, randomColors, randomAngles, t:<>

Code: Select all

name: <>, type: <>, x:<>, y:<>, vx:<>, vy:<>, vt:<>, vr:<>,
mMin: <optional, masses set randomly with this as min>,
mMax: <optional, masses set randomly with this as max>,
rMin: <minimum radius from center, defaults to 0>,
rMax: <maximum radius from center, defaults to 250>,
num: <>,
seed: <a random number generator seed that defines the disk.  That way we can share!>,
...and any of the variables from 'type'

Posts: 1
Joined: Fri Aug 12, 2016 9:26 am

Re: GSim 0.32

Post by Wifaffle! » Fri Aug 12, 2016 9:28 am

Looks Amazing! :D :H :D

Posts: 1
Joined: Tue Aug 23, 2016 5:56 am

Re: GSim 0.32

Post by Maxi480 » Tue Aug 23, 2016 8:17 am

-If you select two objects, the menu will tell you their distance and force (this is a quick-and-easy way to have a 'ruler')
Please list shortcuts in GSim and make them editable. (Found out shift for selecting objects.)

Bug report:
  • It's hard to change calcs per frame, because sometimes I can't scroll down.
  • The biggest planet disappears in the code "Massive Disk" after it turned into a black hole. test settings: c=20; barnes-hut on
    With barnes-hut off i got no problems
  • Is that normal?: If an object m=100, falls into a black hole m=1000, the resulting mass is bigger than 1100, also the velocity changes with start-velocity=0.
  • What can I do with the mode "Lagrange"? I can't see any lagrange points.

User avatar
Site Admin
Posts: 1140
Joined: Mon Nov 19, 2012 7:54 pm

Re: GSim 0.32

Post by testtubegames » Tue Aug 23, 2016 10:37 pm

Wifaffle! wrote:Looks Amazing! :D :H :D
Maxi480 wrote:Please list shortcuts in GSim and make them editable. (Found out shift for selecting objects.)
Oh wow, yes - that totally slipped through the cracks. In the meantime, here are some (all?) of the shortcuts:

-WASD or Arrows to move around
-'+' and '-' to zoom in and out
-Hold F to auto-fire an object
-Hold C while aiming an object to put it in a circular orbit around the nearest mass
-Right click acts as a cursor (selecting objects, moving the screen)
-Hold shift to select and edit multiple planets
-Ctrl-Z undoes the latest planet you've added
-Ctrl-R rewinds time a bit
-E caches a quick-save
-Q loads a quick-save
-0-9 changes what type of object you're adding
-Backspace/Delete removes the selected object(s)
-Space toggles pause
-Escape takes you to the main menu, hit escape again, and you quit the sim

As for the bug reports

-I'll fix the dropdown menus so they all fit on the screen, and
-Huh, that's interesting about the massive disk + general relativity. What's happening is actually connected to your other question. Namely, in the sim (with GR active), when two objects collide, according to relativity, some of the kinetic energy gets converted into mass. I think there's a bug floating around this part of the sim, so I want to take a close look at what's going on when objects merge with GR on. (It may well be connect to the conservation of momentum issue). For the massive disk, the black hole isn't disappearing, it's actually just so big it takes up the whole screen.

There's a problem somewhere with this, though, since, as you say, when you turn barnes-hut off, the final black hole is nowhere near as big. I can't imagine that change in the quality setting should lead to *such* a huge difference in the final mass of the black hole, so, again, I think this is likely pointing at a bug. Thanks for passing that along, it gives me a good lead.

-The Lagrange Mode fixes both objects you've selected in place on the screen (well, it fixes one, 'the star', and then keeps 'the planet' at the same on-screen angle relative to it, by moving to a rotating reference frame). That way you can try to find the lagrange points yourself, by adding objects and seeing what stays still / where objects collect. But I do like the idea of actually drawing the lagrange points in, that mode would make a lot more sense then.

Thanks for the feedback, I'll aim to get the bug fixes posted soon!

Post Reply