Skip to main content

News

Topic: neoSphere 5.9.2 (Read 522937 times) previous topic - next topic

0 Members and 13 Guests are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.3
Reply #1410
The next version of minisphere will rename link() to link.Q() to make it more obvious when you're dealing with a query.

Old way (minisphere 4.3.3):
Code: (javascript) [Select]

const link = require('link');

link(array).where(...).each(function(v) {
    console.log(v);
});


New:
Code: (javascript) [Select]

const link = require('link');

link.Q(array).where(...).forEach(function(v) {
    console.log(v);
});
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: minisphere 4.3.3
Reply #1411
It looks like Color.of isn't defined.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.3
Reply #1412

It looks like Color.of isn't defined.


Looks like you're right, I'll fix that for the next update.  The function exists in the engine but I forgot to register it with Duktape it on startup.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.3
Reply #1413
Quick progress update: The next version of minisphere will be v4.4.0.  It gets another minor version bump due to Link being replaced in the standard library by the new "from" module which provides most of the same basic functionality.

Link is still more feature-rich, but in the interest of future standardization for the Sphere v2 API I thought it would be better to include something a bit more simple out of the box.  Link has a lot of experimental stuff that, while it's really useful, I don't want to accidentally codify as an official part of the Sphere API.  That kind of thing is how JavaScript ended up with all kinds of weird semantics because to fix them now would break websites :P

@Radnen: Thanks for making Query.js and Link all those years ago.  Having some fully documented LINQ-style query functionality available out of the box will be a really great thing for Sphere, I think.  It's already proven its worth for me in the Spectacles battle engine! :D
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: minisphere 4.3.3
Reply #1414
Yeah, I agree with you there, a "basic" version of link would be great to package with minisphere, and those that need the horsepower can upgrade to Link; In short, I endorse.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.4
Reply #1415
Okay, new version 4.3.4 removes Link and replaces it with the new from module (I didn't bump to 4.4 after all, it barely counts as a new feature):

Code: (javascript) [Select]
const from = require('from');

var a1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var a2 = from.Array(a1)
    .where(function(n) { return n % 2 == 0 })
    .select(function(n) { return n + " pigs"; });
console.log(a2);  // 2 pigs,4 pigs,6 pigs,8 pigs,10 pigs


All query methods are fully documented in docs/miniRT-api.txt.

I also fixed Color.of() which was missing in previous releases, originally reported by Eggbert.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.4
Reply #1416
The next big project I'd like to start on is implementing full TypeScript support.  I removed the experimental support for it in minisphere 3.0, because A) it was done on demand by the engine, leading to painful loading times for large games, and B) it didn't support strict typing, entirely defeating the purpose.  Without static typing TS is basically just ES6 + some extra syntax.

So the new plan is to either integrate TS compilation into Cell, or still have the engine do it but then cache the result for later use.  The former seems like a better solution to me, as it'll give more control over the transpilation process.  If the engine does it then you're at the mercy of whatever default options it happens to use.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.6
Reply #1417
minisphere 4.3.6 is up, now with support for partial application of from() queries:

Code: (javascript) [Select]

// if you do this once:
var itemQuery = from(allItems)
    .where(function(v) { return v.owner === "Scott"; })
    .where(function(v) { return v.type === "healing"; });

// you can then do this as many times as you want:
var toShow = itemQuery
    .skip(itemsPerPage * pageNum)
    .take(itemsPerPage)
    .select();

neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.6
Reply #1418
I was recently looking at the source code for the .NET Framework LINQ methods, and the way it works is interesting.  It essentially does exactly what Link does, but in reverse: Rather than pushing items through a chain of points, it instead pulls them through a chain of iterators.  This is what allows things like OrderBy to be done in-place, vs. Link where they have to run the query.  Operations don't always have to stay in lockstep because everything is regulated through the iterator Next() method.  Thus even non-lazy operations like sorting can appear lazy to the rest of the query.

So naturally, I rewrote the "from" module to use this approach.  So look forward to query improvements in the next minisphere version. ;)
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.7
Reply #1419
minisphere 4.3.7 is out, now with support for Symbol which allows creating semi-private guaranteed-unique property names.  That's useful functionality to have as sometimes closures are too limiting.

I also made vast improvements to the from module.  It's now possible to do queries like this:
Code: (javascript) [Select]

var combos = from(this.combos)
    .where(function(v) { return currentPhase >= v.phase; }.bind(this))
    .random(targets.length)  // partially lazy
    .descending(function(v) { return v.rating; })  // ditto
    .select();


Or this:
Code: (javascript) [Select]

var ignoreList = from(followers)
    .mapTo(function(v) { return v.name; })
    .including([ 'robert' ])  // supplemental items
    .select();
SetPersonIgnoreList(info.name, ignoreList);


Or even THIS (totally contrived but it gets the point across):
Code: (javascript) [Select]

from(people)
    .from(function(v) { return v.pets; })
    .where(function(pet) { return pet.age >= 8.12; })
    .each(function(pet)
{
    pig.devour(pet);
    console.log(pet.name + " got eaten by the pig!");
}
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.8
Reply #1420
from#anyIn() was busted in the last release (it always returned false).  4.3.8 fixes it.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: minisphere 4.3.8
Reply #1421
Nice work with all of this so far!

By the way, I've found it difficult to get started with minisphere while the API keeps changing. Something that worked fine in the previous version is now broken. I guess that's just a risk that comes with chasing a moving target, though.

I'm also not really sure how to start creating your project as if it's a Node.js module - I have really no experience with this. There is, in all honestly, a LOT of new stuff I have to get used to by now, including just getting a picture shown on screen, which I needed to use the prim module for because I just couldn't figure it out otherwise. (I know I'm not a very good coder but still. :P)

