Category Archive: Geekery

Ticinus River: Respect the Ponies

“Hah! The Carthaginian cavalry! What can they do to” [dies]
       – Publius Scipio, lately lamented Roman general in this game

Ticinus River is a little skirmish—well, not to the Romans, I suppose—next to the Ticinus River, but all the river does is run along one side, not trapping anyone on the other side of it. Although don’t underestimate terrain on the edges of the board; in the game of the battle of Crimissos River, Timoleon only managed to not get killed by Carthaginian’s Sacred Band because his unit could get to the hills (representing bluffs) on the far edge of the board.

Anyways, returning to the Ticinus, basically it was a very one-sided battle. Publius Scipio underestimated the Carthaginian cavalry and marched straight into their red-squared horses (the heavy horses, who hit with 4 dice instead of 2 for the Roman light foot) and got out-flanked by the green-circle horses (light cavalry, who run very fast) on either side with good leaders (Maharbal1 and Mago). The scenario claims Hasdrubal was in the thick of the battle, charging with the heavy cavalry, and managing not to die, or even get all that close to dying. However, the war council leader is listed as Hannibal, and seeing as “Hasdrubal” was competent, I’m inclined to believe the scenario is mistaken and that was really Hannibal.

Scipio did have medium cavalry, but not enough leadership (actually, more like almost not any; he was the only Roman leader on the field) in either flank to make up against the light cavalry coming straight at him. The Carthaginian side quickly got to their six flags, and the Romans only managed to get one.

It was all over very quickly. In the game, Scipio almost escaped. Almost.

In history, Scipio was able to return, wounded. He attempted to warn the other Roman leaders about what had happened. This did not go over well.

“Hah! You pansy, you got beaten by a bunch of ponies!”
“But… no… you don’t understand… red ponies, green ponies!… so horrible… ” [dies]

Actually, in history Scipio managed to survive and eventually steal some green ponies of his own. Meanwhile, the Romans did not learn to respect the ponies, much to their grief, which they apparently did not learn from until Scipio came back.

In summary: RESPECT THE PONIES.

  1. I know, sounds like something cats hock up. []
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

I Think I Finally Got the Hang of Bagradas

This particular scenario is sort of a starter tutorial on using calvary to good effect, and also one of the rare scenarios in the base game featuring elephants. I’m not Hasdrubal this time, but Xanthippus. (One of the more ancient Hasdrubals is on my right flank. I’m not sure that was a great idea, then or in this game.) Hamilcar is waay over on the left flank. I guess Hasdrubal needed supervision or something.

On the other side (I’m not sure why I side on the Carthagian army for these scenarios, especially when I keep losing, even when playing against myself) are the Romans this time, led by Regulus and Anonymous Leader Guy.

My problem in previous scenarios is that I didn’t know how to handle calvary. If you don’t handle them correctly, they (having, basically, life points of 3 blocks versus foot units with 4 blocks) they get slaughtered. Elephants are even worse, consisting of only two life points, but it helps that they ignore one side of the combat dice rolled against them.

Calvary is very mobile, but I could never figure out the right time to evade; and elephants are slow but man, you don’t want to be a strong unit and fight against them. The way elephant combat works replicates them historically stomping heavier units who can’t get out of the way, and do poorly against fleeter, though less powerful, units. It’s rather simple and brilliant.

The Roman army in this scenario is very heavy on foot (heavy foot and medium foot, with tiny sprinklings of light foot), whereas the Carthagian army has more calvary units and the elephants, and some foot.

I read the historical paragraph a little more closely this time, and found out it also contained some strategy tips (which I had always sort of glossed over before):

The
Carthaginian cavalry and elephants routed the Roman cavalry, and then turned on the flanks and rear of the Roman army, now fully engaged with the Carthaginian infantry. The Roman army disintegrated. Those who survived told of the horror of being overrun by elephants and cavalry.

I really should have listened to that earlier. And that was exactly what I did—I held back on the elephants but still moved them (I think of the term “developing pieces” in chess) to provide support for the Carthagian foot units, and moved calvary more as kind of guerilla movements, each with a leader to provide a combat bonus.

And it pretty much happened like the historical version. It didn’t help the Romans that they had only four cards per turn (which is how you order units to move, and sometimes you get cards that aren’t ideal, because war communications are not—another simple and brilliant simulation that doesn’t get in the way), to represent to dumbassness over-confidence of Regulus; and six cards for Xanthippus, who actually had a clue and trained up his army beforehand.

