Wednesday, January 2, 2019

Making the strategy game

Step one is making the board and havin great keyboard and click control manager. But you need a game compositor, it loads up the appropriate cursor manager, loads xchars and presents itself as a board game API. I accepts game fonts, accepts overlapping rectangles,
The board managers handles callbacks for mouse clicks and does echo when instructed, and the rest.

Has a fairly long API.  Easy to do, allows any number of game styles to be set up from action to strategy.  But, when the I and O have been minimalized to the significant few symbol names needed, then AI strategies can evolve, in different snippets. Bot vs Human vs bot; greats stuff. "Hey, try this snippet against Empire", they will say.

The files snippet

Great ideas will be popping up along the lines of smippet functions, like cursor managers.

How about a files snippet that maps high speed packed char symbols to linux file hierarchy. Used a  single multistep symbol table for the single purpose of constructing the proper linux file name fromthe map, then with the complete file name returned, the caller cn directly execute linux file calls.

In snippet land,that gives us the freedom to organize files and directories of all types, using thye semantics to match the job.  If you have a complex set up job, no probe, preloaded files with the short cuts and semantics you need, you system admin likely has a scheme.

A universal interface,tied to a common, high speed table, with syntax built into the language, no quotes needed so far.

ExecFile File_Name ./xchars/cursor/editor;

Works everywhere, gets you an cursor and key board manager for the local xchars, always there, an editor always available, same semantics. File_name here is like a typecaster, it actually call that files snipper, a method on ./.   ExecFile, in this case, loads a scrip which sets up the desired editor.

The expression is fake, files reconstructs the real file expression for linux.

ut snippets everywhere, for every little task,name spaced off for minimal interference. I fully expect both make and configure to appear as snippets. Developers keep a separate make rectangle,outsie of regular command line.

FX currency insurance

In what some have suggested is a chained liquidation stemming from the collapse of AAPL shares after-hours, multiple FX pairs are flash-crashing across the globe amid still low liquidity conditions in what appears to have been the unwind of a pair trade where an AAPL long was "hedged" with a basket of FX carry longs.

A good example of risk associated with foreign trade, the currency exchanges are generally innovative, unpredictable. So a foreign investor can buy currency insurance, literally, from his broker in the form of a counter investment to recover losses from unexpected exchange changes.  In this case, Apple, a very large share of the US stock market, changed valuation, suddenly. That has an effect on money flows and hedges get activated.

Foreign investors who fund all that government debt need this insurance, and the yield on treasuries has to be high enough to justify the insurance premium.  That is negative feedback, our ability to pay interest charges drops, money flows slows, rates jump, we contract, suddenly, a requant. Bailout jubilee.

The plot on Default name space

I propose using the file expression operators,.. // ./
;

The syntax will alow retyping these operators from Linux files o Snippet tables.

./xchars/NewWin conn win;

Will work, it means:
1) Look up xchars entry point in local table, (the ./)
then 2) take the reduced sequence:
./NewWin;, and ship that token list to the next entry point.

Repeat until it reaches a terminal.  The idea here is using high speed look p so name space costs barely more than a few instructions. But console loop offers a huge freedom, the ability to repurpose method names by running a second snippet in a different namespace. The console loop is already fort is, a few lines of code. Lett sink in, for version 2.0.

A good example are the cursor and keyboard snippets, start up another one, but keep xchars; just add the leading name space.  We can provide a using command so scipt code is all resusabl;e een though an underlying snippet has changed.

Swap cursor managers on the fly.  One rectangle has a game going, the other is your code editor, the third is command line.  This is what iPython is all about, but they got too many layers going with that browser.  The better bet is to get a slimmed down browser designed for iPython notebook, and  attach it with universal interface, then let Python main go to town. Certainly we will get QT_lite, if I have to compile one myself. Dump the browser, or more specifically, break it up into components and get the component collective going with new snippets.

Default macros working nicely

It was mostly corner conditions like no semi at end of src, or fixing switch back to syntax mode after macro and I had to start using the EXIT condition and created a one line exit_cmd to terminate a macro.  All those fixes work for while loops, which are simply macros preceded by expressions preceded by while_cmd.

