Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


Steve Bickle

Host Image
Host ID: 240

episodes: 5

hpr1778 :: Nethack and Vi cursor keys

Released on 2015-05-27 under a CC-BY-SA license.
Hi I'm Steve Bickle and this episode is "Nethack and Vi cursor keys", its my contribution partially inspired by the recent series of vi/vim podcasts and Frank Bell's recent episode Introduction to Rogue Class Linux.
In addition to my piece here, I also want to use this opportunity to point out an excellent podcast about vim, that's complementary to the series on HPR.
I was pleased to see recently that Thomas Gideon's The Command Line podcast is back from a hiatus and want to make sure that others are aware. His 12th of April podcast is an essay entitled "Hope and Fear in the World of vim" where he discusses his use of vim throughout his career as a programmer. You can find this podcast at
The text editor vi was written long ago by Bill Joy in the late 70's before the advent of the PC keyboard and cursor keys, so the default key mappings for left/down/up/right being H,J,K and L are not immediately familiar to a pc keyboard user.
AD-M3A terminal keyboard
The original UNIX machine for which vi was written used the AD-M3A terminal where H,J,K and L had the cursor arrows engraved.
Vi is installed as a default choice on many distros, and where it is not, there is invariably a package available that can be easily added.
Some, if not most, distros come vim installed by default (vim by the way stands for vi improved). This does have the cursor keys mapped nicely for a modern PC keyboard as well as the original keys. Vim is always aliased as vi, so if it's been installed when you enter vi you get vim.
Vi is a pretty light weight bit of code whereas VIM has more dependencies so sometimes vi is still preferred as the default install package. For instance Debian and many of its derivatives have vi rather than vim installed by default.
If you are distro hopping or working on other peoples systems you can generally rely on having vi available, but you can't be sure to get vim so it is useful to be conversant with the vi key mappings, along with a working knowledge of some of the basic commands. Then you will never be at a loss for a text editor when needing to hack around in a Linux box.
For me as an occasional user of vi the most challenging keys to remember to use are the H,J,K and L. cursor keys, since muscle memory has my fingers diving for the arrow keys. This is where the game Nethack comes in, which is what this article/episode is really about.
Nethack is a terminal based dungeon adventure games which uses the same cursor keys as vi and other old UNIX programs. Play this game for a few hours and you will ever struggle with vi cursor keys again.
The goal of the game is to retrieve the 'Amulet' from the lowest level of the dungeon and return to the surface with it for your god.
Nethack presents as a text based adventure with each level gradually being revealed to you in the on-screen character based level map. As you travel through the dungeon more of the level is revealed. As you play, your character gains more experience and levels up its capabilities.
You play as one of a number of types of character, and race. These include many of the usual dungeons and dragons types, archaeologists most likely inspired by Indiana Jones and tourists which definitely owe much to Terry Pratchet. Each role and race has their own initial characteristics, default inventory items, levelsof resilience and ability to learn various skills. For instance a wizard will advance his spell making capabilities faster than a footpad.
Although seemingly a simplistic terminal based game there's more going on in Nethack than is at first apparent. Originally released in 1987 it was actively developed with improvements to game play features until 2003. Since then there have been minor updates and ports for different platforms have been added, however there is rumoured to be a release with further game play improvements some-time this year.
The game has real depth and subtlety that is gradually revealed the more you play. It is not an easy game to win (from my experience to date that may not even be possible) but the more you play it the better strategies you will devise and the more rewarding the game becomes. There's more complexity to this game than almost any modern 3d HD graphic adventure.
Although there is a Nethack Wiki where information about how to play can be sought, the true elite apparently learn through playing. I'd suggest having a go, then when you become familiar with YASDs (yet another stupid death), there's a lot of them, you will have enough experience to answer a few burning question with the Wiki in order to be able to play a more satisfying game.
Although a challenging game, it is not a difficult game to play once you have remembered a few keyboard commands. And this game can be played just about anywhere. Because the game has GPL license there are many ports and flavours available. It is possible to play on most platforms: I have tried it on Linux, Android and even as a Google Chrome app, although the IOS port was not usable on our old iPad or a colleague's new iPhone.
There are various ports for the Windows platform, some of which replace the character based interface with Windows 3.1 style tile interface or a 3d isometric graphic interface. Personally I'd prefer to stick with the traditional character interface since the graphics don't really add anything to the game play. In fact when I play the game on Windows laptop, I use a minimal Debian install running on VirtualBox. I have set it up to auto-run Nethack and shutdown when exiting the game. Then I launch the VM directly with a shortcut containing the virtualbox command on the desktop.
This is how I set up my Nethack VM:
First I created a VirtualBox VM with 1 core 256M of RAM and an 8GB hard drive (I could have easily got away with 2GB actually).
Then I installed a minimal install of Debian, configured networking and installed nethack using apt-get install.
Once nethack was installed I disabled networking so I don't have to wait for a network connection to time-out when if my machine is not online.
To make Debian auto-start with a particular user account you can edit the /etc/inittab and alter one of the tty invocations. I changed the line:
1:2345:respawn:/sbin/mingetty tty1

