Monday, July 06, 2009

Using a game to teach regular expressions

Quick sketching....

You could have a game to teach people regular expressions. It might even actually be fun. I don't know if anything like this has already been done (a very quick look doesn't seem to show anything like it), but here's one way it could be done.

It might be a war between alien forces. You are commanding one side.

The enemy march in a single line in from the right side of the screen, and as the commander of your side your goal is to stop their troops reaching the left side of the screen. You can send out troops from the left side to attack the right side.

There are some number of diff types of enemy troops, and at your disposal you have specialist troops, each one of which can pick of a particular type of enemy troop.

So if the front of their line of troops is a 'green' alien, you send out a 'green' soldier. your troops will always win, as long as you send out the right type.

So you could just play by sending out the right sequence of troop colours...

But then their troops start moving faster and it gets harder to take our their troops one by one.

Luckily there are patterns in the troops... the front of their line might be one green soldier, followed by five blue soldiers, ending with a red soldier

So if you can set up a single command for 'one green', 'one or more blue', 'one red'.

What i'm talking about so far is like a regular expression where you are matching specific characters; they can also match classes of characters, like 'whitespace' or 'word characters' or you can have character classes...

And the game could gently introduce the ability for the player to have such higher-level control... e.g. some of the enemy might be carrying shields... blue ones with shields, red ones with shields and so on... so your 'attack specification' could allow the player to deal with more abstract classes like this.

Ideally, the game would give the player a gentle ramp up to the sort of abstraction regular expressions afford. the player could handle things fully manually... by manually specifying the pattern to meet... and then they would appreciate the ability to handle it in a higher-level way.

The player should be rewarded by being able to take out as many enemy as possible in the one command (the one reg-ex)... the more they take out, the more spectacular it should look, and perhaps the more points they would get (if there were points).

Here's some other ideas.

I can even imagine building a 'search and replace' mechanism into the game... perhaps the 'search' pattern could be use to specify what to target and the 'replace' pattern what weapons to use on each of those targets.

In addition to the idea of a game based around the idea of regular expressions, I might be actually use them to provide powerful input mechanisms in existing sorts of games... real-time strategy games strike me as a possibility.

Friday, July 03, 2009

My Vim setup

A description of my Vim setup, mainly for my own future reference, though could be of use for others. Intending to update this post when I make changes to the setup.


_gvimrc file


" The commands in this are executed when the GUI is started.
"
" To use it, copy it to
" for Unix and OS/2: ~/.gvimrc
" for Amiga: s:.gvimrc
" for MS-DOS and Win32: $VIM\_gvimrc
" for OpenVMS: sys$login:.gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

" set the X11 font to use
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1

set ch=2 " Make command line two lines high

set mousehide " Hide the mouse when typing text

" Make shift-insert work like in Xterm
map
map!

" Only do this for Vim version 5.0 and later.
if version >= 500

" I like highlighting strings inside C comments
let c_comment_strings=1

" Switch on syntax highlighting if it wasn't on yet.
if !exists("syntax_on")
syntax on
endif

" Switch on search pattern highlighting.
set hlsearch

" For Win32 version, have "K" lookup the keyword in a help file
"if has("win32")
" let winhelpfile='windows.hlp'
" map K :execute "!start winhlp32 -k " . winhelpfile
"endif

" Set nice colors
" background for normal text is light grey
" Text below the last line is darker grey
" Cursor is green, Cyan when ":lmap" mappings are active
" Constants are not underlined but have a slightly lighter background
" highlight Normal guibg=grey90
" highlight Cursor guibg=Green guifg=NONE
" highlight lCursor guibg=Cyan guifg=NONE
" highlight NonText guibg=grey80
" highlight Constant gui=NONE guibg=grey95
" highlight Special gui=NONE guibg=grey95

endif

set scrolloff=6
set shiftwidth=4
set softtabstop=4
set expandtab
set linebreak " so it won't linebreak in the middle of a word
set ignorecase smartcase
set columns=75
set lines=33
set backup " turn on backup
set backupdir=C:\james\Data\vimTempFiles " Set where to store backups
set dir=c:\temp " Set where to store swap files
set autoindent
set path+=c:\james\PhD\sources\notes\
iabbrev teh the
iabbrev taht that
iabbrev waht what
iabbrev htings things
iabbrev somethign something
iabbrev somehting something
iabbrev followign following
iabbrev thigns things
iabbrev scuh such
iabbrev everythign everything
iabbrev htink think
iabbrev thign thing

" the following is so the XML escaping/URL encoding mappings
" in allml.vim are available globally

let g:allml_global_maps = 1



