WorldMaker.netBlog2008 › October

BooInterpreter Class for XnaConsole

1 year, 10 months ago

I've been using XnaConsole in a couple of projects. It's quite handy to have around, and easy to plug in to a project. The author asks for people to share when they use it with an interpreter of a new language (he provides an IronPython example). For a recent project I wanted to use Boo instead, so here's my Boo interpreter:

//
// Boo Interpreter for XNA Console
//
// Copyright (C) 2008 Max Battcher.  All Rights Reserved.
// Licensed under the Microsoft Permissive License (Ms-PL).
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Boo.Lang.Compiler;
using Boo.Lang.Interpreter;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace XnaConsole
{
    /// <remarks>
    /// This class implements an interpreter using Boo
    /// </remarks>
    public class BooInterpreter
    {
        const string Prompt = ">>> ";
        const string PromptCont = "... ";
        const string Returned = "<<< {0}";
        string multi;
        public XnaConsoleComponent Console;

        InteractiveInterpreter interpreter;

        public InteractiveInterpreter Interpreter
        {
            get { return interpreter; }
        }

        /// <summary>
        /// Creates a new BooInterpreter
        /// </summary>
        public BooInterpreter(Microsoft.Xna.Framework.Game game, SpriteFont font)
        {
            interpreter = new InteractiveInterpreter();
            interpreter.Ducky = true; // Keep from having to make static type decisions in console
            interpreter.RememberLastValue = true;
            foreach (System.Reflection.Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies())
            {
                interpreter.References.Add(assembly);
            }
            interpreter.Eval("import Microsoft.Xna.Framework\nimport Microsoft.Xna.Framework.Graphics\nimport Microsoft.Xna.Framework.Content");

            multi = "";

            Console = new XnaConsoleComponent(game, font);
            game.Components.Add(Console);
            Console.Prompt(Prompt, Execute);
            AddGlobal("Console", Console);
        }

        /// <summary>
        /// Executes boo commands from the console.
        /// </summary>
        /// <param name="input"></param>
        /// <returns>Returns the execution results or error messages.</returns>
        public void Execute(string input)
        {
            object last;

            try
            {
                if ((input != "") && ((input[input.Length - 1].ToString() == ":") || (multi != ""))) //multiline block incomplete, ask for more
                {
                    multi += input + "\n";
                    Console.Prompt(PromptCont, Execute);
                }
                else if (multi != "" && input == "") // end of multiline
                {
                    input = multi; // make sure that multi is cleared, even if it returns ...

Film of the Moment: Choke

1 year, 10 months ago

Normally I spend the afternoon before classes attempting to get school work done but usually getting little more accomplished than getting my email checked before rushing out to catch the bus. So I figure I've had a more productive Tuesday than many in the simple act of shaking things up and making a visit to the local "cheap" Popcorn Stadium, which apparently is even cheaper than normal on Tuesdays (score!). I saw Choke and came out of the dark (romantic) comedy feeling somewhere in a nice place between depression, happiness, and few hours worth of useful schadenfreude drained from my system.

Choke, at least in film form as I have yet to read either novel, has some rough parallels to Fight Club, and its very easy for me to say that I enjoyed Choke much more than I enjoyed Fight Club. Part of that is just that Choke seems to have a few of the motifs that drew me to Fight Club, but doused in a darker humor (and I like dark humor) and more fully centered with, to me, a stronger through-narrative and connecting motif. The connecting motif to the film being that the main character Victor, portrayed by Sam Rockwell [1], is ultimately strung through a series of fantasy worlds and can be seen ultimately as a redemptive tale of coping with false realities, and this motif certainly says things to me. (I think this can be particularly contrasted with the darker Fight Club motif of building false realities out of boredom and need.)

I certainly think things are better because they are redemptive. Victor, to some extent, wins some control over his false realities as the movie progresses, even as some of the facts of true reality are slowly doled out to him. If there is ...

Spy Games

1 year, 10 months ago

There seems to be a lot of spy stuff in what I've been consuming lately. Halting State has a big involvement with a set of spy MMO/ARGs. (Some of which was stuff that I ended up predicting because it was almost how I would have done it.) On TV I've been watching Burn Notice, Chuck, Terminator: The Sarah Conner Chronicles [1], and caught the first episode My Own Worst Enemy [2]. Plus I discovered that the first season of spy-fi Invisible Man (from "way-back" in the Farscape era) is on Hulu. [4]

I was thinking about the weird idea of Spy Dating ARG and/or Reality Show. I'm not going to spend too much talking about it because I know it is outside the gulf of good taste, even if I think it would be awesome. But basically the idea would be: screw computerized psychology tests and 14 equally meaningless dimensions of matching and compatibility, just grab two crazy people that are attracted to each and build a romantic relationship the old-fashioned Hollywood way through fake explosions. Just imagine the blind date that starts with you attempting your best Ah-nold impression, "There is a very bad man after you. Come with me if you want to live," and is immediately followed by an explosion and some running and then will come the bad disguises and high-speed chase to some random industrial factory or warehouse...

But I can hear the screams of "how could you build a relationship on such fake emotion?" and "people don't like it when you fake blow up their apartment buildings and cars and pets and loved ones", so I'll stop there and let the idea simmer.

Here's a better idea: Over the holiday weekend I got linked to a ...

Blogs of the Round Table: Bring Out the Card Tables

1 year, 10 months ago

October's Topic

Family! Games! Games with Family!

In my July round table post I stated that I've always contextualized gaming as a social activity, even or perhaps particularly when it comes to video games. Much of that feeling comes immediately from the fact that I have a large extended family.

One of the earliest memories that I have of a big family holiday, probably Thanksgiving [1], included a card table set up somewhat centrally in the small den of my grandparents' home [2] with a jigsaw puzzle. It was in the way of mobility around the house and it subtly encouraged everyone to glance at it from time to time, and to contribute a piece whenever one might be found. I don't remember much more than that, or even if I ever saw that particular puzzle finished. I just remember a sense of the event being almost richer just by having that shared puzzle. (I was taught several times over that jigsaw puzzles are always more interesting as a social activity.)

There are many memories of other holidays and other games. Easter as a holiday, when you are young, is almost solely about the hide-and-seek competition for sweets.

But videogames have not been exempt: my first experience with a NES was when one of my (many) cousins would bring his for the holidays. Eventually I was the one bringing a NES around for the holidays. My grandfather [3] had a PC before I had one personally, and games were obviously a common activity upon it (and at times, them). Games would be requested as gifts and it was important to show off your haul of games to family, often debating which one to start with and play together. Even Gameboys would be passed around or gathered around ...

I decided that today was D2-Day

1 year, 10 months ago

Today I updated all of the repositories publicly accessible at repos.worldmaker.net to Darcs-2 format and I've decided to switch code licenses while I was updating everything. This means some changes if you are using my code (and I don't know of many that are), but I thought it warranted a quick post, particularly to talk a little bit about my thoughts on things.

Why Darcs-2 format?

Darcs is, IMNSHO, the most humane and powerful source control system in existence. The new Darcs-2 format of repository fixes some small annoyances with darcs-1 format and brings several years of new smarts to the way conflicts are handled. Switching to darcs-2 format now is a pre-emptive strike. It requires anyone seeking a copy of my repositories to upgrade to a version of darcs greater than 2, but with the recent release of darcs 2.1, I figure that that isn't too big of a requirement.

Why the license swap?

I've read recently of several people switching to more restrictive licenses and thought it time to buck the trend and switch to a less restrictive license. For all of my projects that I've licensed under the 2.0 GPL I'm switching them to the Microsoft Reciprocal License (Ms-RL).

I've waffled over the GPL for years. I've never been quite happy with the FSF interpretation of the GPL and I've had to use the Creative Commons deed to better explain some of my own differences in interpretation. Worse, the GPL 3.0 contains clauses that just seem wrong to me, with some weird extra baggage. I could talk for a while about my concerns with the AGPL or Affero GPL. Basically, I think that in the name of copyleft the GPL, and moreso the ...

On Serious Games and the Culture of Amateurs

1 year, 11 months ago

I just finished Halting State in about a week, as it appeared to be written just for me as I had got the impression from the reviews I had read last year. The following discussion was further enhanced, tangentially at least, from the book and I debated including spoilers but instead may save that for a follow-up or an "of the Moment" post.

At the IdeaFestival lecture by Jane McGonigal one of the few respondents in the brief Q&A session was a surgeon and he spoke of the increasing video game-like nature of surgery (remote operations using video and sophisticated telemetrics) and pointed out to the assembled that with a decline in professionals interested in surgery that we are ever closer to seeing "amateur video game surgeons" taking over surgery operations. He asked Ms. McGonigal, albeit as an indirection to asking the assembled crowd and I paraphrase, "Does that scare you like it scares me?" I'm going to come back to this question, but I thought it more interesting to take the question by starting in easier territory with a couple of examples that fascinate me...

Zombie Squad is a community survival program, somewhat akin to Boy Scout civic duty game (levels, badges), where members are encouraged to think about disaster survival and recovery by thinking about the (wink) inevitable Zombie Apocalypse. To be perfectly honest, how lame does Community Emergency Response Team sound in comparison to joining a Zombie Squad?

Plus, Zombie Squad is rich in game potential... it's not hard to come up with cool concepts for "zombie scenarios" that test individuals and teams of players using modern gadgets (custom software for GPS-enabled cellphones, etc...) and its not hard to keep people playing those when they get a spare Weekend. How many people would get ...

Colophon Copyright © 1999-2010 Max Battcher / WorldMaker. Some Rights Reserved.

With our thoughts, we make our worlds. Font Hosting by Kernest.com. I only buy the best Robots — All my Robots are GSD ServDev® Brand.