Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1404748 Posts in 68420 Topics- by 62079 Members - Latest Member: elkim

February 06, 2023, 03:24:02 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogs5N²+6N-4 . . . . . . (codename)
Pages: 1 ... 10 11 [12]
Print
Author Topic: 5N²+6N-4 . . . . . . (codename)  (Read 31948 times)
a-k-
Level 2
**


View Profile
« Reply #220 on: October 15, 2022, 06:30:11 AM »

Did I just use Python to transpile the Go code that the C++ game generated to WASM?


(WASM now available in the captcha spinoff as the 9th language)

WASM could actually be a nice addition also to the main game if I didn't find the translation of individual commands too verbose to my taste. Given that it's a standalone thing, basing this off Go was easiest: Go's support of multi-level break/continue transfers directly to WASM's named blocks/loops, and its restricted goto can be handled as if it were syntactic sugar for break/continue inside for { ... break }.

The new game should (hopefully) be playable on all Safari versions now, after implementing a workaround for a seemingly-obscure bug. Only to find another Safari-specific cosmetic issue with my indentation guides...
Logged

a-k-
Level 2
**


View Profile
« Reply #221 on: November 19, 2022, 03:28:55 AM »

I think that I've found the ultimate language for concealing goto's:



This shares the same algorithm that I implemented for Prolog, being little more than a nicer syntax at the moment. It won't apply to f1 and f2 above, but in general most helper functions should be eliminable by inlining loops. In Prolog, conditional loops needed their own predicates, while here anything can be nested inside anything. I'm going to do just that - hopefully with inlining the translations get "lispy" enough.
Logged

a-k-
Level 2
**


View Profile
« Reply #222 on: November 26, 2022, 01:13:03 AM »

Scheme has been integrated, for a total of 18 languages:


(loops using named let instead of local function definitions)
Logged

a-k-
Level 2
**


View Profile
« Reply #223 on: December 03, 2022, 02:52:32 AM »

The captcha spinoff game has just grown to 10 languages with the addition of OCaml:




How was that implemented? By transpiling from Scheme, of course:

Scheme

(define (tractors)
  (define (f1)
    [
0]
    (cond (<1>
           [2]
           (when <3>
             [4]
             (f2)))

          (else
           [5]
           (f2))))
  (define (f2)
    [6]
    (f1))

  [7]
  (let loop ()
    (when <8>
      [9]
      (f1)
      [10]
      (loop)))
  [11])
    ===>    OCaml

let tractors () =
  let rec f1 () =
    [
0];
    if <1> then begin
      [2];
      if <3> then
        let () = [4] in
        f2 ()
    end
    else
      let () = [5] in
      f2 ()
  and f2 () =
    [6];
    f1 ()
  in
  [7];

  while <8> do
    [9];
    f1 ();
    [10]
  done;
  [11]


In terms of control flow, for our purposes OCaml is merely Scheme plus while loops that don't support break/continue, so conversion was pretty easy. But then, getting it to a style that looked good, with proper line breaks/indentation and judicious use of idioms (or so I hope), took lots of iterations. (And if the result looks alien to you, so did it to me at first...)
Logged

a-k-
Level 2
**


View Profile
« Reply #224 on: December 17, 2022, 08:25:08 AM »

Following player feedback, I've read Whenever's specification once again and realized that the language was stricter than I'd thought, and required print() statements to be placed on lines of their own.

Combined with the earlier (and unrelated) change of limiting the number of commands on a line to no more than 5, this has made the translations longer in about a third.


(the code in the middle is incorrect (both lines) - can't have print() and 2#1-N(2) or 1 on the same line)

I should note that by the same token, read() also needs a separate line, so the code that I generate for conditions (not shown above) is incorrect too. I'm not keen on changing that, however - it seems more natural for language implementors to treat read() as a function than as a statement, so the restriction may not be imposed in practice.
« Last Edit: December 17, 2022, 08:34:29 AM by a-k- » Logged

a-k-
Level 2
**


View Profile
« Reply #225 on: January 14, 2023, 07:22:51 AM »

New level

  • Added a reduction-like level where the input needs to be transformed to a different "representation" (chosen by the player) and then converted back
  • The game now has 72 levels and 18 languages, which seems to perfectly fit its 6 commands. Of course I'm hoping to ruin that (although it's getting harder...)

Chrome 108 saga

Two players reported that the HTML5 version on Chrome started eating memory like crazy (gigabytes), ultimately crashing the browser. I couldn't reproduce it with my savefile, so was mostly shooting in the dark. Nothing I did help, and when one of them, having 64GB RAM and 8 cores, reported that they could barely pass the title screen, I jokingly recommended IE 11, where the game runs smoothly at 60Hz and uses only 200-300MB.
It was obviously that very suggestion that prompted Google, just a few minutes later, to deploy their new version (109) to the player, which fixed all issues.

Gained in the process:
  • Memory optimizations to applicative caches - compression (standard/custom/both) and hashing of keys where these were absent, stricter eviction, and a complete overhaul of one cache whose effectiveness had gradually diminished since the game stopped having only one language (4 years ago)
  • Ctrl+Shift+D also displaying memory use, rather inconsistently - private bytes on Windows, peak heap space rounded up to the next power of 2 in the HTML5 version, and total heap allocations (without fragmentation) on Linux (using malloc_info, possibly the only glibc function that returns XML...)
  • Ctrl+Shift+M (undocumented) - clears most caches, rebuilds font textures (so unused font sizes get deleted), and on Windows and Linux, also returns memory to the OS
  • WebGL 1-->2 transition (HTML5 version)
  • A change that was done and then reverted (killed FPS of HTML5 version on mobile) - moving from using freshly-allocated (static and smaller) VBO per draw call to allocating one (dynamic and larger) VBO and using it cyclically across all draw calls and all frames

Tablet support in HTML5 version

An experiment to test whether, without any changes to the UI, touch input would work well enough as a baseline.

Changes to the HTML5 version:
  • Touch support - fix for old SDL2 version that always reported (0, 0) coordinates, and manual handling of buttons that open browser windows/file dialogs
  • Fullscreen by default, web/standalone app manifests, and CSS/JS voodoo to encourage mobile browsers to not hide the game with all sorts of top/bottom bars (with partial success; dvh may help in the future)
Logged

Alain
Level 10
*****



View Profile WWW
« Reply #226 on: January 22, 2023, 08:50:33 PM »

Hey a-k! I just wanted to leave a word of encouragement: You have been cracking at your game consistently for a long time and it seems crazy complex. I have to admit it scares me a bit, but I'll keep an eye on it :D Keep up the great work!
Logged

a-k-
Level 2
**


View Profile
« Reply #227 on: February 02, 2023, 07:11:05 PM »

Hey a-k! I just wanted to leave a word of encouragement: You have been cracking at your game consistently for a long time and it seems crazy complex. I have to admit it scares me a bit, but I'll keep an eye on it :D Keep up the great work!
Thanks! Don't let all the "extras" fool you, the core game, what players do, is actually simple and hasn't changed since day 1! It's a tried-and-true formula...
Logged

Pages: 1 ... 10 11 [12]
Print
Jump to:  

Theme orange-lt created by panic