The same goes for the Linq-style stuff - it looks really great but usually I don't *quite* understand what half of the selector code does in the examples I see fly by. Comments next to each line, please? Although maybe I just need to read the documentation for that.

Is there a possibility you could focus a little more on creating some simple snippets or tiny example projects on how to use certain parts of the API? That would be good wiki/tutorial material, too. :)


Edit: regarding Windows 7 testing: I'm using a laptop from work nowadays that has Windows 8.1, so I'll be checking that out soon on the notebook that also has Windows 7 on it.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.8
Reply #1422

Nice work with all of this so far!

By the way, I've found it difficult to get started with minisphere while the API keeps changing. Something that worked fine in the previous version is now broken. I guess that's just a risk that comes with chasing a moving target, though.


Yeah, Sphere v2 is still brand new and comprises a HUGE API surface (built-in engine functions + miniRT, it's a much more comprehensive API than Sphere 1.5's) so I used the 4.x cycle as kind of an experimental testing ground to get all the kinks ironed out (I thought I said something to that effect when I released 4.0.0, maybe not though...).  The goal for minisphere 5.0 is to stabilize the API so that it won't change anymore, at least not in major, fundamental ways like it has throughout the 4.x cycle.  But before that could happen I had to make sure it was presentable - it's important that our frontend be as easy to understand for someone reading the code as possible.  That said, the plan is to release 5.0.0 on the second anniversary of minisphere 1.0 (March 28), so 4.3 will remain current for quite a while.  And if it makes you feel any better: If you take the time to learn the API now, the rug won't be pulled out from under you again, I don't intend to change much in minisphere 5.0. :)

Quote

I'm also not really sure how to start creating your project as if it's a Node.js module - I have really no experience with this. There is, in all honestly, a LOT of new stuff I have to get used to by now, including just getting a picture shown on screen, which I needed to use the prim module for because I just couldn't figure it out otherwise. (I know I'm not a very good coder but still. :P)


Actually don't feel bad about that - that's exactly what the prim module is there for. ;)  miniRT is a first-class part of the Sphere v2 API, so it's not going anywhere.  Galileo is there if you need it for advanced stuff - but if you're just getting started or making simple games, prim is more than sufficient.  The built-in APIs in Sphere v2 are low-level because they are meant to be a foundation, so that you can build any kind of framework on top of them you need.  Games generally shouldn't use them directly; miniRT is there for small-medium sized projects, but if a large project needs something more robust it can build its own custom library on top of the low-level built-in functions.

Also, I feel it's relevant to mention here, the entire Sphere 1.5 API is still there if you need to fall back on it - and it's fully interchangeable with the Sphere v2 stuff.  That was a very important consideration over the course of Sphere v2 development - the two APIs had to be compatible with each other to make migration painless.

Quote

The same goes for the Linq-style stuff - it looks really great but usually I don't *quite* understand what half of the selector code does in the examples I see fly by. Comments next to each line, please? Although maybe I just need to read the documentation for that.


Yeah, I'm not sure any example can really convey its power.  The basic idea is that from(array) converts the array to a query, then each query operator you tack onto the end adds a new link to the "chain".  When the query runs, each item goes through the links in the chain, being transformed or filtered along the way (this is why a lot of the methods take functions as parameters, the examples would be much easier to read if Duktape supported fat arrow functions, but it doesn't).  Whatever makes it to the end without being filtered out is what you get as output.  Here's a query that gives you an array of all even numbers between 1 and 10, as strings:

Code: (javascript) [Select]

var evenStrings = from([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ])
    .where(function(v) { return v % 2 == 0; })  // "where value is even"
    .select(function(v) { return v.toString(); })  // "select value, converted to string"


The best advice I have is to read the documentation, since like I said the current version will be current for a while and the API is not likely to change much for 5.0 anyway.  These are permalinked to the 4.3.8 tag so the links shouldn't break in the future:
https://github.com/fatcerberus/minisphere/blob/v4.3.8/docs/sphere2-api.txt
https://github.com/fatcerberus/minisphere/blob/v4.3.8/docs/miniRT-api.txt

Despite the lack of examples, I did make sure the API documentation always stayed up to date, and it goes into detail where necessary (unlike the Sphere 1.x documentation which gets pretty vague at times...).

Quote

Is there a possibility you could focus a little more on creating some simple snippets or tiny example projects on how to use certain parts of the API? That would be good wiki/tutorial material, too. :)


But yeah, I'll try to do this for minisphere 5.0.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: minisphere 4.3.8
Reply #1423
Wow, thanks for the very comprehensive answer. I'm in the busy of a very busy lifestyle so I don't know when I can get around to it, but it's good to know I can basically start learning the stuff at any time without huge changes at this point. :)

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: minisphere 4.3.8
Reply #1424
New command-line tool planned for next big release: majin, named after Majin Buu from (what else? :))) Dragon Ball Z.

Majin will let you set up a game manifest from the command line without having to bother with a Cellscript.  For example:

Code: [Select]

mkdir awesome
cd awesome
majin init
majin title "Legendary Adventure"
majin author "An Awesome Dude"

# create a main script with some code, save it as, say, scripts/main.js

majin main scripts/main.js
spherun .


A while back my plan was to repurpose Cell to do this, but I decided against it because an automated build tool will still be needed in the future, once TypeScript support, minification, etc. comes into play.  So instead I'm making the project management its own thing.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub