Saturday, August 29, 2015

PowerShell's Strict Mode (and a rant about implicit behaviors)

PowerShell's strict mode (enabled by running set-strictmode latest) is really nice.  So nice, in fact, that I'm wondering why it isn't the default.  In fact, why is there even the option to have a non-strict mode?

PowerShell's strict mode makes the interpreter throw terminating exceptions when it would otherwise silently fail, with respect to uninitialized variables in expressions.  This is megas useful nyoro~n for finding typo'd variable names and generally keeping you from being confused later on as to why an exception is getting thrown elsewhere, or why your script isn't outputting correctly.

I would argue that it should be taken a step further.  There should be a version of strict mode that prevents assignment to uninitialized variables as well, so that you have to use the new-variable cmdlet to explicitly create variables.  I already do this in all the scripts I write, because of a broader issue I have with PowerShell, namely, its never-ending set of implicit and sometimes unintuitive behaviors.

So that I can be 100% sure I know what's happening, I force PowerShell to bend to my will by explicitly defining every behavior that I want to happen, even when it would normally happen implicitly.  This has also led to my adoption of the mantra "If it doesn't work in PowerShell, throw more parentheses at it.", which you can often find in an all caps comment in my code near where I've added parentheses to make something work.

Because those of you who aren't familiar with PowerShell may be wondering what sorts of code wouldn't work as expected without parentheses, but works properly as soon as they are added, I will offer an example.  Let's use something for this example that looks innocent enough: declaring a new variable and initializing both its type and its value using a typecast.
> new-variable -name foo -value [decimal]0 > $foo [decimal]0 > $foo.gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True String System.Object
That's right, the way you'd immediately think of doing it results in $foo being the string '[decimal]0' instead of the value 0 as type System.Decimal.  Now, let's stick some unnecessary-looking parentheses in there and see what happens.
> new-variable -name bar -value ([decimal]0) > $bar 0 > $bar.gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Decimal System.ValueType
Now we get our expected behavior.  This only happens because PowerShell will implicitly interpret unquoted sequences of characters as strings.  This implicit behavior is the cause of a rather large class of annoying behaviors in PowerShell: the parser decides too quickly that something is a string instead of code to be executed, which can produce a variety of headache-inducing results.

Here's another one.  Again, we're making a new variable, however, we want to assign it an object that we're creating via the new-object cmdlet.  Once again, this looks innocent enough, but fails:
> new-variable -name baz -value new-object system.xml.xmldocument New-Variable : A positional parameter cannot be found that accepts argument 'system.xml.xmldocument'. At line:1 char:13 + new-variable <<<< -name baz -value new-object system.xml.xmldocument + CategoryInfo : InvalidArgument: (:) [New-Variable], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewVariableCommand
As you might expect by this point, merely putting parentheses around the call to new-object gives us our desired behavior.
> new-variable -name baz -value (new-object system.xml.xmldocument) > $baz NodeType : Document ParentNode : DocumentType : Implementation : System.Xml.XmlImplementation Name : #document LocalName : #document DocumentElement : OwnerDocument : Schemas : System.Xml.Schema.XmlSchemaSet XmlResolver : NameTable : System.Xml.NameTable PreserveWhitespace : False IsReadOnly : False InnerXml : SchemaInfo : System.Xml.Schema.XmlSchemaInfo BaseURI : Value : ChildNodes : {} PreviousSibling : NextSibling : Attributes : FirstChild : LastChild : HasChildNodes : False NamespaceURI : Prefix : InnerText : OuterXml : > $baz.gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False XmlDocument System.Xml.XmlNode
Now, let's try to initialize a new variable to the result of a static method call.  I'm sure you get the drill by now.
> new-variable -name qux -value [math]::floor(3.5) New-Variable : A positional parameter cannot be found that accepts argument '3.5'. At line:1 char:13 + new-variable <<<< -name qux -value [math]::floor(3.5) + CategoryInfo : InvalidArgument: (:) [New-Variable], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewVariableCommand > new-variable -name qux -value ([math]::floor(3.5)) > $qux 3 > $qux.gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Double System.ValueType
There's another one that's more difficult to demonstrate where the interpreter will implicitly flatten a single-element array to its sole value, which is annoying when the code around it is expecting an array.  I could go on and on listing implicit behaviors and how to explicitly define them to get your code to do what you want, but the lesson is already plainly obvious: Be very vigilant while writing and testing your code.  Always keep the interpreter nearby to test things and make sure that they work.

Also, if you point out the implicit behavior that all of my code examples are using without turning it into the equivalent explicit behavior, you get a cookie.

Tuesday, August 25, 2015

Video Game Piracy

Because of a post on the video gaming Shitty Gawker Network Blog™, I'm thinking about it.  While the accounts shown in the article certainly paint a picture of the variety of reasons why people pirate games, it's not nearly large enough of a picture to be an accurate representation.  Indeed, a lot of them cite monetary issues, and the article's author mentions this plenty of times, which I feel unfairly paints a picture of "can't afford it; just torrent it" entitlement fantasy as the major reason for piracy.  In fact, there is a diverse enough set of reasons to bring up some good points on things the industry is doing wrong or is just plain overlooking when they talk about how "piracy is the reason we only made 30 billion dollars last quarter" or whatever.

First, not every region of the world is so lucky as to have legal releases of games.  For people in these regions who want to play games, their only recourse is to pirate them, or pay an arm and a leg to import them.

Second, people often pirate games because of lackluster or nonexistent game demos.  If the demo doesn't have enough content to help the player make an informed decision, or if the demo doesn't exist at all, how does someone know if they want to purchase a game?  Everything you hear from the developer and publisher prior to the release is, of course, carefully crafted marketing information.  While it's still possible to pull objective information from that, it can be difficult since they have full freedom to pick and choose what aspects of the game they want to show to you.  The next logical step would be to turn to reviews, but most review sites can't be trusted to rate things objectively.  Also, when publishers know that the game is horrible, they embargo reviews until the game's release, or simply don't give out review copies until after then.  Video game publishers still rely too much on the blind buy.  I myself am interested in Fantasy Life and Rune Factory 4, both 3DS games, but have held off purchasing them because they don't have demos available.  Also, I recently purchased The Legend of Dark Witch, also on the 3DS, because of my gameplay experience in its demo.

Third would be tacked-on DRM clients such as uPlay from Ubisoft.  These are pretty much universally a headache to deal with and have a tendency to cause more problems than they solve.  The problem is also further compounded by the fact that you can often torrent the game and get a copy where the DRM has been removed.  In that case, pirating the game results in less of a headache than purchasing it legally, so the DRM really only exists to punish legitimate purchasers of games.  I will point to the release of Spore, which was so riddled with DRM issues that the only people who were actually able to play the game upon release were people with pirated copies.  Also, you often see games with these DRM clients on Steam, which is itself a DRM client.  Why the redundancy?

Fourth would be region controls.  I know for certain that a lot of piracy is due to the fact that some games just never see the light of day outside of the region the developer calls home.  While a fair number of people import games and consoles to get around this the "legit" way, doing so is rather expensive.  This is also one of the reasons why people such as myself modify their home consoles.  In my case, I modified my PS2 so I could play the copy of The Rumble Fish that I'd imported.  Region restrictions are an artificial measure put in place because publishers and console manufacturers desire more control than they're due.  It's clear that if the region controls are circumvented, the game will function perfectly, so it's definitely not a true restriction.  It's also clear that people are willing to deal with the language barrier, so that isn't really a valid reason.  Why prevent a person from playing a game that they've legitimately purchased on the requisite hardware that they've also legitimately purchased?

Fifth, and perhaps one of the bigger reasons, is that a lot of games are out of print.  In the interests of preserving gaming history, a lot of older games, including older console games, get pirated.  However, this raises a very important question.  Namely, if the developer and publisher can no longer make money off of the game, does it really hurt them to pirate it?  A lot of times, the legit copies show up on reselling sites like Amazon and eBay for ridiculous prices.  A clear example would be the GameBoy Color cartridge of Shantae, which commands over $300 on such sites, and can only otherwise be purchased for a much more reasonable price on the 3DS eShop.  But if you're sitting there with your old GameBoy Color and don't have a 3DS, then you'd have to buy one just to be able to pay that much more reasonable price, which would result in the game effectively costing almost as much.

Sixth, compatibility is an issue for computer games.  This relates back to the aforementioned problem of games lacking demos.  This also relates back to older games, where just getting a game running was sometimes an exercise in frustration.  I certainly remember the old days of games with DOS setup programs where you had to select your sound card from a limited list and provide details like IRQ, DMA, etc.  Sometimes just getting something working made you feel like a genius.  Computers have come a long way in terms of ease of configuration since those days, but newer computers often can't run games made for older computers because of how those games are programmed.  Often an emulator like DOSBox or a virtual machine of an older OS can solve the issue, but they're somewhat of a hassle to deal with and not every gamer is going to want to put in that much effort.

I guess the point I'm trying to make here is that video game piracy is definitely a multifaceted issue, and you can't simply look at it and chalk it up to one reason in particular.  Services like Steam and GOG definitely make legitimately purchasing games a lot easier, and have won over a lot of pirates on the convenience factor alone, but they're little more than a band-aid on the broken leg that is video game distribution.

Friday, August 21, 2015

Auto Racing Bucket List

I know, if you read this blog, it's inevitable you'll run across one of my posts about it, most likely The Day of Racing, as I've termed it.  However, I have actually spectated races from the venue in person, as opposed to just watching on TV, and I do have a list of races I'd like to watch in person sometime.  I even looked all of them up on Google to be sure I had the right names and locations.  So if there's any inaccuracies, blame Google.

But first, places I've been to watch races in the past:
  • Richmond International Raceway, Richmond, VA - I forget if it was an IndyCar race or a NASCAR race, to be honest.  At oval courses, you always prefer to get seats higher up in the grandstands, so you can see the entire oval from one spot.  The only thing that sucks about having seats that high up?  The longer walk to concessions/the bathroom.
  • Indianapolis Motor Speedway, Indianapolis, IN - I've been to a few of the Formula 1 races they held there.  This is where I got my Ferrari hat from.  Our seats were in Indy turn 4, which was the perfect place to sit because you could see the entire front straight and first several corners leading onto the back straight.  Thankfully, I was at home watching on TV during the six-car farce thanks to Michelin not bringing durable enough tires that year.
Now, places I'd like to go to see a race at some point:
  • Bristol Motor Speedway, Bristol, VA - The shortest track on the NASCAR calendar, and always a great source of entertainment.
  • Circuit de Spa-Francorchamps, Stavelot, Belgium - One of the best tracks on the F1 calendar.  I'd love to have a seat at the first hairpin where I can see all the way down the hill to Eau Rouge.  This track is where this legendary pass for the lead happened.  In fact, here, have the onboard from Hakkinen.  Listen closely as he lifts the first time through Eau Rouge, but then not the second time.  Balls of fuckin' steel, man.  Fun fact: Hakkinen was the only person who was ever able to defeat Schumacher in his prime.
  • Circuit Gilles Villeneuve, Montreal, Quebec, Canada - Another great F1 track.  I'd either want to sit at the hairpin just before the final straight, on the outside of the corner; or along the front straight, closer to the first and second turns, but where I can still easily see the cars coming through the final chicane.
  • Indianapolis Motor Speedway, Indianapolis, IN - I still feel incomplete as an auto racing fan, having been to multiple races at Indianapolis Motor Speedway, none of them having been the Indianapolis 500.  So hopefully I can see an Indy 500 live and in person sometime.
  • Mid-Ohio Sports Car Course, Lexington, OH - All jokes about being stuck in Ohio aside, this is one of the many great road courses in the US, and I'd love to see a race there.
  • Road America, Elkhart Lake, WI - Yet another great road course in the US.  Dat elevation change on the front straight.
  • Sears Point Raceway, Sonoma, CA - Because screw calling it "Infineon Raceway" or "Sonoma Raceway".  Another of the great road courses in the US, which gets used for a variety of forms of racing, including NHRA drag racing.  I'll take either IndyCar or NASCAR, though.
  • Mazda Raceway Laguna Seca, Salinas, CA - While we're in California, how about yet another amazing US road course?  This course is where "the pass" happened, which of course was Alex Zanardi passing Bryan Herta in the corkscrew and going off the track in the process, which apparently wasn't against the rules at the time.
  • Watkins Glen International, Watkins Glen, NY - The other NASCAR road course, but I'll throw a curve ball here and say I'd rather see a series that races the full International circuit, such as the IMSA Tudor United Sports Car Championship or the Rolex Sports Car Championship, or the Continental Tire Sports Car Championship, or whatever the name of that series is.  It's the Le Mans-style one.  It has about 50 different names.  Pick one.  Even if they're actually different series, they're all pretty much the same: endurance racing with driver changes.
As you can see, there's kind of a long and eternally incomplete laundry list of US road courses (there's New Jersey Motorsports Park (what exit?), and Circuit of the Americas, for sure), and then a few from other countries.

Friday, August 14, 2015

XT's Typical Day

