..

Week of the 11/06/2023 - #45

Contents

tech

  • ZX Art - Octobre 2023
  • RCValle Logo animation
  • Donut ASCII demo articles
  • C64Demo - Public Demo Releases

science

  • Chess and AI

ZX Art - Octobre 2023

Here are some of my favotire ZX art releases for last month:

Fishing Cat (zxgfxtober 1 - cat)

Fishing Cat (zxgfxtober 1 - cat)

the spirit is willing

the spirit is willing (zxgfxtober 2 - spirit)

Robocot

Robocot

COAL DUST IN NAKHODKA (zxgfxtober 15 - crane)

COAL DUST IN NAKHODKA (zxgfxtober 15 - crane)

Netrunner

Netrunner

moonlight reflex

moonlight reflex

Guinea pig (zxgfxtober 23 - rodent)

Guinea pig (zxgfxtober 23 - rodent)

only a glitch (zxgfxtober 27 - 200)

only a glitch (zxgfxtober 27 - 200)

Лист календаря 10.11

Лист календаря 10.11

Forest Escape - A Knight's Quest

Forest Escape - A Knight’s Quest

Donut ASCII demo articles

Donut ASCII output

For me the key takeaway is this formula which might come in handy to rotate stuff with integer math:

Integer rotation snipet

#define R(t,x,y) \ 
  f = x; \
  x -= t*y; \
  y += t*f; \
  f = (3-x*x-y*y)/2; \
  x *= f; \
  y *= f;

Integer version of donut code:

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define R(mul,shift,x,y) \
  _=x; \
  x -= mul*y>>shift; \
  y += mul*_>>shift; \
  _ = 3145728-x*x-y*y>>11; \
  x = x*_>>10; \
  y = y*_>>10;

int8_t b[1760], z[1760];

void main() {
  int sA=1024,cA=0,sB=1024,cB=0,_;
  for (;;) {
    memset(b, 32, 1760);  // text buffer
    memset(z, 127, 1760);   // z buffer
    int sj=0, cj=1024;
    for (int j = 0; j < 90; j++) {
      int si = 0, ci = 1024;  // sine and cosine of angle i
      for (int i = 0; i < 324; i++) {
        int R1 = 1, R2 = 2048, K2 = 5120*1024;

        int x0 = R1*cj + R2,
            x1 = ci*x0 >> 10,
            x2 = cA*sj >> 10,
            x3 = si*x0 >> 10,
            x4 = R1*x2 - (sA*x3 >> 10),
            x5 = sA*sj >> 10,
            x6 = K2 + R1*1024*x5 + cA*x3,
            x7 = cj*si >> 10,
            x = 40 + 30*(cB*x1 - sB*x4)/x6,
            y = 12 + 15*(cB*x4 + sB*x1)/x6,
            N = (-cA*x7 - cB*((-sA*x7>>10) + x2) - ci*(cj*sB >> 10) >> 10) - x5 >> 7;

        int o = x + 80 * y;
        int8_t zz = (x6-K2)>>15;
        if (22 > y && y > 0 && x > 0 && 80 > x && zz < z[o]) {
          z[o] = zz;
          b[o] = ".,-~:;=!*#$@"[N > 0 ? N : 0];
        }
        R(5, 8, ci, si)  // rotate i
      }
      R(9, 7, cj, sj)  // rotate j
    }
    for (int k = 0; 1761 > k; k++)
      putchar(k % 80 ? b[k] : 10);
    R(5, 7, cA, sA);
    R(5, 8, cB, sB);
    usleep(15000);
    printf("\x1b[23A");
  }
}

RCValle Logo animation

I collaborated with Sander focus to animate his beautiful RCValle logo:

RVCalle logo

C64Demo - Public Demo Releases

There is this thread on CSDB talking about releasing tools and source code in demos. From this discussion there are some intereting tools / repos:

  • TSCrunch - “TSCrunch is an optimal, byte-aligned, LZ+RLE hybrid encoder, designed to maximize decoding speed on NMOS 6502 and derived CPUs, while keeping decent compression performance (for a bytecruncher, that is). TSCrunch was designed as the default asset cruncher for the upcoming game A Pig Quest, and, as such, it’s optimized for in-memory level compression, but at as of version 1.0 it can also create SFX executables for off-line prg crunching.”
  • Go tool to inspect SIDs - Seems to be a tool to open SID files and output it’s metadata.
  • C64 Programming Templates - A really nice starting point for a C64 demo.
  • Discomatic MD - 2021 source code - csdb entry

Robert Troughton released the source code for 6 Commodore 64 demos

The demos source code for these 6 Commodore 64 demos:

Chess and AI

One interesting topic is the relationship between computer algorithms and understanding. My goto reference for this is Roger Penrose. With the advent of AI and the new computer chess playing alogorithms that beat the best human players without breaking a sweat one can believe that computers have a deeper understanding of chess than us humble humans. This is not the case. If one understands how this algorithm works you can see that they are simply very powerfull calculators. One way to see this is to present them with chess positions which average playing humans can clearly see are drawn (for example) but computers struggle or simply consider winnable. A recent article in Quanta Magazine talks about this topic and cite a paper with lots of this interesting chess positions.

Let’s look at this position. From the paper: “White can draw in several ways, for example, by repeating Kb2-a1 to draw via the three-fold repetition rule or the 50 move rule. There is no way for white or black to make progress. This position would be even be drawn is white picks up the pawns on g4 and h3. The reason is that black can sacrifice the bishop for one of the pawns. The resulting position is a draw because it’s a fortress.”. Even though one can clearly understand this Alphazero would struggle with this position!

This position is a draw

  • AI System Beats Chess Puzzles With ‘Artificial Brainstorming’
  • Diversifying AI: Towards Creative Chess with AlphaZero - Paper with algorithms that perform better on these type of positions. The abstract: “In recent years, Artificial Intelligence (AI) systems have surpassed human intelligence in a variety of computational tasks. However, AI systems, like humans, make mistakes, have blind spots, hallucinate, and struggle to generalize to new situations. This work explores whether AI can benefit from creative decision-making mechanisms when pushed to the limits of its computational rationality. In particular, we investigate whether a team of diverse AI systems can outperform a single AI in challenging tasks by generating more ideas as a group and then selecting the best ones. We study this question in the game of chess, the so-called drosophila of AI. We build on AlphaZero (AZ) and extend it to represent a league of agents via a latent-conditioned architecture, which we call AZ_db. We train AZ_db to generate a wider range of ideas using behavioral diversity techniques and select the most promising ones with sub-additive planning. Our experiments suggest that AZ_db plays chess in diverse ways, solves more puzzles as a group and outperforms a more homogeneous team. Notably, AZ_db solves twice as many challenging puzzles as AZ, including the challenging Penrose positions. When playing chess from different openings, we notice that players in AZ_db specialize in different openings, and that selecting a player for each opening using sub-additive planning results in a 50 Elo improvement over AZ. Our findings suggest that diversity bonuses emerge in teams of AI agents, just as they do in teams of humans and that diversity is a valuable asset in solving computationally hard problems.”
  • Sir Roger Penrose & Dr. Stuart Hameroff: CONSCIOUSNESS AND THE PHYSICS OF THE BRAIN ▶️ - An intimate lecture with renowned mathematical physicist Sir Roger Penrose and anesthesiologist Dr. Stuart Hameroff, followed by a conversation with The Science Network co-founder Roger Bingham. Co-organized by The Penrose Institute and the UC San Diego Institute for Neural Computation, with the support of Intheon, Neocortex Ventures, and the Data Science Alliance.