Wolfram|Alpha: Systematic knowledge, immediately computable.

Thursday, April 29, 2010

I Scream, You Scream, We All Scream for DICE Scream!

Doing some mathematical work with Maple 13 tonight and needed a break. Thinking of the recent fiasco with DICE and their new game Battlefield Bad Company 2 (see Pings? We Don't Need No Stinkin' Pings!), I decided to see how hard it would be to connect to EA's central server (where the information for the game server browser comes from - the one that doesn't work properly in the game) using Maple. I'd already done some work reverse engineering the traffic for this and the patcher, looking to ease the pain of users with the  game browser and the patch process (yay for Steam - patches there just work, no worries of overloaded, flaky EA servers!)

Maple, for those not familiar with it, is an extremely sophisticated application for doing all things mathematical. The product has an amazing list of capabilities for mathematical analysis, graphing, and programming. It is however primarily a mathematical tool, competing with the likes of Mathematica and Matlab. I use all three, Mathematica being my personal favorite. For quick and dirty, however, I find the 'Document Mode' in Maple to be ideal for rapid exploration. I often do proof of concepts there, and when the ideas are fleshed out, move them to Matlab or Mathematica.

So how hard would it be to get to the Electronic Arts centralized server, using a tool completely out of its domain (kind of like using a champagne bottle for a baseball bat), without any of the raw socket nonsense that the game developers used? See for yourself - seven lines of Maple gets you the initial connection and response. A handful more lines would get you a complete server browser. Without the hassles the game introduces by using raw sockets. Pretty powerful tool, doing things out of its real domain. It makes me wonder even more: what were the game developers thinking when they chose to use raw sockets?

Maple Code:

with(Sockets);
sid := Open("159.153.235.12", 18395);
reply := Array(1 .. 65, datatype = integer[1]);

WriteBinary(sid, Array([67, 79, 78, 78, 64, 0, 0, 0, 0, 0, 0, 91, 80, 82, 79, 84, 61, 50, 10, 80, 82, 79, 68, 61, 98, 102, 98, 99, 50, 45, 112, 99, 10, 86, 69, 82, 83, 61, 49, 46, 48, 10, 80, 76, 65, 84, 61, 80, 67, 10, 76, 79, 67, 65, 76, 69, 61, 101, 110, 95, 85, 83, 10, 83, 68, 75, 86, 69, 82, 83, 73, 79, 78, 61, 53, 46, 49, 46, 50, 46, 48, 46, 48, 10, 84, 73, 68, 61, 49, 10, 0], datatype = integer[1]));

ReadBinary(reply, sid);
Close(sid);
convert(subs(0 = 32, 10 = 32, convert(reply, list)), bytes);

EA Server Response:

"CONN ATIME=1272627041 TID=1 activityTimeoutSecs=240 PROT=2"

Hello, EA! All your base are belong to us!

I Can See CXLVI Frames Per Second!

You can find a myriad of posts in gaming enthusiast forums debating the need, or lack thereof, of high frame rates in PC gaming. Inevitably, someone posts a claim that at least some 'X' frames per second are needed before it doesn't matter, or even that no such upper limit of  'X' exists, to which I usually reply with the title of this entry.

And just as inevitably, the 'experts' and 'pro gamers' chime in with claims that ridiculous frame rates are needed, and how they can see and notice a difference with hundreds of frames per second.

Invariably, these forum arguments boil down to someone referencing a Wikipedia article, or some other forum post, all of which seem lead back to the same 'authoritative' reference: a couple of 'articles'  (one a dedicated web site) by an 'expert' making ludicrous claims based on research done by the Air Force many years ago regarding the 'persistence' of vision to a rapidly displayed single image.

The problem here (aside from the fact that the Air Force study has no real relevance with respect to our ability to utilize rapidly changing scene information) is that these two 'articles' are written by someone with no background of note, nor any expertise of any sort in the subject matter that I could discern.

In my opinion, the 'author' may also be a 'kook', having published other 'articles' of such scholarly note as 'We Made Contact', an expose on their 'scientific' analysis of newly discovered crop circles, with the conclusion that these are a response from a message sent to a distant globular cluster as part of the SETI experiments. Complete with a 'decoding' of the alien message. This 'article' demonstrates such an incredibly naive understanding of the physics involved in the transmission, or a purposeful use of misinformation in an attempt to bolster the credibility and 'wow' factor of the 'article', or both, that I'm really not sure what to make of it! Read it at "We Made Contact" for a serious laugh.

The 'gotcha' there: even though the target in question would require a round-trip message time of tens of thousands of years, the 'reply' took only a handful according to the 'expert' author of the 'scientific' article, while a trivial analysis shows that the probability of some mystery planet hosting aliens being close enough and in the needed direction yet unknown to us is nonexistent.

