The Intellectual Wilderness There is nothing more useless than doing efficiently that which should not be done at all.

2021.04.5 12:37

Geopol: MAD (Mutually Assured Destruction) Predicts Ideological Conflict

A discussion about how the policy of MAD between major powers prevents direct overt competition, and when given a lack of intermediate means of conflict exists conflict will instead manifest through subterfuge, subversion and ideological conflict.

Watch on Rumble or BitChute.

Geopol: US Nuclear Parity With China?

This video discusses nuclear parity, what it means, and how the situation between China and the US shape our thinking about this issue.

Watch on Rumble or BitChute.

Censorship: Attack of the Twits!

Filed under: Politics / Geopolitics,Society — Tags: , , — zxq9 @ 12:26

The story of how I left Twitter. Pretty ridiculous, but in 2021 the line that defines Poe’s Law is long gone in the rear-view mirror for the majority of the English speaking world.

Watch it on Rumble or BitChute.

2021.03.11 17:11

Geopol: How moral responsibility maps to the consciousness spectrum

Continuing on with the foundations of geopolitics (and this one is also part of the foundations of general moral philosophy — but I’ll get into that later), this video discusses consciousness as a spectrum and how moral responsibility maps to that. This particular video is podcast style with just a still image over it as I didn’t have a camera or any interesting B-roll to illustrate it with.

Watch on Rumble or BitChute.

Geopol: Mutual capacity for violence is the root of negotiation

Misunderstandings about the root of political interaction has come up repeatedly lately so I’ve decided to do a few videos that discuss the roots of geopolitics. In the video below I discuss how the mutual capacity for violence is the root and essence of negotiation.

Social Trust: Why crypto, blockchain and smart contracts will not change the world

Lately I have been involved in a number of discussions about distributed systems, delegated authority structures, cryptocurrency and smart contracts. The hope of many is that cryptocurrency will avert inflationary trouble entirely and help the public hold government in check. There is also hope that smart contracts will magically turn Africa into a paragon of high trust economics and a trade powerhouse of its own accord.

I decided to record my thoughts on this here:

The TL;DW of it is that while these are really great things to hope for, and not impossible goals, the idea that crypto technologies are going to manifest profound levels of social change on their own is misguided. The social and political problems much of the world is facing today are due to an erosion of trust and flagrant, repeated violation of trust and faith from every actor at every angle. In short, the West is moving from a high-trust social model to a low-trust social model and Africa is and has ever been suffering from low-trust social models. Crypto isn’t how that is solved.

Erlang: Video tutorial HOWTO on installing Erlang and ZX from scratch on Ubuntu Linux

Filed under: Computing — Tags: , , , , , , — zxq9 @ 13:24

I’m flattered to find that Dr. Kumar made a tutorial video of how to install Erlang and ZX on a fresh Ubuntu system and check that it is working by playing Erltris. It is sort of a video version of previous instructionals and the ZX quickstart docs all in one place.

Big thanks to Dr. Kumar!

2020.12.26 16:19

Erlang: Writing a Tetris clone Part 3 – Gameplay rules, final features and deployment

Filed under: Computing,Games — Tags: , , , , , — zxq9 @ 16:19

The third video in this series moves on with implementation of gameplay rules, scoring, the “next” preview window and packaging and deploying the game using ZX as a shortcut.

Writing this is a lot of fun. As of this video the game part is finished, but there are a few things such as high score recording and maybe some network features that have not been implemented. I might make a fourth video that covers these but it might be more interesting to move on with another example to demonstrate techniques to accomplish similar tasks.

Quite a few details that were noticed and mentioned in the first two videos have been updated in the course of completing the code for this video, so it may be interesting to check the commit history if you’ve been following along.

As always, have fun making stuff!

2020.12.19 17:16

Erlang: Writing a Tetris clone Part 2 – Gameplay mechanics

Last night I was able to make the second video in my series about implementing a Tetris clone in Erlang. Yay!

In this video I start where I left off in the first video where I had ended with a data abstraction to represent the play field (called the “well” in Tetris lingo), a data abstraction for the game pieces, some colored sprites to draw the game board with, and a GUI that could draw a game board and a single random piece every time it was opened as well as print to stdout any key press events that I made.

Oh but by the way…

I have a small confession to make — I didn’t actually start where I left off. I mentioned the stopping point (the “Draw the board with a random piece on it” commit), then I mentioned the next thing I did which was implement basic movement (the “Basic (unsafe) movement” commit), then I completely blew past it and never explained the way I implemented unsafe movement in the first place. The trouble with having skipped that is that I had intended to discuss how keystroke capture actually works, where it is in the GUI code, and follow the event through the system so that people could get that idea into their head earlier than later because it is so basic to making a game!

