Ubuntu: Change Hostname, or, Why is sudo so slow?

After installing Ubuntu, I decided that the name I gave my computer was not satisfactory. So, I followed this how-to, which explains that you can simply change it by editing the contents of the file
/etc/hostname
and restarting the computer.

After this change (I didn’t make the connection until later), any sudo command would take almost a minute to run, and give the error sudo: unable to resolve host <hostname>.

The resolution is that you can’t only edit this file. The file
/etc/hosts
must also be edited, so that 127.0.0.1 resolves to the new hostname you defined.

Immediately, sudo began working properly again.

Using compiled Lua with Moai SDK on OSX

Today I started taking a look at the Moai SDK for game development. It’s a game engine that uses Lua for scripting, without ever having to touch the C++ code underneath if you don’t want to.

A Moai application is actually just a set of .lua files that are fed into the moai executable (moai main.lua), which can be downloaded as a binary or as source with projects to build it on various platforms.

My first thought, rather than how to make a game or do anything interesting, of course, was how how to release a Moai game without distributing plaintext source (I’m not suggesting you shouldn’t, but that in some cases you might not want to). It turns out moai can take in compiled lua, as well.

Great. So I install lua with homebrew, compile with luac -o main main.lua, run moai main, and get this crap: -- main: bad header in precompiled chunk.

Turns out this is because the homebrew installation of lua is 64-bit, and moai is 32-bit, and they just don’t get along. In order to compile lua source properly for moai, you’ll need to download lua5.1.4 and compile it for 32-bit. I found the solution here, but I’ll reproduce it below as well.

  1. Download lua 5.1.4
  2. Unpack it, cd into that directory
  3. Modify src/Makefile by finding the lines
     macosx:
        $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"

    and changing them to

    macosx:
        $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX -arch i386" MYLIBS="-arch i386 -lreadline"
  4. cd src
  5. make macosx
  6. cd ..
  7. sudo make install (note, this will write to /usr/local/bin, which will overwrite any existing lua install)

Now you should have a version of lua such that your luac-compiled files will get along nicely with Moai!

-E

Aturae Campaign, Session 2 Recap

Ruethál promptly lit a torch and took lead climbing down the ladder into the damp sewer tunnels below the abbey. They came across a split in the tunnels, but Nahusha managed to trace the scent of blood and keep the group on track. The heroes hurried down the hall until they entered a chamber with crumbling walls and large sewage grates on the floor. They spotted two kenku, some spitting drakes, and a pseudodragon. As they engaged in combat with their foes they heard the rushing of liquid down some pipes and soon find out that the grates on the floor were there to drain the filth intermittently spewing from the walls.

Ahhhh the ambience of the occasional toilet flush pouring from the walls.

Poor guys didn't know what hit them, but they did have some nice guard monsters to help them out.


The kenkus were surprised by the sudden assault and informed the heroes that this is the territory of the Iron Crow, the mob leader of the Frigid Talon. They mentioned that they saw some others pass by earlier and agreed to let the heroes pass through this part of their territory in exchange for a ceasefire and their healing the kenku they wounded.

The heroes continued into the actual water tunnels of the sewer and began down the path. They soon came to another fork in the road. Down to their right they spotted firelight coming from within a room. Nahusha attempted to sneak by and see what was inside – he saw on his right a large grate holding back a legion of rats, and on his left a kenku who was sitting guard in a room filled with crates. Unfortunately, the kenku saw him too and ran to pull a nearby lever, unleashing the cage of rats into the water.

Fuck rats.

Rats big as cats, all swarming on a bear.


The rest of the heroes threw precaution to the wind and rushed forth to attack the kenku, who promptly shut and barred the door to his room. Suddenly, as the heroes were swarmed by rats, a crocodile lunged out of the water at Ursus, Ruethál’s spirit companion. The heroes realized that the rats were actually feed for the crocodile!
This crocodile lives in shit. Meh.

The croc is a battleship! =P


Griffin of Targe wrestled with the crocodile while Gauthak started to break down the door. Gauthak managed to break in and subdue the kenku, bringing him outside clenched in his fist. Nahusha managed to land a final slash on the crocodile as it was swimming away, killing it just before it was about to reach Gauthak and the kenku.

The heroes notice that this kenku had an unusually heavy coin pouch on him, and upon further inquiry discover that he had accepted it as a bribe for the safe passage of some human who came by recently. After revealing the direction the human went, the heroes ran down the hall and come into a large chamber with sloped floors leading down to water pits.

That poor kenku... nobody wants to get tossed into an octopit.

The thief, found at last! Plot twist!