☑ Rant about computer software not working the way I want it to
☑ Notice something weird and talk about it for a while
☑ Pet the dog
☑ Rant about computer programming
☑ Discover and/or cause computer problem, find solution, post solution
☑ Say bad things about something that I don't fully understand
☑ Wish I could get someone to hire me
☑ Stay inside all day
☑ Eat too much
☑ Drink a lot of soda
☑ Watch YouTube and/or play games
☐ fap
☐ Go to sleep

Tuesday, August 11, 2015

The Legend of Dark Witch

I just covered the demo, but as I stated in that post, I was going to buy the full game, and I did.  This post will restate some stuff from that post, just so it's a complete review.  So, with that out of the way, here we go!


The Legend of Dark Witch is a Mega Man-style action platformer.  If you've played a Mega Man game before, you know the drill.  You choose the boss you want to fight, work your way through their stage, and eventually confront and defeat the boss.  Upon defeat, you get their weapon, and another boss is weak to that weapon.  Once all the main bosses have been defeated, special boss stages become available, and getting through all of them gets you the game's ending.  One of the stages is typically a series of re-fights of the main bosses, and that's certainly no exception here.


To set it apart from your average Mega Man-style action platformer, though, the game provides a Gradius-style upgrade system.  Drops from enemies, called Tres in this game, fill up a gauge at the bottom of the screen.  When the upgrade you want is highlighted, you press a button and get the upgrade.  These upgrades will generally help you get through each stage, and certain parts may require you to have upgraded Speed.  If you get hit, you lose progress on this gauge, which can make another upgrade get selected instead of the one you had selected.  So basically, as soon as you can grab the one you want, do it.



The Tres you pick up during a stage are also added to a count shown on the lower screen.  Between stages, you can access a menu and use your saved up Tres to buy permanent upgrades.  One of the permanent upgrades increases the amount of Tres you get from enemies, which I highly recommend getting first.  Each permanent upgrade has three levels that increase in cost, so you'll really want that income multiplier maxed out before buying much of anything else.  The income multiplier also affects how long it takes to get upgrades within each stage, so it's megas useful nyoro.  Combined with one of the other upgrades maxed out, and you start a stage with enough Tres to grab a Speed upgrade right away.

Hidden throughout the six normal stages are crystals you can find.  These crystals increase your maximum upgrade levels.  Each stage has two of them, and once you've gotten all twelve, a secret one appears in the first extra stage, that adds a new upgrade.  For a first playthrough, I fully recommend getting all of them.  They're kind of tricky to find, as they're not visible, but you can shoot them.  So if you fire at a random spot and hear a weird noise, it's a crystal.  You can either shoot it several times to make it appear, or jump at the spot.

The graphics are sort of a halfway-point between NES-style graphics where the pixels are large and in charge, and the high-resolution graphics that we're more familiar with these days.  I guess a good term would be "high resolution pixel graphics", even though "pixel graphics" is a bit redundant because all graphics are composed of pixels.  Anyway.  The stages all have their own look and feel, and anything that needs to stick out sticks out so you'll notice it.  Heck, the game even displays a blinking red "DANGER!!" text on the top or bottom of the screen when there's an enemy just offscreen.

As one of the extras points out, the music sounds like it's a bunch of PCM modules, straight out of the 90s.  That's the style they went for, and I think it turned out well.



The controls are spot-on.  Control isn't slippery like in Mario where you constantly have to adjust with left and right to land your jumps.  You stop pressing the button, your character stops moving.  Period.  Also, the controls on the A, B, X, and Y buttons can be rebound to be more to your liking, which is nice, and unexpected in a handheld game.  There's also an option for how you want your jumps to work.  The default is that your jump height is the same regardless of how long you hold the button for, but you can change it so that pressing the button for less time results in a shorter jump.

As far as the other options go, volume levels of various categories of sounds can be adjusted, the camera distance and speed can be adjusted.  Then, there's the "install mode" setting.  This affects how the Gradius-style upgrade system works.  It defaults to Auto, and there's also Semi-Auto and Manual settings.  I haven't tried Auto or Semi-Auto, because from the start I wanted to be in control of which upgrades I got when.  Besides, if you're used to Gradius, you're going to want to set it to Manual anyway.

When you start the game, you can choose Easy, Normal, or Lunatic difficulty.  Lunatic is only unlocked once you beat the game once.  I hopped straight in on Normal.  Easy has health pickups, Normal and Lunatic don't.