All this is aside from the fact you would need to believe the conclusion of the 'scientific' research of the 'author' that these Aliens exist, have somehow violated Einstein's Theory of Relativity, and even bothered to respond to us by carving these circles (and the 'Face on Mars', according to the 'study').

If you need to use this kind of thing as your authoritative reference, you might as well stop playing games, and just check with Sylvia Browne to have her tell you what your scores and stats will be.

There is no academically, scientifically sound study that supports the outlandish claims of this 'author', or the logical leaps made by many based on the 'facts' from these articles, or the claims by gamers that wildly overestimate their own physiological capabilities.

I actually heavily researched this, and consulted with real experts in the field during a venture funding analysis.

I want to be clear: I am not saying higher frame rates are not beneficial.

I am saying that the value where the ability of even gifted humans to take advantage of high frame rates is lower by a large margin than the claims of this oft referenced 'expert' and that of poseurs in forums.

Think you know better than the experts? Think you have supernatural abilities?

I publicly state here that the first person to either:

(1) Show a peer-reviewed academic/scientific study that supports the hypothesis "Humans can effectively utilize frame rates over 300 frames per second and can demonstrate a statistically significant increase in target acquisition and game score (test score) compared to 120 frames per  second"

or

(2) Demonstrate such an ability under controlled and accepted scientifically valid testing protocols,

will be awarded a $100.00US prize by me.

Interested parties can post their acceptance of this challenge here or email the author. The precise terms and conditions will then be determined by both parties.

(As an aside: there is at least one game I am aware of where the physics algorithms of the game appear to be inexplicably tied to the frame rate limit settings. In this game, one can raise the default rate cap, and this allows slightly higher jumps, etc. to be accomplished. Obviously, such coding horrors do not mean the higher frame rates are the cause of better target acquisition by the player...)

My shekels are safe.

Dedicated to James "The Amazing Randi" Randi.
Debunker extraordinaire. A hero of mine.
See Google to find his $1,000,000.00 challenge to 'audiophile' kooks that think $25,000 cables sound better. Hilarity ensues with the funambulistc help of  Pear Cable, maker of goof-ball speaker cables.

Wednesday, April 28, 2010

Flipping You the Bird, With a Flipping Bird That's Flipping Out.

Oh man, I want one of these! This bird borders on unbelievable. It not only can mimic dozens of calls from other birds perfectly, but when exposed to man made sounds, it mimics them too. I'd make a pair of little tiny bird headphones, and have it listen to BFBC2, so I could have it mimic the crazy accented Russian/English and weapon sounds in the game.

This video shows a bird from a zoo where construction was in progress. Among other things, it mimics:

1. Hammer
2. Chainsaw
3. Jack hammer
4. Lawn mower hitting sticks
5. Leaf blower starting
6. Power drill
7. Wood saw
8. Human voices
9. Two-way radio
10.Worker whistling

Video here: Lyre Bird in Action

Swimming in the Septic Tank with my Gaming Buddies.

C'mon in, water's warm! And there's flotation devices all over the place!

Seriously, you wouldn't go swimming at your local water treatment facility, so why on earth would a serious gamer try to run their games in an environment that is even more unhygienic?

I helped a few posters recently with a puzzling 'lag' issue. They would enter the game, but each spawn was met with a many seconds delay, and in some cases, the same puzzling delay would happen when accessing the game menus.

Turned out to be their anti-virus software getting in the way, and either disabling it, or adding all the game directories to the exceptions list, fixed the issue. I see this all the time, where some software turd causes a problem with a game, slowing things down or otherwise interfering with the game. Anti-virus, anti-malware, peer-protection, printer drivers, iTunes, Quicktime, peripheral drivers, etc., the list of cesspool floaters is endless.

Which got me thinking about something I ponder about periodically: Why on earth would a serious gamer have anything but the leanest, meanest OS environment for playing their games? What on earth is the reason to have an anti-virus running with a game that is from a trusted source (if you're stealing games, that's another story)?

I myself have always had separate Windows installations, one hardened for day-to-day activity and any uncontrolled network access, the others having only the drivers and software needed to play my games. Gives me the protection I want for regular activities and maximum performance, minimum hassle for gaming.

Many use things like Hardware Profiles (unfortunately deprecated in Vista and beyond) to 'minimize' unnecessary system load, but that can be cumbersome. Others use snake oil programs that purport to improve game performance by shutting down system processes and optimizing memory. I'll not argue the myth of messing with MS system processes, and what effect (none) it has on game performance. This is just another messy and questionable 'tweak'.