To their left they see Brother Xavros, standing across one of the pits.
“I provoked this kenku into attacking the abbey, I didn’t plan on his mad dash for the book. You four disappointed me in letting him go. This little bugger got in the way, you see what he did to my leg? Working with these filthy crows has been more trouble than it’s been worth. Anyway, I have what I came for, I don’t need him anymore.”
He picked up the kenku in one hand, it squirmed in complaint, but hadn’t the energy to fight. Xavros tosses the kenku disdainfully down the slope and into the pit.
With a splash the Kenku is promptly sucked down under the water. As Xavros finishes talking his face begins to morph – features begin to disappear as his skin turns white and his hair turns gray.

Xavros begins summoning more Fell Taints as drakes came swooping down at our heroes. Gauthak was the first to step too close to the water, as a slimy tentacle lashed out at him. He managed to get away, but Ruethál was not so fortunate, as a Drake knocked him down into the other pit. Nahasha ran over to Xavros and stabbed him in the stomach, causing him to fully morph into his featurelessness and die. The fell taints fade away as their summoner perished. The heroes manage to take care of the other assailing monsters and come over to inspect the corpse.

Xavros was a doppelganger, the original man long dead, and on his body was the Book of the Exile, alongside a pendant:




The heroes realize that Xavros had been using the power of the book to enhance his summoning powers, which was the origin of the Fell Taints. They break down the door Xavros had been fumbling to unlock and find a ladder going up. They climb out of the manhole at the top and emerge into a busy street in the middle of Brachik.

They made their way back to the Abbey and go to Brother Elward’s study. They hear voices from within asking about the Book of the Exile. Upon their entrance they meet Brother Cruros, the Right Hand of the High Priestess of the Raven Queen, who had received Brother Elward’s message and was here for the book. Cruros was a 7 foot tall human, garbed in a hooded cloak. Alongside him were two others also in cloaks, one of which was a slightly shorter human and the other a mechano-wooden guard. Nahusha hands over the Book of the Exile.

Cruros takes the book, hands over 100 gold to each of the adventurers, and tells them to stay out of such affairs and not take the “stories” of Brother Elward too seriously. Upon seeing the symbol on the pendant, Elward is shocked. He informs the heroes that it is the Symbol of Lord Qasaf. He examines it and notices that it has a mild charm, and gives it to Gauthak. Cruros nods and parts in silence, along with his fellow brothers.

The heroes, tired after a long morning of battling in sewage, take their leave: Gauthak goes to cook, Nahasha to meditate and pray, and Griffin and Ruethál head to a tavern together to exchange stories of their past.

To be continued….

Aturae Campaign, Session 1 Recap

The adventure begins in a town called Brachik, a bustling city located on the central eastern coast of the continent Aturae. Night has fallen on Brachik as an elf shaman named Ruethál Baeqúiathem arrives at the door of the local Abbey of the Raven Queen. In search of more information concerning the mysterious Lord Qasaf, he speaks with Brother Norril, who leads him inside.

In the library is a human warlord named Griffin of Targe who has been summoned by Abbot Elward to see to the safe passage of a dark book of secrets. After learning that this book contains information on Lord Qasaf, Ruethál opens the cover, unleashing a torrent of wind and energy and a handful of Fell Taints, dimension-shifting creatures of another plane.

The wild commotion ushers forth the goliath fighter Gauthak, who serves as the Abbey’s cook, and the razorclaw shifter avenger, Nahusha, who was visiting the abbey from the countryside, to find new experiences out in the world. The four heroes fought bravely as Abbot Elward rushed to shut the book from which the monsters poured out.

After putting an end to the Taints and the commotion, Abbot Elward led the group into a separate chamber to talk to them about The Book of the Exile and the ancient story about the City of the Gods. The tale goes that in ancient times stood a magnificent City of the Gods, until one day war broke out between two groups of Gods. Central to their battle was a powerful item, which is never fully described in any of the tales, which was stolen by a God known only as the Traveler. A God named Déoradhan the Exile betrayed his fellow Gods and aided the Traveler in this plot. Together they fled the city as the old gods destroyed it around themselves. The old gods were buried, but the Exile and Traveller found a peaceful place and built a new world around it. The item now lies at the center of the world, along with the Traveller, who lies in slumber. The way to his realm is guarded by Lord Qasaf, the Gatekeeper.