Once you beat the game once, the main menu gains some extra options.  One is a hidden shop with extra upgrades and some unlocks and things, that uses Syega as its currency instead of Tres.  Various things throughout the game, including beating the game, give Syega rewards, to be used here.  Also available is a poker (5-card draw, not that hold'em cancer) minigame where you can bet your Syega and win more.

I originally had a list of frustrations here, but they can be summed up as "I blindly jumped in on Normal difficulty and things got challenging and I had to repeat stages a bunch to learn them".

Overall, it's a great game.  It's $4 on the eShop, and it's well worth the price.  I know for sure that I've gotten more than four dollars' worth of entertainment out of it.

Friday, August 7, 2015

Trying Some 3DS Demos

Some titles on the eShop have demos, so I've tried a couple that looked interesting.  Of course, the existence of this post means I'm about to tell you what I tried, what the games are like, and my opinions of them.  If your opinion is different, then... good for you!  If you read this post and decide you want to purchase either of the games, do note that they will both transfer save data from the demo to the full game.

Witch and Hero

I downloaded this demo because the game looked similar to Protect Me Knight on the Xbox 360.  It's got the same retro graphics style and the same occasionally broken English.  The graphics and music are quite good.

However, it's a defense game.  Typically, I don't like those.  Yet, here I am giving one a try anyway.  Unfortunately, I still don't like it.

The difficulty seems to follow an exponential curve, wherein it gradually goes up for a while, and you'll occasionally have to repeat a stage due to some stupid error or whatever, and then suddenly on stage 8 it becomes a brick wall.  You know what doesn't help?  If you fail a stage, your rewards get cut in half.  At first, it seems like it's there to provide a penalty for losing, which is fair.  However, when you lose, it's because you need better stats, and the loss of half of your reward means it takes you twice as long to get better stats.  I must have played stage 8 for about 15 minutes, upgrading whenever I could, and I still couldn't beat it.  Because I couldn't beat that stage, I don't know how far through the game the demo will take you.

Also, the game has no sense of accomplishment.  As you power up, so too do your enemies.  You'll never reach a point where you feel powerful because you're always struggling to complete a stage.  The game's battle system compounds this issue by having you run into enemies in order to attack, despite the mass of unused buttons on the system.  As you run around the screen nudging everything to death, you gradually take damage from some indeterminate source.  Once you die, you stay down until your health bar refills, which takes an annoyingly long amount of time.  Occasionally an enemy will leave a chest behind, but they're annoying to open.  This is because every time you nudge something, you get knocked back, seemingly a random distance.  Usually it's pretty small, but sometimes it's upwards of half of the screen.  The chests seem to always knock you back a long distance, making getting their contents difficult at best.

The witch stays at the center of the stage and can't move because she's been turned to stone.  If she dies, you fail the stage.  However, past a certain point, you can power her up with enemy drops, and when powered up all the way, she'll momentarily revive and perform one of two attacks, either an area-of-effect storm, or a fireball that you have to aim using the L and R buttons.  Powering her up so you can have these attacks going constantly seems to be key to victory.

However, I just didn't find it fun repeating the same stage over and over again, only getting half of the reward, and trying to upgrade myself to the point where I could beat the stage.  The shop where you buy upgrades also charges you more and more for each level of each upgrade, so it takes longer and longer to upgrade each time.  Now do you see why I disagree with the whole "half rewards on failure" thing?  It really only serves to add tedium.  It's just not fun.

The Legend of Dark Witch

This is an action platformer in the style of Mega Man, where each stage ends with a boss fight and you get the boss' weapon when you beat them, and each boss is weak to a specific weapon.  However, it also has a powerup mechanic in the style of Gradius, where drops from enemies fill a gauge and you press a button when the upgrade you want to get is selected.  There are also permanent upgrades that can be purchased between stages.  One of them basically acts as an income multiplier, which I highly recommend grabbing (and maxing out) first.

The graphics are great, the music fits, and the controls are perfect (and re-bindable!).  The character designs are anime-style, which may turn off some of you out there.  For the open-minded, though, it's an excellent blend of two classic games.  The demo has one stage available.  I jumped straight in on Normal difficulty (the highest, Lunatic, isn't accessible in the demo) and had a good experience.

The game has a number of extras that are unlocked by doing various things in-game.  Only a select few (I believe only two) are obtainable in the demo, and I've gotten one of them, for defeating the one boss available in the demo without taking damage.  The way the unlock methods are chosen seems to encourage replaying the game with different strategies, to make it different or more challenging.  For instance, one of them is obtained by completing the game getting no upgrades other than speed upgrades.

Overall

I think I'm gonna buy The Legend of Dark Witch, and delete the Witch and Hero demo.