So instead I’ll explain how that works and point out where it is in the code here in this post and cover it at the beginning of the third video.

Getting Input

If we look at the “Basic (unsafe) movement” commit there is a file called ertltris/src/et_gui.erl that is the code for the GUI process. In the init/1 function we see the wx server get started, a “frame” is created (the main window in wx parlance), some various widget elements and things are all established and on line 112 we see this:

ok = wxPanel:connect(Frame, char_hook),

This is connecting the Frame to a window manager event called char_hook. I do mention this in the video, but it is important to point this out here. I should also point out that I’m mistakenly calling wxPanel:connect/2 instead of wxFrame:connect/2 — which is technically incorrect, but due to the nature of the underlying inheritance among the C++ classes that make up wx and the way that’s all masked in the generated library wrappers that make up wxErlang, it actually doesn’t cause any errors. wxPanel and wxFrame are all ancestors of wxEventHandler.

Anyway… what connecting to this event does is tells wx that whenever the frame is the focus it should relay keystroke events to the program. Inside Erlang they arrive as messages that carry a #wx{} record that includes an event element that carries another record that provides all the relevant information about the event. You can receive these in the handle_event/2 callback function of wx_object. Pretty nice. This means you can deal with GUI events in very much the same way you can handle network events as well as inter-process messages within the Erlang runtime: everything is a message.


As I often say: Develop idioms.

A common idiom I use in wxErlang code is to match on an event type in handle_event/2, assign any relevant event data to variables, and then within a case inside the handle_event clause that matched that event type determine where we want to dispatch the event (if at all). You can see a very clear example of this on lines 191-203 of this commit.

handle_event(#wx{event = #wxKey{keyCode = Code}}, State = #s{frame = Frame}) ->
    ok =
        case Code of
             32 -> et_con:random_piece();
             88 -> et_con:rotate(l);
             90 -> et_con:rotate(r);
            314 -> et_con:move(l);
            315 -> et_con:rotate(r);
            316 -> et_con:move(r);
            317 -> et_con:move(d);
            _  -> tell("KeyCode: ~p", [Code])
    {noreply, State};

I could have made each one of those dispatch decisions inside the function head instead of using a case statement within a clause, but I find it much easier to read this particular style where we open a very compact dispatch span per event type we’re looking for than have a ton of handle_event clauses. In complex GUI applications you can wind up with a lot of special keystroke events and it becomes super cumbersome to match them all as function heads. Not just writing the function heads, but trying to find a specific event gets kind of messy because the code starts looking so scrambled.

Each of the different key codes matched in the dispatching part of that function correspond to some gameplay event. Note that the GUI doesn’t really care what the status of the game is at all, it just cares that it is relaying the mapped commands to the game control process and then carries on doing GUI stuff.

This is important to point out: Nearly all communication between the controller and the GUI is asynchronous. You almost never want blocking calls to pass between them. There may be a need for a blocking call in some special code, but this is almost always a bad idea.

Buh bye!

That pretty much sums up what I wanted to cover that I forgot to mention in the video. Input handling is really important. If you want to jump ahead, check out the way the handle_event/2 function evolved in the latest commits to see how menu commands are intercepted, or go check out the handle_event/2 function in the Erlang Minesweeper clone!

Don’t forget to give me all the delicious likes and stars and channel subs! BWAHAHA! I’ll catch you magnificent nerds in the next video!

2020.12.15 17:16

Erlang: Writing a Tetris clone Part 1 – Data types and basic GUI display

Over the last few days I wrote an Erlang implementation of the classic puzzle game Tetris and decided to do a few videos to explain how it works and why. This is part one of a three-part series.

  1. Data types and basic GUI display [this page]
  2. Gameplay mechanics
  3. Gameplay rules, final features, and deployment

This first video covers how I started the project (cheating using ZX to template a GUI project for me, of course), what data types I thought I would probably need from the outset (the game board and the game pieces), and my initial stab at getting pixels on the screen in a reasonably pretty way.

The videos roughly trace the commit history of the project as I developed it, with this first video covering the first 3 commits which get me from a GUI project template to displaying the game board and drawing a random piece in it each time I start the program (as well as catching keystrokes so I can examine what their values are).

« Newer PostsOlder Posts »

Powered by WordPress