Lines are coming in at 860, still well withing range of snippet.  But the expressions probably execute without crashing and it is mainly just getting the accumulator  matched properly between the while_cmd and  expr_cmd But even with simple macros, I can repeatedly bang on xchars with ad hoc command sequences. Productivity speed up already happerning.

A Default boot syntax, perfect in its niche. Well targeted, I avoid making any promises exceptthe simple default operations of a simple console loop.  But for the price, above and beyond what we needed anyway, Default is costing all of an extra 350 lines of code, and is designed to drop out on request.  It is like always having this open source, basic graphics driver for Nvidia, something that gets one started up and it is not black box.

My next test is Execfile, a file having the contents:
Default  LoadModule xchars;
MyStr() {
   NewConn conn;
   NewWin conn win;
   NewRext win rect 10 10 200 200;
   OuStr rect HwlloWorld;
}

Then under test condition I can:
MyStr();  # while debugging xchars.

I am remaining in Default mode. If I exit Default mode,
the macros remain valid, the console loop still finds them
and the source code is not replaced.  Cntrl c exits syntax mode, but we need to make exit_cmd work in this case.

How much args list can a snippet use?

MySnippet(int *argc,voiad * args[]) {

int base = *argc;

}

The snippet owns args from base to the semi colon in Default syntax.
 In console loop, the snippet can use args out to infinity.
/Console loop mode sets argc to zero, noting preserved in args list.

The argc requirements are unknown for other syntax engines. Since using args is mostly new, now is the time to standardize on semicolon for command line control

If the snippets calls the other snippets directly, not via Exec Command, then the two can create their own argc and args, be completely independent of syntax mode or default mode.  Cursor manager does this with xchars, calls directly.

The one catch is that any sub system can call ExecFile while in Default. That completely fouls the system, but works fine in console loop. This is the one major syntax error for console loop, until fixed.

I think I have this, the last major flow issue working, so all the macros and expressions and while loops will be simple adjustments.

So the package is defining and running macros without crashing, and I have to test for correctness.  The syntax-console hand off seems to work, semi colon terminators do their job. I have one page of Default syntax document in the links.  It should be mostly a few minor alignment fixes from now on, repaired as I use and test the system.

Persistence in console loop

Syntax engines like persistent objects, Default handles this by keeping the source code in buffer until cntrl c exits the syntax. It makes no attempt to move source code symbols, string and integer constants remain as pointers to source.

But, Console is currently keep fixed size buffers (a lab technique) ans this will change. Soright now, Default has a built in maximum source length, and I had n plans to exceed that anyway.  Default, about a minimal as one can get and still do recursive loops.

But, when theuser exits syntax mode, then is the source erased?No, the symbol tables remain accurate, pointing to the proper macros and variables in source. So the console loop preserves objects y preserving source, and its ability to repair syntax errors is nill. The syntax engine will likely need its own error recovery, at some point in the future; otherwise the persistent source code will cause repeated errors.

Logic flow, what is re-enrtent; all this changing a bit as I accommodate a flexible Default macro system, makinf it robust and follow a predictable rule.

It is the design philosophy, Default does only default things within its own memory space, just enough to set things up for another syntax engine. The management of source implies that Console loop will need configurable  settings telling it exactly what to do with source and args list. The default actions here will definitely not apply to all engines.

This also means multi-level aborts for the user, one abort keeps the source but exits the engine, all symbols work. The other abort clears source and deletes symbols, a more complete exit.  Syntax engines need to tell console loop how to handle aborts.

Not handling this correctly is why my macros had inconsistent behavior.  A lot of my discoveries are about the hand off between syntax and command line and dealing with tokenizer induced spaghetti. But that is more important than making Default completely functional.

Tokenizer strings, identification of charater markers to make tokens will change if syntax want to..  I am going to set aside space on args list, the list of special character strings will be there, just set the pointers is fine.  The new syntax engine isd in console loop memory space, the args list is universal, use it for configuration, include a control code for console loop. 

Application collections

What do we need for a good code editor?