To login my account 'steve'
1:2345:respawn:/sbin/mingetty –autologin steve tty1

To get Nethack to run on start-up, and the vm to shutdown on exiting the game edit the user's .bashrc file and append these three commands to the end of the file

clear # this ensures that the screen is clean prior to running the game
nethack # to run the game
sudo shutdown -h now # to close the VM when you exit the game

Because Nethack is a terminal based game it doesn't hammer the battery in portable machines, making it an ideal travel game for a commuter.
Even if you are not a gamer its worth a look at Nethack, it might be the one computer game that really grabs your attention.

hpr1775 :: Sonic Pi

Released on 2015-05-22 under a CC-BY-SA license.

In this review of the Sonic Pi software I have mentioned a couple of programs that I wrote the listings are here:

The Hippopotamus Song
use_bpm 180
# use_transpose -12
use_synth :fm
2.times do
play_pattern_timed [:D3,:G3,:G3,:G3], [1,1,1,1]      # 1 extra note from bar an bar 2
play_pattern_timed [:G3,:D3,:B2,:G2], [0.5,0.5,1,1]  # 3
play_pattern_timed [:a2,:b2,:c3], [1,1,1]            # 4
play_pattern_timed [:b2,:b2,:a2], [2,0.5,0.5]        # 5
play_pattern_timed [:g2,:g3,:g3], [1,1,1]            # 6
play_pattern_timed [:fs3,:g3,:e3], [1,1,1]           # 7
play_pattern_timed [:d3,:d3], [4,1]                  # 8 9
play_pattern_timed [:g3,:g3,:g3], [1,1,1]            # 10
play_pattern_timed [:g3,:d3,:b2,:g2], [0.5,0.5,1,1]  # 11
play_pattern_timed [:a2,:b2,:c3], [1,1,1]            # 12
play_pattern_timed [:b2,:b3,:a3], [2,0.5,0.5]        # 13
play_pattern_timed [:g3,:fs3,:e3], [1,1,1]           # 14
play_pattern_timed [:a3,:fs3,:e3], [1,1,1]           # 15
play_pattern_timed [:d3,:d3], [4,1]                  # 16 17
play_pattern_timed [:a3,:a3,:a3], [1,1,1]            # 18
play_pattern_timed [:e3,:e3,:e3], [1,1,1]            # 19
play_pattern_timed [:a3,:a3,:a3], [1,1,1]            # 20
play_pattern_timed [:e3,:a3], [2,1]                  # 21
play_pattern_timed [:c4,:b3,:a3], [1,1,1]            # 22
play_pattern_timed [:a3,:b3,:gs3], [1,1,1]           # 23
play_pattern_timed [:a3,:d3], [4,1]                  # 24 25
play_pattern_timed [:e3,:fs3,:g3], [1,1,1]           # 26
play_pattern_timed [:fs3,:d3,:d3], [1,1,1]           # 27
play_pattern_timed [:e3,:fs3,:g3], [1,1,1]           # 28
play_pattern_timed [:fs3,:d3,:d3], [1,1,1]           # 29
play_pattern_timed [:c4,:b3,:a3], [1,1,1]            # 30
play_pattern_timed [:g3,:fs3,:e3], [1,1,1]           # 31
play_pattern_timed [:fs3],[1], sustain_level: 0.6, sustain: 1, decay: 3   # 32 sustain note into next bar
play_pattern_timed [:g3,:fs3], [1,1]                 # 32
play_pattern_timed [:e3,:d3,:fs3], [1,1,1]           # 33
play_pattern_timed [:g3,:d3],[3,3]                   # 34 35
play_pattern_timed [:c3,:b2,:a2], [1,1,1]            # 36
play_pattern_timed [:d3],[3]                         # 37
play_pattern_timed [:g3,:fs3,:g3], [1,1,1]           # 38
play_pattern_timed [:e3,:a3,:g3], [1,1,1]            # 39
play_pattern_timed [:fs3,:e3,:fs3], [1,1,1]          # 40
play_pattern_timed [:d3,:d3],[2,1]                   # 41
play_pattern_timed [:b3,:b3,:a3], [0.5,1.5,1]        # 42
play_pattern_timed [:g3,:d3,:d3], [0.5,1.5,1]        # 43
play_pattern_timed [:c4,:c4,:b3], [1,1,1]            # 44
play_pattern_timed [:a3,:e3,:d3], [0.5,1.5,1]        # 45
play_pattern_timed [:e3,:fs3,:g3], [1,1,1]           # 46
play_pattern_timed [:d3,:b2,:g2], [1,1,1]            # 47
play_pattern_timed [:a2],[3], decay: 3               # 48
play_pattern_timed [:a2,:b2,:a2], [1,1,1]            # 49
play_pattern_timed [:g2],[3], decay: 3               # 50
play_pattern_timed [:g2],[1]                         # 51
sleep 2