These tales and more are bound within the volumes of four books, the Book of the Gatekeeper, the Book of the Exile, the Book of the Traveller, and the Book of Brothers. The Book of the Exile is the one in the possession of these monks, and the Abbott tells the heroes that he knows the location of the other three books. He says that if all four books were to be found, their collective knowledge could point the way to the item of power from the ancient tales. He proposes to the group that they aid the monks in finding the other three books and prompts them to sleep on it. The four heroes part without speaking much and rest after their unexpected battle.

The next morning the heroes each find notes on their doors imploring them to meet in the courtyard to continue their discussion from the night before. Ruethál, Gauthak, and Nahusha come outside to find no one else there. Suddenly a raspy voice calls out to them informing them that since they had learned the secret of the books they could not be allowed to live. A Kenku of the Frigid Talon summons three drakes to assail the heroes. Griffin comes rushing out after hearing the commotion and joins the battle.
The heroes manage to deal with the drakes, but the kenku bolts off into the abbey. The heroes give chase but are too slow; they burst into the library to the sound of a muffled scream only to find the Book of the Exile missing from its stand, alongside torn bloodied robes of one of the monks. The party finds a secret door leading to a hallway. Rushing after the Kenku they find themselves in an underground wine cellar, but here the trail runs cold. There is no sign of the Kenku or the monk, but the heroes notice a grate leading down into the sewers.

Abbot Elward comes down to ask the group what had happened and if they had seen or heard anything of Brother Xavros who had rushed to check on the book as soon as he heard the commotion in the courtyard. The heroes informed him of all that had transpired.

To be continued. . .

Playing Solitaire

I spent the evening writing a solitaire simulator. I’d suggest at least glancing over this article first so that it makes a little bit of sense.

Now, this may not be a version of solitaire you have ever played or heard of. I, however, have known it for as long as I can remember. My mother taught it to me at some point in my development, and I have used it as a pointless time waster ever since. It’s especially great when you are tired, because it takes absolutely no real thought.

Shuffle the deck.

Draw cards one at a time from the back of the deck, putting them on top into what I like to call the “play stack”.

The cards you pay attention to are the top card on the play stack, and the fourth one down. There are two rules:
1. If these two cards are the same suit, remove the two cards between them.

2. If they have the same value, then discard all four cards – the ones that share the value and the ones in between.

Rinse and repeat! You can do multiple discards per draw, so it’s fun when you get a nice chain reaction after a dry spell of no discards.

If you’re curious how that game turned out, whence I took the screenshots…

I ended up with two cards, not too bad!

So, of course somewhere along the line I realized that this would take no creativity to write into a computer program, considering there is no strategy, it is a simple reflex game. I wrote a simple javascript page to simulate playing many games, to gather statistics. The page is here!

I ran 10 million games, and found…
Win rate: 0.7%
Average cards left over: ~13

So, it looks like I can have a reasonable chance of winning if I play about 150 games. OK!

-E

Koans!

So, I found this site and it’s great.
http://sett.ociweb.com/sett/settJan2011.html#javascript-koans

It’s a set of sets of short exercises designed to introduce you to some of the quirks of a new language.

I blasted through the Javascript ones today. There could have been more, but it was quite fun.
Javascript Koans Github Page
Just go download the source and follow the instructions in the readme. These are definitely worth doing for anybody who wants a quick jump into Javascript!

-E

Creating an HTML5 Game, Part 1: The Objective

My most recent personal project has been creating a fully browser-native game written entirely in javascript. Considering I didn’t know javascript previously, it may be all new to you, but it’s definitely all new to me!

This first post will not be about javascript, but about setting the framework in place to begin work on this game.

Now, you can call me outdated, but my greatest inspiration comes from 2D SNES-era platformers and RPGs, so I’ll be using these as my design reference in these tutorials.

Games like these keep me warm at night.

The Objective

What I want out of this project is a framework, within which I can easily craft new levels, characters, and behaviors, without doing a whole lot of complicated coding. The features I want are as follows:

  • Pure javascript+HTML5 game, to run without any plugins or downloads on any HTML5-enabled browser.
  • Easy map and character making utilities, so that I never have to hardcode game assets.
  • Something fun to play!

Note: In general, I work by a design philosophy where I need to have something to play with to feel like I’m making progress. So, at every point in creating this game, I’ve got a working prototype, some of it rather hacked together. Cleaning things up and generalizing code comes later, when I need those features.

This post has the potential to get very long, so I’m going to break it up into quite a few parts, for my own sanity and yours.
Next topic: The Map.

-E

Hello, indeed

I’ve added an About Me page, and a Projects page. They’re both pretty simple, but it’s a start!

Hello world!

document.write(“Hello World”);
cout << “Hello World”;
println(“Hello World”);

It’s all the same to me.

-E