The Cartagians achieved the goal of 7 flags fairly easily. I kept playing afterwards, though, to see if the Romans could fight back. It… didn’t work out so well for the Romans, because by this time the slow Carthagian foot had made it to the front lines, and the Roman heavy and medium foot had been pretty much stomped by elephants, leaving the rest of the Romans easy pickings. (The elephants each had to retreat, actually, but when they do that they still trample the opponents and friendly units in the adjacent spaces, so… yeah. They’re quite, quite dangerous.)

Regulus was killed when his third unit died around him and he became more vulnerable to the leader hit rules; Anonymous Leader Guy fled the battlefield. All the Carthagian leaders survived, although Hasdrubal (whichever one he was) went into combat around halfway through the battle, then fled nearly off the battlefield on his own side, and never rejoined the rest of his homies and seemed to have a smoke with the rest of his medium calvary unit. Meanwhile Xanthippus and Hamilcar almost died four times each. I don’t know if this is what happened in the real battle, but somehow I wouldn’t be terribly surprised.

I can’t wait for next year. Or the next scenarios, now that I think I have the hang of mounted units. I hear in later expansions there are medium and heavy camel units. So neat.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

A Table Set for Four, Seats One

A very nice lady was just in this afternoon to close my mortgage refinance. We talked and joked and I signed a zillion sheets of paper and handed over a scary amount of money (but I’ve done worse over the years; buying a house on the island with 20% down takes a lot out of you).

The previous night, though still sick, I cleaned and vacuumed but it probably wasn’t enough after two weeks of being poorly. Still, it had a purpose, and so wasn’t bad.

After she left, I realized that I’ve never had anybody else but me sit at that dining room table, which I bought in the overexcitement of having my own place. It’s been a few years.

It’s a perfect size for most board games. It can, if you extend the wings, almost fit most of Arkham Horror on it (which is a long way to go to set up a solitaire game, but oh, so worth it).

It was strange, having another person in the house, sitting there. I have to start inviting friends over, once I’m well enough to clean like crazy. Although I am, as you might imagine, a bit short on friends due to my general paranoia.

But it felt good to have someone else there. And I wasn’t scared or nervy, which tends to happen when I’m around people. Especially people I’m familiar with—they see a flirty ditz, but my pulse is through the roof.

I wasn’t scared. I didn’t know her, of course. But still.

How strange.

I’m sure the feeling will go away.

On the other hand, maybe this means I’m starting to go native, in this strange land where it’s impolite to hit someone, even in private.

But I’m so not letting anyone else in until I’ve cleaned the kitchen counter and vacuumed the sofa and dusted everything, omg.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

Sending Little Wooden Block People Off to Die

I’ve been ill, but I still received my order of the entire Commands & Colors: Ancients series. Dang, it’s a lot. Lots and lots of wooden blocks to put stickers on; I was able to do a bunch while I was too sick to do anything else, like thinking, and am now a champion of putting the stickers on straight 90% of the time.

For those who don’t know, Commands & Colors (C&C) is a series of elegant war games by Richard Borg1. Some grognards2 consider this series rather too simplistic, kind of a “gateway war game” to us noobs. But I like the system, because C&C non-epic games end in half an hour, instead of four. (Even C&C “epic” games, which are huge, take a quarter of the time for a similarly sized war game in most other systems.)

C&C has been implemented in multiple periods and even fantasy:

  • Battle Cry is the oldest published one, featuring the Civil War, and actually published by Hasbro3. It has little plastic pieces, actually quite nicely molded. Of C&C games, it’s the simplest.4 Unfortunately, expansions were never produced, and it’s out of print.

  • Memoir ‘44 (published by Days of Wonder) is the second oldest published one, but still in print. It features World War II, has a zillion expansions, nicely molded plastic pieces, and now many scenarios—as well as a pretty neat campaign system. Of the C&C games, this is the next step up in complexity from Battle Cry, but more polished. As a result, I’d say it’s the best C&C game for the casual player.

  • After the success of Memoir ‘44 came the publication of C&C: Ancients (GMT Games), and it’s actually somewhat recent (within the last three years). It has quite a few major expansions, and is the most complex in terms of unit types and rules, yet still simpler than many traditional war game systems. Has wooden blocks with stickers you must apply yourself, but the end effect is actually very neat and easy to deal with, in terms of storage and setting up the starting position. And now it also has a huge number of scenarios.

  • And the newest C&C game is BattleLore (first published by Days of Wonder, then handed over to Fantasy Flight Games). This is the fantasy version of C&C, and has really nice plastic figures. It also has what’s called Lore, which is basically like adding Magic: The Gathering style effects to C&C, and is the most wild and, to me, fun, when played with Lore (although many more staid gamers prefer to play without Lore). Unlike other C&C games, BattleLore allows players to set-up/draft a detailed war council (which affects what kind of Lore you can play), and there are quite a few expansions, but they don’t cover as much ground as Memoir ‘44 or Ancients (but it’s got dragons, and that must count for something).

    I like really it, but there’s a lot of potential (more races than just dwarves, goblins, and European men) that may never get realized, because producing the plastic pieces is really, really expensive (especially these days). If all the expansions that Richard Borg is thinking of implementing ever get produced, it may even take over Ancients in terms of number of units. In way, while BattleLore is wild and fun, right now its present feels more restrictive than its siblings (except for Battle Cry, which is dead).

    I don’t mind the smaller number of official scenarios for BattleLore; much of it is about drafting, and so far it’s the only C&C game that’s additionally allowed for special drafting when building armies on the spot.

