Skip to main content

News

Recent Posts

1
Engine Development / Re: Oozaru: Sphere for the Web
Last post by Eggbertx -
What kind of functions do you have in mind?


One thing I can think of is accelerometer support. You see it in use in stuff like racing games, where your phone becomes a steering wheel, or even just simple stuff like Pokémon GO, where putting the phone upside down will turn the screen black to save performance.
Stuff like this, or handling swiping. Though I guess it would technically be possible for a game to do that, but a runtime ES6 helper module would be nice.
2
Engine Development / Re: Oozaru: Sphere for the Web
Last post by DaVince -
What kind of functions do you have in mind?
One thing I can think of is accelerometer support. You see it in use in stuff like racing games, where your phone becomes a steering wheel, or even just simple stuff like Pokémon GO, where putting the phone upside down will turn the screen black to save performance.

I imagine that Oozaru will be able to do more anyway, if we can have access to the JS DOM API.
3
Engine Development / Re: miniSphere 5.3b2 (stable: 5.2.13)
Last post by Fat Cerberus -
miniSphere 5.3 release is very close - just a few more API kinks I have to work out but otherwise everything is ready to go.

I even made a last-minute API addition: you'll be able to create custom BlendOps to have better control over the blending stage of the graphics pipeline.  This is something that can't be handled in the fragment shader at all--blending is still fixed-function even on modern hardware.
4
Engine Development / Re: miniSphere 5.3b1 (stable: 5.2.13)
Last post by Radnen -
I'm still baffled the widespread popularity of lodash... when libraries you and I write can be an order of magnitude faster, and any missing convenience methods lodash has, can always be added.

Anyways, I didn't have from.js on me, but I ran your parameters on my new Linkier library along with lazy and Link and got:
Code: ('js') [Select]
const Linkier = require('./linkier.js');
const Link = require('./modules/link.js');
const Lazy = require('./modules/lazy.js');
const Benchmark = require('benchmark');

// Generate a random list of 100,000 integer between 0 and 1,000.
const items = [];
for (let i = 0; i < 100000; ++i) {
    items[i] = Math.floor(Math.random() * 1001);
}

const suite = new Benchmark.Suite;
const linkier = Linkier(items).filter(n => n % 2 === 0).take(10000).map(n => n + 1);
const link = Link(items).filter(n => n % 2 === 0).take(10000).map(n => n + 1);
const lazy = Lazy(items).filter(n => n % 2 === 0).take(10000).map(n => n + 1);

suite.add('Linkier', function() {
    linkier.reduce((a, n) => a + n, 0);
}).add('Link', function() {
    link.reduce((a, n) => a + n, 0);
}).add('Lazy', function() {
    lazy.reduce((a, n) => a + n, 0);
}).add('For Loop', function() {
    let n = 0;
    let r = 0;
    for (let i = 0; i < items.length; ++i) {
        if (items[i] % 2 === 0) {
            n++;
            if (n <= 10000) {
                const m = items[i] + 1;
                r = r + m;
            }
        }
    }
}).add('For Loop 2', function() {
    let n = 0;
    let r = 0;
    for (let i = 0; i < items.length; ++i) {
        if (items[i] % 2 === 0) {
            n++;
            if (n <= 10000) {
                const m = items[i] + 1;
                r = r + m;
            } else {
                break;
            }
        }
    }
}).on('cycle', (event) => {
    console.log(String(event.target));
}).on('complete', function() {
    console.log('Fastest is: ' + this.filter('fastest').map('name'));
}).run({ async: true });

Code: [Select]
Linkier x 4,242 ops/sec ±5.49% (78 runs sampled)
Link x 3,786 ops/sec ±2.13% (91 runs sampled)
Lazy x 2,917 ops/sec ±2.87% (91 runs sampled)
For Loop x 2,213 ops/sec ±2.01% (96 runs sampled)
For Loop 2 x 11,052 ops/sec ±1.52% (97 runs sampled)
Fastest is: For Loop 2

