Jump to content

  • Log In with Google      Sign In   
  • Create Account

Crawling with ideas

World in 7 days, Days 2, 3 and 4: Stars and planetary systems

Posted by , in worldin7days 27 February 2014 - - - - - - · 749 views
worldin7days, programming, unity and 2 more...
I haven't updated in long time but this doesn't mean I haven't worked. In fact, I am splitting my work hours between this project and GAMIFICATOR™ ;) and I'm now on day 4 of making world.

Currently my galaxy can hold up to 5.4 * 10^13 stars (that's a lot). You can check out the most current version HERE (click me), the seed is set so no voice-created universes for you. The interface is clunky, sometimes it gets stuck (reload if that happens), and sometimes it generates gas giants next to the sun, with couple dozen earth sizes in diameter, and a fraction of its mass. But we're not here to nitpick, are we? We're here to generate UNIVERSES Posted Image.

So, let's do a writeup of what has happened so far (with sprinkle of pretty pictures):

What I had previously was looking pretty, but ultimately doomed to fail, as it had no level of detail progression. Which means I was limited by the amount of stars in the galaxy. Bad thing. I've started working on it, and had some pretty funky results:

Posted Image

Finally I have created really nifty looking galaxy:

Posted Image

That's more like it, but still not good enough. I needed to walk away from prettyfying, and move back towards optimisation, to allow the amount of stars that I wanted (granted, this galaxy would be more than enough for what one person can experience). So I've started implementing octree. It took me majority of Day 2, and I was left with something that visualised to this:

Posted Image

Ooh, pretty colours. Still, it didn't feel right. On third day I sat with my good friend Theo, and implemented non-persistent node implementation, that created node ID based on its location and depth, and created seed out of that. This allowed for repeatable generation of data without the need to store the data structure. The seed code looks like this:
    void FillOutNode(int x, int y, int z, int depth)
        ulong mask = 0xffffffffful << (nodeDepth - depth);

        float minX = (float)((ulong)x & mask);
        float minY = (float)((ulong)y & mask);
	float minZ = (float)((ulong)z & mask);

	float length = 1 << (nodeDepth - depth);
        ulong nodeID = FindNodeIDBin (x, y, z, depth);
        int currentSeed = nodeID.GetHashCode() + universeSeed.GetHashCode();
        Random.seed = currentSeed;
    ulong FindNodeIDBin(int x, int y, int z, int depth)
		ulong mask = 0xffffffffful << (nodeDepth - depth);
		return ((ulong)depth << 36) | (((ulong)x & mask) << 24) | (((ulong)y & mask) << 12) | (((ulong)z & mask) << 0);
Neat, eh? Well, this gave me neat spatial partitioning:

Posted Image

Rest of the day was spent on adding space navigation (ooh sexy starjump code) and starting to add proper star data generation, which continued into day four:


And on day four I've added planet generation:


Well, that's what I have so far, going into day 5, on which I'll focus on moving into planetary system mode. So far the problem is following: To allow for enough precision, I had to position the stars at pretty close locations. Going into planetary system will mean that the precision will need to be insanely higher (if we're to allow, say, visiting planets, which is the goal of this whole exercise). Smooth transitioning between different speeds will be interesting, but I think I can make it. That means also displaying of the planets and sun, which will also be fun ;).

I'll also want to do an update on GAMIFICATOR© some time before the end of the week, but don't know if I'll have time to do it. I reserved time on Sunday and Tuesday evenings for it, so that progression doesn't stop. So far so good http://public.gamedev5.net//public/style_emoticons/default/smile.png. The GAMIFICATOR (patent pending) started as a tool to help me become productive, and I've spent more time polishing it and being productive on it than with any other recent projects. I guess it's serving its purpose even before it's finished ;).

So, again, I hope I'll find some time to develop some more.

See you then!

Story so far:

Days 2, 3 and 4: Stars and planetary systems
Day 1: Galaxies


Posted by , in Programming, gamification, iphone 09 February 2014 - - - - - - · 968 views
iphone, iOS, programming, fun and 2 more...
Quick break from World making. Normal service will resume shortly.

So, as I looked at my life and noticed that I'm not getting ridiculously rich fast enough, I decided that I need to do something with it. I am going to gym, I study new things a lot (lately bioinformatics, astronomy, and cryptography, MOOCs are fun!), I help my friend with his project. But I wanted to do something to keep me motivated.

Enter gamification.

If you're not sure what that is, quick disclaimer, in my own words: It's using game stuff to make otherwise boring tasks fun. As you clean your dishes, you get experience points, when you get enough xp you level up! You may hate doing dishes, but being Level 41 Dirt Obliterator feels just cool, so you'll want to work just a bit more.

I decided to write a generic iOS/Android app that I could run on my phone, and level up in it. I took level up mechanics from Dungeons and Dragons, as they worked to get them solid way better than I ever could. This started as a really simple application just for myself with one screen, done in 30 minutes, but ended up as a bigger project. One that I'll upload to AppStore/Android Market even (for free), as soon as I'll make it pretty and robust enough (my girl is helping with art still, woo). So, without further ado, the mechanics:

1. Encounters

Each monster/group of monsters of strength equal roughly to yours that you meet while traveling is an encounter worth
300 * level
experience points. I chose to assume each week counts as an encounter of your current level. At first you set your goals, say you want:
  • 3 gym sessions
  • 1 studying session
  • 1 working on project session
each week. You add those, and then the experience points is divided equally between each session. If you get all or more of those, you get points assigned, for each one in each session type you miss, you get penalised. Each session type may have following kind:
  • Sport
  • Education
  • Work/projects
  • Food
  • Art
  • Entertainment
  • Social
2. Levels

Levels in D&D (and thus in my app) are calculated with the following formula:
XPrequired = 1000 * (level + Combinatorial(level, 2));
So the required XP for levels are 0 for level 1, 1000 for level 2, 3000 for level 3, 6000 for level 4, etc. You look at your current XP and let the math figure out which level are you.

And the overview screen looks something like this:

Posted Image
It's not very pretty, but I need it done for tomorrow, when I'm at gym, so that I can start levelling up Posted Image. According to my guesstimate (too lazy to calculate), it should be more than one year of training to reach level 20, which is when you're Epic Character in D&D standards, and after more than one year of sticking to the work, in mine as well.
Here's a quick video of the application working:

Obviously the app needs some work done before I can release it to people (because even free apps should be of SOME standard), but I really hope that you like the idea. Will be back this week with more World In 7 Days, because I've added that to my Gamificator, so now there's no escape ;).

See you then!

February 2014 »