I fell head over heels in love with Ancients and its expansions when visiting friends the last couple years, so getting the entire Ancients series all was my way of being happy this year as I won’t get to visit them. (Still cheaper than flight seats, too.)

I played a couple games today and yesterday by myself (because I am still sick, and work is such that I end up unable to reach gaming groups consistently, even the tiny one on the island itself), the first two scenarios in the base game: The Battle of Akragas (406 BC) and a skirmish at the Crimissos River (341 BC). They were quite fun, even by myself (and a good way to practice so that next year I will not get my ass completely whupped).

First off, let me say that one of the reasons I love C&C games is that every historical scenario comes with a paragraph or two of its history, and what went wrong or right. And how stupid or smart generals/officers were. Sometimes they were extremely stupid, to the point where I realized that the epic stupidity that Sir Pratchett wrote in Jingo actually did exist. Ye gods.

Crimissos River is rather interesting; because the Carthaganian dude, Hasdrubal5, was a complete dumbass. In history, he never sent scouts while trying to ford his army through a river, so he didn’t know there were a bunch of Syracusan troops about to ambush them on the other side. It was epic dumb on the level of Lord Rust, and the outnumbered, though badass, Sacred Band got slaughtered and it was very sad, especially as the flub wasn’t their fault.

In the game, even though the Carthaganian side had more units, most of them were stuck on the other side of the river, just like in history. Most of them were the good units, too. (One Carthaganian chariot sucks against five units of heavy foot units). And just like last year, I still couldn’t get them across the river in time before one wing or the other of the Syracusan army descended upon dumbass Hasdrubal and the poor Sacred Band. The Sacred Band were a pretty scary special unit, actually, and almost got all of the necessary victory flags6 by themselves.

And then they ran into the last of the Syracusan heavy foot and died horribly. Almost everybody else was still stuck on the other side of the damn river, and anybody on the side of the river with the Syracusans got slaughtered. Last year, and tonight, I said, “You goddamned idiot, Hasdrubal, why couldn’t you have sent scouts so my game would be more balanced,” although to be fair the scenario is surprisingly balanced (fewer Syracusan troops that would have been slaughtered… had the units across the river been able to get into battle).

Afterwards, I had the thought I always have when playing historical war games, like C&C and others, which is: these were real people, and they really did get sent off to die. Here’s the historical paragraph and everything. Here are the dumbasses who got real people killed, and the smart guys who, well, still got people killed, but fewer of them, usually. Here are the little wooden blocks or plastic figurines that sometimes represent the historical unit realistically, depending on the scenario.

D-day at Normandy Beach (an epic scenario) in Memoir ‘44 is horribly hard to the Allies, too. Bloody as hell, like the real history, and winning as the Allies in that scenario is such a thin margin that I’m surprised we managed it (of course, that may have had something to do with sending many many many people to die instead of merely many). I can never play Memoir ‘44 and not feel incredibly sad, even though it’s technically a good way to remember the awful battles so that people remember that they happened, and maybe won’t let them happen again (or… not). It’s too recent, somehow. Ancients I can deal with because these are long-dead people, almost the stuff of legend, even down to the little green foot units that get killed so easily when going up against just about every other unit. BattleLore is easiest to deal with, of course, because the people there are all made up, unless you go with the historical scenarios, like Agincourt, in which case… they weren’t.