It is trivially simple to start with a clean Windows install and clone it to a separate partition to provide a multi-boot environment where one copy is hardened, the other is for gaming. The web is full of helpful tutorials that can guide even the most novice of users through the process. Users with the Enterprise and Ultimate versions of Windows 7 that allow native booting from VHD, can get equivalent functionality without the need to partition the hard disk at all.

That is the environment I use: Multiple VHD, each with exactly the environment needed for the games they contain, tuned and optimized (some games 'prefer' certain drivers, etc.), and only running things absolutely needed for those games. No A/V, no firewall, no junkware. Nothing that could affect the performance or otherwise interfere with my games. Another VHD contains a fully hardened Windows installation, with a combination of anti-malware/firewall/security that ensures safe passage when navigating the sewer we call the Internet.

A side benefit is that by using Differencing VHDs, all of this is done with very minimal space requirements: I don't have to duplicate the space required for each Windows installation, saving hundreds of gigabytes of storage. With Windows 7 Ultimate/Enterprise, I can boot 'natively' (that is, to the bare metal: a normal boot running at the full speed and capabilities of the hardware) or boot using a virtual machine to any of these VHD installations.

I can even 'boot' into the hardened environment using a virtual machine while already booted into one of my gaming environments should I need to download or otherwise access the web, without needing to reboot the machine. I can grab something from the Internet, have it completely scanned in the virtual environment, then drag-and-drop it into my gaming environment.

Maximal security combined with maximal speed. Another benefit to the use of a virtual machine in this case is the ability to snapshot the virtual hardened Windows, so if I do get exposed to some nasties, I can rollback time with the click of the mouse. Cool! Should some really extreme corner case of attack or malware successfully corrupt or infect one of my 'game' environments, it stays isolated to that environment, and I can restore it from backup ludicrously quickly (another Differencing VHD benefit).

I go ahead and run everything in the 'game' environments under a 'real' administrative account, since even in 2010, there are developers that seem to still be incapable of writing a properly behaving userspace/usermode game (see Pings? We Don't Need No Stinking Pings! for an example.)

If you're interested in trying out this kind of setup, there is one caveat: You must be disciplined. No network activity in the naked 'game' environments other than the game and game related functions. No installing or running anything not from trusted sources. Use the hardened environment, either natively or in a virtual machine for everything else. Otherwise, you're swimming in the septic tank. Surrounded by hepatitis infected needles. Naked. Do note, if you choose to run 'naked' like this, you'll still want some kind of isolation from the baddies on the WAN. If directly connected to the WAN (i.e., your PC IP is public), running the windows firewall should be part of the setup - even with hygienic use of the naked setup, this will minimize external attacks. Even better (since the windows firewall can be problematic with some games), keep it off, and use a proper router with NAT (and its own firewall enabled if you wish). NAT done correctly will keep the outside world at bay, and can be easily configured if needed (seldom) for specific games. Router firewalls can be more robust than the built-in windows system, and reduce load on the CPU for firewall tasks. The overhead of going through a router, firewall enabled or not, is negligible, and the protection provided warrants their use, in my opinion, even if your PC is the only device on your LAN.

The benefits of this kind of setup seem so overwhelming to me (absolute security combined with the leanest, meanest yet perfectly 'tuned for games' environment, with a significant reduction in the inevitable conflicts between different installed software that can be arduous to troubleshoot), I can't imagine why every serious gamer wouldn't want the same. No firewall, no A/V, no anything to get in the way of the game. It's better than running on a nude beach while sipping a Cialis spiked cocktail! Minimal encumbrance, maximum performance! Try it, you'll never look back.

I ♥ Windows 7 Event Logging!

I was recently debugging a couple of applications, and was trapping some events as part of the process. I forget how useful the Event Viewer is in general, and particularly with the greatly enhanced functionality in Windows 7/Vista.

Two of the really cool features are the ability to build sophisticated custom filters and views, allowing you to focus on exactly what you're looking for, and the ability to create events on events.

For example, the following XPath query for a filter/view allows me to trap a specific event for a specifc PID, excluding all other 'noise' in the event log:
  
<QueryList>
   <Query Id="0"
     Path="Microsoft-Windows-Winsock-AFD/Operational">
      <Select Path="Microsoft-Windows-Winsock-AFD/Operational">
         *[System[Execution[@ProcessID="3141"]]]
            and *[System[EventID="1000"]]
      </Select>
   </Query>
</QueryList>

Equally cool, I can assign tasks to any event/view/filtered view such that the system will notify me with a dialog, E-Mail me, or start any arbitrary program.

Hugely useful, allowing efficient, quick & dirty debugging without even needing to fire up a real debugger, and as an incredibly useful ancillary to formal debugging.