The HPR Outro theme - hack on this improve it and make a show
in_thread do
  use_bpm 180
  use_transpose 24
  use_synth :beep
  19.times do
    play_pattern_timed [:a,:as,:a,:a], [0.5],release: 0.02, amp: 0.3 #
    play_pattern_timed [:as,:f,:as,:a], [0.5],release: 0.02, amp: 0.3  #
use_bpm 180
sample :elec_hi_snare
sleep 0.5
sample :elec_hi_snare
sleep 0.5
sample :drum_bass_hard
sleep 0.5

use_transpose -0
use_synth :saw
2.times do
  play_pattern_timed [:a,:a,:a,:a], [0.5,1,0.5,1] # 3
  play_pattern_timed [:a,:as,:a], [1,1,1]
  play_pattern_timed [:c5], [3], decay: 2   # 6
  play_pattern_timed [:a,:a,:a,:a], [0.5,1,0.5,1] # 3
  play_pattern_timed [:a,:as,:a], [1,1,1]    # 6
  play_pattern_timed [:f], [3], decay: 2   # 6
use_synth :dsaw
play_pattern_timed [:f],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:as,:a,:as],[1,1,1]
play_pattern_timed [:a],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:f],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:as,:a,:as,],[1,1,1]
play_pattern_timed [:a],[1]
play_pattern_timed [:f],[2], decay: 1.5
play_pattern_timed [:f],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:as,:a,:as],[1,1,1]
play_pattern_timed [:a],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:f],[1]
play_pattern_timed [:c5],[2], decay: 1.5
play_pattern_timed [:as,:a,:as,:a],[1,1,1,1]
play_chord [:c4,:f], decay: 4

hpr1751 :: How I got into Linux

Released on 2015-04-20 under a CC-BY-SA license.

My third show, its my How I got into Linux show, Crunchbang for the win, thank you Corenominal.

I actually wrote some of this up before I recorded my first show. I wasn't happy that I did a good enough job originally. However I decided to make use of a rainy day and get it updated and recorded. I cut out a chunk of rambling about floppy drive cleaners, and stuck some more up to date info on the end.

hpr1686 :: Interview with Joel Gibbard of OpenHand

Released on 2015-01-19 under a CC-BY-SA license.

This show is an interview with Joel Gibbard founder of the OpenHand project. The interview was recorded on my phone which unfortunately created a few glitches. I've cleaned the audio up as best I can. Although frustrating, the occasional glitches have not caused anything to be missed that cannot be inferred from the context of the recording.

photo of the hand

After creating an artificial hand for his degree project Joel Gibbard wanted to continue the work on the hand with the goal of producing a workable prosthetic hand for $1000, so he launched the OpenHand project with a succesful IndieGoGo fundraiser. In this interview we learn more about the Dextrus hand, the project's progress to date, and hear of Joel's vision of affordable prosthetics for amputees worldwide.

For a short 4 minute introduction to the project see Joel's video at

The openhand designs and more information are available at

hpr1201 :: In My Feed - Episode 01

Released on 2013-03-11 under a CC-BY-SA license.

My first show "In My Feed", a title inspired by the HPR Contribute page's list of requested topics.
Web Comics

GNU Command of the Week! is ... 'scp'
Go to $ man scp ;-)

Become a Correspondent