Everything is helped out by the fact that, of most war game systems, C&C is the most abstract. If it weren’t for all the historical paragraphs, you might not feel very much when your warrior units charge and come to naught in the river. Darn you, Richard Borg, for Doing the Research.

What amuses me most is how a few of the scenarios in Ancients are surprisingly similar a few of the scenarios in Memoir ‘44… which means that people made the same dumbass mistakes in 300BC as in the mid 20th century (although to be somewhat fair, the one in Memoir ‘44 had a bridge. Which still didn’t help that much). It’s enough to make one double facepalm. Admittedly, I myself have also got to stop being dumb at tactics, since I still lose in scenarios when I’m Hannibal ferchrissakes, but people like Hasdrubal sure didn’t help.

So, I still haven’t bought Memoir ‘44, even though I think I would enjoy its mechanics, its aliveness in terms of expansions and scenarios and campaigns, its greater simplicity, its far better components. But desperately marching little stickered wooden blocks into cavalry is bad enough.

  1. Not to be confused with Richard Berg, who could have made Fandom Wank several times over if it had been around during his… more controversial days. []
  2. War game geeks. Serious geeks. []
  3. The big toy players are not, typically, into publishing non-party, non-classic games, so this was an extra special occasion. []
  4. Though that’s not the same as boring or lacking in strategy. Definitely, definitely, not. []
  5. Whichever one of him fought this battle. There were several dudes of this level named Hasdrubal. []
  6. One killed unit earns you a victory flag; this particular scenario is played to five flags. []
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

Actually Short: My Internet Rules (Inspired by Fandom Wank)

When interacting with people on the internet these days, I do my best to remember these tenets:

1) Will what I’m about to say end up on Fandom Wank, and not in a good way? If so, what I’m about to express is RAEG!!1!! and not legitimate anger.

2) The only proper way to react to RAEG!!!11!! is to grab the popcorn and wait for the show to appear on Fandom Wank.

ETA: These rules also apply to stupid as well as RAEG.