What we learn here, is that hand-writing a for loop can be slower... The first for loop doesn't short circuit after 10,000 items, but that's on intention. How many times in writing a for loop you think of doing that? Therefore from.js, link.js and other libraries are going to be faster since they can make those common-sense decisions for you, and just automatically make your code faster.
5
Engine Development / Re: miniSphere 5.3b1 (stable: 5.2.13)
Last post by Fat Cerberus -
So when I said above that from queries would be blazing fast, I meant it, and to prove it I've done a quick benchmark of other similar solutions:
Code: (javascript) [Select]
let fromQuery = new Query()
.where(it => it % 2 === 0)
.take(10000)
.select(it => it + 1)
.reduce((a, it) => a + it, 0);
Code: [Select]
 event                    count   time (us)   % run  avg (us)    % avg |
------------------------------------------------------------------------
 Array method chain       1,001   3,605,798  34.1 %     3,602   34.3 % |
 Underscore chain         1,001   2,065,016  19.5 %     2,062   19.6 % |
 Lodash chain             1,001   1,168,390  11.0 %     1,167   11.1 % |
 from.js 1.0              1,001     903,805   8.5 %       902    8.6 % |
 from.ts (Oozaru)         1,001     875,786   8.3 %       874    8.3 % |
 Link.js query            1,001     475,447   4.5 %       474    4.5 % |
 Link.js query (NR)       1,001     325,084   3.1 %       324    3.1 % |
 from.js 2.0              1,001     319,423   3.0 %       319    3.0 % |
 Lazy.js sequence         1,001     270,130   2.6 %       269    2.6 % |
 Sphere from() query      1,001     205,757   1.9 %       205    2.0 % |
 Sphere Query object      1,001     188,966   1.8 %       188    1.8 % |
 handwritten 'for' loop   1,001     119,092   1.1 %       118    1.1 % |

Sphere from() query and Sphere Query object is us!  All timings are for running a chain equivalent to the above query 1,000 times with the respective library over an array of 100,000 random integers between 0 and 1000.

Special thanks to @Radnen for (indirectly) giving me the idea - Link.js was touted as a replacement for writing repetitive for loops, which got me to thinking... what if I just compile the query to an actual for loop...

This is really incredible that I was able to get so close to native loop performance and is a big win for code readability.  Query chains remain understandable even with 10+ query operators chained together, but throw together a couple filters and mappings plus a sort (or two!) and the set of for loops you need to write to match it can get pretty gnarly.  Lodash is proof people are willing to sacrifice a great deal of performance to get more readable code (see benchmark results above), even in tight loops where it matters most, but it's even better if you don't have to. :smiley_cat:
6
Engine Development / Re: miniSphere 5.3b1 (stable: 5.2.13)
Last post by Fat Cerberus -
Starting in miniSphere 5.3, from() will be built into the Core API without the need to import the "from" module.  Like @Radnen 's Link.js library that came before it, from() queries are often incredibly useful in battle engines, and now I've written some code in the engine to compile these queries directly to JS for super-fast performance.

Code: (JavaScript) [Select]
let dinnerAmount = from(worldPopulation)
    .where(it => pig.isHungryFor(it))
    .besides(it => pig.devour(it))
    .reduce((a, it) => a + it.weight, 0);
SSj.log(`the pig just gained ${dinnerAmount} lbs.`);
7
Spherical News / Re: Forum updates thread
Last post by Rukiri -
I'm not the most active guy around here, but this is going to blind a few people in the morning :P
8
Game Development / Re: The Screenshot Thread
Last post by Eggbertx -
I haven't mentioned it until now since it's a very low priority project that may never even get finished, but I figured I may as well post a screenshot for interest. The blocks that comprise each letter are actually one image copied to multiple locations as determined by a per-character array of JS object literals with x/y coordinates.
9
Editor Development / Re: QtSphere IDE 0.6.0
Last post by Eggbertx -
And now the map editor is (slowly) starting to look like a map editor! Thanks @Fat Cerberus for helping with the weird tileset quirk.
10
Editor Development / Re: QtSphere IDE 0.2.5
Last post by Eggbertx -
This thread is in desperate need of an update since QtSphere IDE is still in development even though it isn't my main project. I'm currently working on the map editor, and even though it's still far from completion, it fully loads map files, and this is what the editor itself looks like so far:

It might end up being able to display the first frame of each entity as a preview, rather than a generic icon. I haven't decided yet.