Add-on scripts



How I've dealt with Vim's temp files

Details here.

Sunday, June 14, 2009

Switching between windows with a directional mouse-gesture (or a map)

Here’s an idea for how a computer operating system could enable you to quickly switch between windows. The idea is that you could press a some key or key combination to indicate you wanted to switch windows, and then you could specify which window simply by shifting the mouse pointer from its current position just a little bit in the direction of the window you wanted to switch to.

The operating system would guess which window you wanted to switch to and make it flash or something. If it had the one you wanted, you could press the mouse key and that window would get the focus. I think the system would have to figure out which window was, overall, most in the direction you've gestured.

If it didn't select the one you wanted, you’d move the mouse again to try to make it clearer which window you wanted. How would this work? Imagine that you’d moved the mouse to the right to indicate a window to the right, but you the one you actually wanted was further to the right of the one the system guessed.

To indicate that other one, you could just move the mouse a bit more to the right and it’d figure out you meant the window more to the right. Whatever the subtleties an actual implementation would have to deal with, I think there’s a good chance you could figure out a workable solution.

(On windows, instead of simply pressing a key, you could press and hold down the Windows Key and move the mouse pointer and then release the key once it has seleted the one you want).

As different approach, instead of gesturing direction, pressing the ‘switch windows’ could bring up, at the place where the mouse pointer was, a small schematic map of the desktop indicating all of the windows’ locations. Mousing over a window on that map would highlight the actual window it corresponds to; clicking it would switch to that window.

Friday, June 12, 2009

More birds-with-arms (pics)

Some more photoshopped pictures of birds with added arms, thanks to the good people on the Something Awful forums.

When I see a picture of a bird now without arms, like this one, my brain is thinking "amputee":



Here they are:










Wednesday, June 10, 2009

"Photoshop Arms Onto Birds!" (pics)

Over on the Something Awful forums, Paradox86 said "It's pretty simple. A friend and I agreed that birds are pretty pissed that they don't have arms. We decided this should be fixed."

Yes, this is what the world has been needing. Pictures of birds with arms. Yet it is somehow strangely compelling - there's some pretty brilliant stuff there... here's a handful of them:










Sunday, June 07, 2009

Rough notes on getting things done

Doing an assignment, writing a book, losing weight -- whatever the task is, there's no doubt that it can be hard to get things done. Here's some rough notes -- that I'd like to clean up sometime -- on ideas to make it a bit easier.

  • Build habits. Habits have momentum, and they can suck you into a task without you trying.
  • Associate a place with a task (if you can). That's one good way to build a habit. I go to a local coffeeshop to do PhD writing. That's all I do there, and I don't go there otherwise. I find it quite useful. If it's a place you don't do any other tasks at, it's less likely to trigger habits associated with them.
  • Make the habits generic, so you can always invoke them. If you make the initial task "start writing" (start writing anything - it doesn't matter what), then this applies regardless of what you are writing or what you are writing it for.
  • Minimised the (perceived) next task. Make it easy to start.
  • Doing has momentum. Make the initial task very simple. Simply by continuing to work on it, it can gather momentum and snowball and if that happens you don't have to even think about trying to do next thing.
  • Impose non-negotiable constraints (where possible). The coffeeshop I do my PhD writing at doesn't have any internet access, so I can't stuff around on the net even if I wanted to. (I understand that many tasks require internet access - this is just an example of the general principle). I also don't have Freecell or Solitare etc installed on my computer.
  • Have others around who can see you. That's another thing I suspect is an benefit of writing in a public place... it feels harder to slack off. May not work for some sorts of tasks.
  • Be prepared for initial Suck when getting into any new sort of task / setup. Basically it’s like developing a skill - it's going to take a while to get into it.
  • Learn to recognise and acknowledge when you’re refusing to consider doing something or how to do it, and just pushing it back. and that if you can do this, this could be all that’s required to actually get your major goals done.
  • We seem to have a tendancy to try to figure things out in our heads before starting. This tends to make the task seem to big, and you just end up staring at a blank page or screen. So learn to recognise when you’re doing this.
  • Related to this, there's a tendancy to want to go into a ‘perceptual response’ mode of thinking – you get stuck. (need to do more work to explain this).
  • As a longer-term proposition, try building up desire to achieve what you want to achieve.
  • Try to have “definite critiera” (I need to do more work here to explain what I mean) -– like writing something that reads from start to finish, rather than just a bunch of notes.

Wednesday, April 08, 2009

Some interesting-looking loft-style bedroom/desk/storage units

 
Some interesting-looking loft-style bedroom/desk/storage units (via dornob):