Missile Launchers with F#

hasKitty Chris Smith had a talk at the CodeMash conference in January 2010 titled “Being an Evil Genius with F# and .NET”.  Chris created a post about his talk and doing Computer Vision, Speech Recognition, and shooting missiles at people all with F#! 

Here is a bit of his speech recognition code using the System.Speech.dll:

let recognizerEvent = getWordRecognizer()

// Main handler - convert spoken text into RL commands
let handleWord spokenText =
    printfn "Recognized Word: %s" spokenText
    let action = 
        match spokenText with
        | "up"  // Has a hard time recognizing this :(
        | "north" -> MoveUp(20)
        | "down"  -> MoveDown(20)
        | "left"  -> MoveLeft(20)
        | "right" -> MoveRight(20)

        | "fire"  -> Fire

        | _ -> NoOp
        
    performAction rocketLauncher action |> ignore

// Exit handler - specifically look for exit/quit
let terminateLoop = ref false
let terminateLoopHandler = function | "exit" 
                                    | "quit" -> terminateLoop := true
                                    | _      -> ()

// Hook up event handlers
recognizerEvent.Add(handleWord)
recognizerEvent.Add(terminateLoopHandler)

while terminateLoop.Value = false do
    System.Threading.Thread.Yield() |> ignore
()

Chris happily provided the source code as well, RocketLauncher_v1.0.zip

Tags:

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.