Swap out the standard cursor snippet, add you own, add highlighting, reuse Xchars, set the windows how you want, add borders and such with xcb pass thru from xchars.  Everything in xchars defined by symbols, edit window, for example. Change fonts as needed, change color per rectangle; all with basics rectangle, window, and graphic context, plus xcb pass thru and you have a collective of snippets organized into an editor.  Edit in one window, execute in the other, your editor snippet has full access to ExecCommand. Make a charting snippet.  Games of all sorts, the simplicity of high speed symbols look up does the trick here, uniform call structure in args, then direct mapping from string via tokenizer.

Leave your graphics routines right there, in args list for reuse, just inform console loop with the continue return, that informs console to retains executable codes.  The we setup arg list with specialty moves and font swaps, work the heck out of xcb, make great font based games.  If you want symbol persistence, tryout sqlite on the bus, or adapt a well written symbol maintainer snippet.

All of xchars moves with wayland, as will xcb, xchars will get nothing but faster.

Then the multi step high speed processors need control, console loop and syntax engines do the job, multi-level job control, like we need in join operations.

We can add spreadsheet snippets, the whole sheet code attached on the universal interfaces, direct control of cells. Bunches of others, a buffer snippet supports direct drawing into bitmap.  Al of the applications will adopt the fast symbol interface.

A snippet manager snippet. It keeps an eye out for loose snippets, tracks their location whenever the user wants a snippet collection.  It does snippet hunting, calls LoadModule for you, maintains a persistent collections of snippet collections.

If snippet authors build up large snippet dependencies, fine, we got names spaces, snippet hunters, pipers, and what not to cobble something close to desired collection of snippets. Load em up in the same address space, and you have an applications likely better than those that come before..

Tuesday, January 1, 2019

Managing the bus program counter

Right now that is my worst problem, making sure argc is stable from snippet to snippet, but I work through it. How to protect argc?  Update it via the signal handler, the snippet is done executing, it can request an update by an assert, the signal handler well adjust argc.  I do not consider this necessary, yet. Linux probably has a shared memory operation that can do the trick, I am not looking, not my problem at the moment.

I  mention it because it is the weak point, but it has solutions, the pros know what to do.  Enterprise we have the consensus snippet which I told you about.  Separated console loops can share args list but they have to reach a multi-party access lock. A request is a bot that crawls the console network, locking the resource for every node. So, I am driving this problem up to the snippet layer, a fast consensus algorithm. Done this, been there.

Putting a powerful tool up for python and golang, a controllable args list with snippets preforming transformations.
case end_tag: // The semi colon
args[*argc]=";";  // Making sure
*argc +=1;
if(!DepthBase) {// This is the pass thru function
*argc=StartCommand;
ExecCommand(argc,args);
}
break;

This is the Default interpreter executing pass thru.  It is essentially in control of the command line.  Start command is the point one past where the previous command ended, but that variable isd managed in ExecCommand acting a program counter.

What does Default pass through? Everything, you commands that are not syntax, it also runs its own assembly code back through this interpreter, everything is a linux command whose function is discovered in ExecCommand.  If I include 'linux undefines' as valid Default syntax, which it is, then Default encapsulates all the linux command semantics, built in, especially since I added file expressions as first class objects.

But is all happens on args list. Many of the calls being a transformation of args list, tokenizer does this, shun does this.  Each intermediate form works because it is structured like a valid command and we just run it back through.

This simplifies symbol table, one table holds everything through its various transitions, so there is a single point of information at any stage in the process.  All of which leads to compact code, a single file which is still at 800 lines of code.

Is Default fast? Heck no, designed for compactness and reuse, never even considered speed a factor because the speed in in the snippets. Xcharsis fast, fast enough for personal gaming, much faster than anything a browser can do, but in th context of a cursor managing snippet, xchars can be just as flexible regarding text.

Software dependencies? None, we can run console loop and default on a bare processor, if it has a keyboard io.  That is what we want, a machine completely defined by the layered semantics above, keep the hardware metaphor. console loop is a dma controller for the bus.. Default is the default DMA device driver.