Being able to discern what falls under RAEG!!!1!!!1! and “rage” means hanging out on Fandom Wank for a while and processing/analyzing what you see (make sure you don’t fall into RAAAEEEEG!!!11!1!! because wanking on wanks definitely falls under tenet #1).

Make sure you’re not drinking anything during this time.

For historical study, check out the Fandom Wank Wiki.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

Google Buzz: We Will Know Where You Are.

Up until yesterday I was somewhat cautiously using the Buzz Mobile App to post Buzz updates from my iPhone.

This morning I found, when trying to post, that I was being asked to agree with a TOS wherein, among other things, it stated that my current location would be displayed whenever I posted to buzz via the Mobile App.

And there was no way to opt out of it, unlike with Twitter and many of the Twitter apps. Or, hell, Facebook even.

My favorite quote from above: “Consent to the collection, use, sharing, and onward transfer of your data, including but not limited to voice and location data….”

Some of that I’ve always understood in Google apps before, because if you don’t allow them to store your data, they can’t do anything for you. On the other hand, I’ve never seen a Google app TOS before where they didn’t let you hide information that they didn’t need to get the job done. Like location when I’m not trying to use Google Maps.

The thing that worries me is if Google was already doing this, but hadn’t thought up the warning until this morning.

As y’all may know, while I do advertise my location as “Bainbridge Island, WA”, that’s one thing versus the GPS-triangulated location of the street corner I happen to be at. I have stalkers on my tail, and as such I do not post my precise geo-location on every Tweet.

Even Apple understood that, and let me turn off location services when I take pictures, wherein they don’t insert geo-location into my JPGs, and I don’t upload a YouTube of me throwing their iPhone through the wall. In fact, Apple let me turn off location services entirely, only to be turned on with the appropriate dialogs when other iPhone apps asked for it. A polite “no” didn’t freak out most non-map apps. I mean, why does an I-Ching program really care about where you are anyways? Or a camera?

It’s a simple arrangement.

Not simple enough for Google, apparently.

Yes, I do have a filter on my privacy. Some things I’d like to make public. Some things I want to keep private (it takes extra money to do so at times, but it’s doable). If a service refuses to let people make that nuanced distinction outside of “well, just don’t use us then!”, that’s either pretty damn arrogant or pretty damn lazy.

Google, you may intend no evil, but that doesn’t mean evil is never a result.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

iPhone Games I’ve Started to See in My Dreams

My, I never realized I’d end up using my iPhone as my Most Commonly Used Game Console. But then again, I don’t play anything other than turn-by-turn video games.

I always kind of thought “seeing Tetris blocks fall when I close my eyes” was… more… a figure of speech. Turns out to be far more than that.

Here are some I’ve just started seeing in my head, usually when I’m trying to fall asleep, and sometimes I dream of playing them.

TanZen

This is the best tangram puzzle game implementation on the iPhone. And, I daresay, anywhere. Including real tangrams. The graphics, the intuitive controls, the fact that you can turn the music off and listen to your own (not something to be overlooked), and the fact that new puzzles are added every few months. It comes with over 200 now.

Boggle (Official)

It’s ideal Boggle solitaire (and should, be after all, being official). It has everything, including the shaking-of-the-boggle-cube, which is not to be underestimated when implementing a word game. Includes little achievements to unlock, and some interesting variants that could only be implemented with a timer on an iPhone, like Portal Boggle (cubes at the beginning and end of words you make swap places).

Poison

If you’ve ever played the card game by Reiner Knizia, you know that it’s an addictive trick-taking game in the manner of hearts, except better. For instance, all three normal suits can score negative points, but you can shoot the moon in any of them (indeed, strategy centers around shooting the moon). And that’s just the start. It’s Evil Hearts with more strategy. The iPhone game is solo.

Rummikub (Official)

I don’t like playing Rummikub in person, because there is a lot of tile manipulation involved. Which is quite fun, but still: tons of tiles, tons of manipulation. This little app makes the manipulation intuitive and cool, and the little tile sounds are wonderful, as is the animation. As in real life, you’re best off with three—in this case virtual—opponents.

WordSearch [AFKsoft]

There are a lot of find-words-in-a-grid games in the App Store, but I currently like this one best. A lot of strange categories to please any geek (dinosaurs? constellations? greek myths?), as well as daily Small/Medium/Big-sized puzzles with results that go to a leader board server. It’s simple, and it doesn’t have eye-breaking backgrounds unless you want it to.

i.Game 16 Mahjong

This is real Mahjong, the rummy and, basically, discard deduction game, not that solitaire tile-matching thing. Mahjong has multiple variants, and this is Taiwanese 16-tile hands. The AI is not all that great, or so reviews say, but at least this app is stable. Mahjong tile sounds? Satisfying check. The games, like real-life Mahjong, can take foreeeeeever, but it auto-saves and picks up games easily. I suck at Mahjong, but am addicted anyways.

Button Men

The classic game of beating people up with dice of various polyhedral shapes. You can play it solo, or play with two in pass-and-play fashion. Comes with Soldiers and Vampires, along with a new exclusive set (so standard, swing, shadow, and poison dice). They plan to do more, so I hope one day for speed dice! There are individualized taunt and beaten messages for each Button Man you play against, which I really like.

I usually played Niles back when I had the buttons. Which might tell you everything you need to know about me.

Mach Dice

I quite like this die roller app. Does any number of polyhedral dice you like, including funny sizes (like 14 and 16) and the lesser sizes (like 2). Realistic rolling engine. Eats up CPU and memory like anything, but still very stable and better than rolling 15 d10s manually. I wish you could add custom dice (like Battlelore or Heroscape dice), but otherwise it does quite a good job. And now I have a war game that requires 2-sided dice (at one point 20 of them were required1), so this has become an invaluable app.

  1. The single unit being attacked did end up requiring this much to bring it down. Fickle, fickle dice. []
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

Apologies On Ebook Delays

Ebooks have been delayed, in particular for Shadow Unit and a couple of side projects, because I had serious problems with Crossover Mac and discovered yesterday that I needed to pay $40 more for it to be compatible with the most recent version of X in Leopard. I’d bought Crossover Mac maybe a couple years ago. I need it for Windows emulation, vital for things like mobigen and seeing whether the Microsoft Lit conversion is readable.

The discovery was a little distressing. That could have been at least 4, probably 6 or 7, ebooks across the Kindle store, Fictionwise, and Webscriptions… and yes, I’m in the process of buying my old library back, which is why I care about the velocity of leftover-money over books on a per month basis.

But CodeWeavers needs money like anybody else, including me. c’est la vie, and it probably did suck to try to figure out what was causing the rapid-crash problem (things involving Wine and X usually do). Bless them.

Anyhoo, we’re back on track over here in the eBookery, and once Shadow Unit updates later this evening (or sommat) the updated Extras will be available with both last week’s and this week’s.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

Live Word Count in VIM!

A live word count (one updated as you type) is a feature I love when writing non-technical documents and non-programs.

For instance, newer versions of Wordpress feature this at the bottom of your new post text box (though it waits until you’ve hit a rest period in your typing before it updates the count, although this is a very short rest period indeed). It’s also a great feature of surprisingly few author-orientated writing programs (Scrivener is one).

However, for items that are neither Wordpress blog posts nor fiction, I prefer to use vim, because you can’t take the programmer out of the writer sometimes. Heck, even for blog posts or fiction I often prefer vim (especially in the area of syntax highlighting). But sadly, for a long time, vim did not come with a live word count.

Until now.

Well, sort of. There’s a version that’s been cooked up by one of the commenters on Stack Overflow.

I use this just in macvim, not terminal vim, because macvim is for more extended projects/programming, and terminal vim is for quick and dirty scripts. Thus I only really care about wordcount in the Mac equivalent of gvim.

But no worries; if you use .gvimrc in addition to .vimrc, then .gvimrc acts as overrides for things in .vimrc. Excellent, of course.

So this went into my .gvimrc (and really, it should go into a separate file plugin or something in my .vim directory, but I’m too tired to care at the moment):

"-------------- word count ---------------
" from http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim/120386#120386

"returns the count of how many words are in the entire file excluding the current line
"updates the buffer variable Global_Word_Count to reflect this
fu! OtherLineWordCount()
    let data = []
    "get lines above and below current line unless current line is first or last
    if line(".") > 1
        let data = getline(1, line(".")-1)
    endif
    if line(".") < line("$")
        let data = data + getline(line(".")+1, "$")
    endif
    let count_words = 0
    let pattern = "\\<\\(\\w\\|-\\|'\\)\\+\\>"
    for str in data
        let count_words = count_words + NumPatternsInString(str, pattern)
    endfor
    let b:Global_Word_Count = count_words
    return count_words
endf    

"returns the word count for the current line
"updates the buffer variable Current_Line_Number
"updates the buffer variable Current_Line_Word_Count
fu! CurrentLineWordCount()
    if b:Current_Line_Number != line(".") "if the line number has changed then add old count
        let b:Global_Word_Count = b:Global_Word_Count + b:Current_Line_Word_Count
    endif
    "calculate number of words on current line
    let line = getline(".")
    let pattern = "\\<\\(\\w\\|-\\|'\\)\\+\\>"
    let count_words = NumPatternsInString(line, pattern)
    let b:Current_Line_Word_Count = count_words "update buffer variable with current line count
    if b:Current_Line_Number != line(".") "if the line number has changed then subtract current line count
        let b:Global_Word_Count = b:Global_Word_Count - b:Current_Line_Word_Count
    endif
    let b:Current_Line_Number = line(".") "update buffer variable with current line number
    return count_words
endf    

"returns the word count for the entire file using variables defined in other procedures
"this is the function that is called repeatedly and controls the other word
"count functions.
fu! WordCount()
    if exists("b:Global_Word_Count") == 0
        let b:Global_Word_Count = 0
        let b:Current_Line_Word_Count = 0
        let b:Current_Line_Number = line(".")
        call OtherLineWordCount()
    endif
    call CurrentLineWordCount()
    return b:Global_Word_Count + b:Current_Line_Word_Count
endf

"returns the number of patterns found in a string
fu! NumPatternsInString(str, pat)
    let i = 0
    let num = -1
    while i != -1
        let num = num + 1
        let i = matchend(a:str, a:pat, i)
    endwhile
    return num
endf

"example of using the function for statusline:
"set statusline=wc:%{WordCount()}

"-------------------------------------------

set statusline=%<\%f\ %y%m%r\ wc:%{WordCount()}%=%l,%c%V\ \ %L\ lines:%P\  

The last piece of configuration is my normal statusline with word count inserted, so it shows up like this:

gvimrc status line with word count

You can get more help with the statusline codes in vim via :help statusline, or visit the vim online documentation project, at ’statusline’. (You can search the rest of the online documentation as well.)

This has been my geekout for the day.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email

RubyEpub Tools (ruby-epub) 0.0.2 Released

Added the ‘add-to-ncx’ operation on the epub script, and removed the creation of the template HTML file, which just got in the way.

See the ruby-epub GoogleCode page.

  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • BlinkList
  • Twitter
  • Facebook
  • Digg
  • Yahoo! Bookmarks
  • Propeller
  • Sphinn
  • PDF
  • email