Natalie Martinez, once more

The 20 hottest photos of Natalie Martinez courtesy of heavy.com

 

Handy Tip for Virtual Machines

When I’m booting up a virtual machine on my PC I always have to dig into the network details or run ipconfig in  order to determine the IP Address before I can use remote desktop. To save one of those steps you can run bginfo from the startup folder to get it to automatically write the IP Address and other details to the desktop background:

http://technet.microsoft.com/en-us/sysinternals/bb897557.aspx

and

http://windows.microsoft.com/en-us/windows/run-program-automatically-windows-starts

Eldritch Coding Horrors, Part 1

I found this terror today in a legacy application.

Program A uses SetWindowLong to hook the message loop for a Windows Form:

[sourcecode language="VB"]

Friend Function StartListening() As Boolean
SetWindowLong(m_MappedWndHandle, GWL_WNDPROC, AddressOf WindowProcedure)
End Function

[/sourcecode]

Program A then shells program B. Program B sends a WM_COPYDATA message to program A. Program A intercept the message, reads the data, and then passes the message to the form:

[sourcecode language="VB"]

Public Function WindowProcedure(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If msg = WM_COPYDATA Then
objMapMemoryData.ReadMessage lParam
End If
WindowProcedure = CallWindowProc(objMapMemoryData.GetWindowProcedureAddress, hwnd, msg, wParam, lParam)
End Function

[/sourcecode]

objMapMemoryData.ReadMessage raises an event that is handled by the Form:

[sourcecode language="VB"]

Friend Function ReadMessage(ByVal lParam As Long) As Boolean
‘SNIP: Copy memory around
RaiseEvent MapMemoryDataEvent
End Function

Private Sub objMapMemoryData_MapMemoryDataEvent()
‘SNIP: Process event here
End Sub

[/sourcecode]

To Bind or Not To Bind That is the Question

One of the things that VB6 is very good at is late binding. Back in the days before .NET late binding or OLE Automation as it was also known was one of the only ways to do certain tasks such as create reports in Excel, run Word mail merges from databases, or print nicely formatted documents. However there were downsides too. Applications that late bound to DLLs and EXEs had no means to ensure that the target supported the call being made or even that the target was installed on the PC. This allowed difficult to debug problems to creep into your program.

 So the best solution to late binding problems was to early bind to any DLLs that you wanted to use. This way you could ensure that the interface was correct and that the DLL was installed on the system. However this led to another problem: DLL Hell. When an updated DLL was installed your system had to keep track of each version of the DLL and make sure that the right program called the right version. If a DLL was relied upon by a lot of programs and was regularly updated then a new installation could mess up an old program.

 So .NET included ‘xcopy’ installation – simply include the right version of each referenced DLL in the same directory as the application and late binding became something that only ‘bad’ programmers did. Early bound DLLs also need to be loaded by the system when your program initiates.

 The thing is that late binding solves a certain class of problem, one that often occurs in legacy applications. When adding new features supported by a DLL or refactoring old features to use new DLLs early binding to the DLL can cause problems with your installation program/routine, especially where DLL Hell issues have been previously overcome or there are a large number of support DLLs required for the application.

 So a simple approach to enhancing or refactoring an old application is to develop with the references early bound and then switch to late binding and copy the required DLLs into either the application directory or another suitable location.

Why I’ve Quit World of Tanks

I realised something today: World of Tanks is a casino with nothing to win except a momentary sense of accomplishment.

I’ve loved tanks since I was a little boy making plastic models of WWII tanks. As I grew up that turned into a love of wargaming and all its associated modelling requirements. I would lovingly select, purchase, assemble, and paint all the tanks, soldiers, terrain, and other items required to field my own little army against fellow enthusiasts. If I’d never moved house there would still be a desk piled high with paints, brushes, glues, and tools but I did and so all those things had to be tidied away. A couple of moves later and with a pressing need for money it was time to sell all my wargaming collection on eBay. I thought I was done with it.

Years later my wargaming passion has turned into an online gaming passion. I’ve played World of Warcraft of course, who hasn’t, but I’ve also played sundry other games but never found something that drew me like my teenage obsession with tanks until I chanced upon World of Tanks. World of Tanks (WoT for short) is purportedly an MMO focused around WWII tank battles and so it is at first appearance.

You play the game by entering short PVP team battles, fifteen tanks to each side on a small thousand meter square map. Now that’s quite odd for tank warfare which is mostly conducted over significantly larger ranges and areas. This is explained by the designers as the game being focused on arcade action and fun. Sounds like a great idea.

However it’s not quite that simple. Each shot has a very large random outcome as the designers have applied a strong random factor to every aspect. Assuming you have aimed correctly when you press the fire button your shell will disperse randomly within the aiming circle. It’s meant to be on a bell curve but from personal observation it’s just wild, you cannot aim and expect the same result from the same gun consistently. Assuming you actually hit the enemy tank there’s then a random penetration roll that increases or decreases your shell’s penetration by twenty five percent. After that the game works out what damage you do to the enemy tank again with a twenty five percent randomisation of your standard damage. Add this all up and each shot you fire has a wildly different outcome. Multiply that out by your fifteen team members versus the fifteen members of the enemy team and the outcome is entirely unpredictable. Except that it isn’t. Somehow the random factor seems to favour you on some days and be against you on others. Almost is if the dice were loaded.

Now it’s certainly possible to overcome all this randomness, the designers of the game have given you plenty of opportunity to spend buckets of money on microtransactions to enhance your game. Premium subscriptions to let you progress faster, premium tanks to let you grind out experience and cash for new tanks, premium ammo to let you penetrate better, premium crews to utilise your tank at one hundred percent of its ability instead of the standard fifty percent. The list goes on and on. By the time you’ve got into the game and run into the point where you have to start grinding the game to progress you’ll either have given up in frustration or be very ready to start buying your way forward.

Once you’re established in WoT you’ll begin to perceive the underlying problem and eventually realise why it’s bad for you. Other players have taken the readily available statistics from the game and done some simple analysis. The average player has a win rate (games won as compared to games lost) of forty eight percent. The worst players lie around thirty percent and the best no better than seventy percent. The shape of the bell curve for this distribution of win rates has very steep sides meaning that it is very difficult to change your win rate once you have a lot of games under your belt. What this means is that each game you play has roughly a one in three chance of being lost no matter what you do, conversely another one in three will be won without you lifting a finger. It’s only the remaining one in three games where you will stand a chance of influencing the game. Provided that you are in a tank that can sufficiently influence the outcome and that the random rolls come your way. For the average player this is maybe one game in ten where they can have an effect on the outcome. What’s worse is that thanks to the pretty much guaranteed one win in three even the most useless players, AFKers, and bots will always succeed in the long run, simply by virtue of playing a large enough number of games which means that there are always thoroughly useless players on each team and it only takes having one more useless player on your side to lose the game.

So the game is pretty much a gamble, you take your tank, place your bet (in the form of the ammo and repair costs you will spend), and spin the wheel. On a good day you guess the outcome, otherwise it’s all down to the randomness in the system. But you never know which one it is. If you do well you’ll feel god about your accomplishments, do badly, or get on a losing streak and you will be upset, blaming every other player under the sun, and having a thoroughly bad day.

This is where it gets nasty. Unless you pay money to overcome the randomness in the system you will have more bad days than good days and even the good days will have plenty of bad spots in them. Unlike most quest based MMOs where you can feel as if you’ve accomplished something each time you hand in a quest, WoT is only rewarding for the one game in ten where you actually personally accomplished something.

So now it’s possible to see why quitting World of Tanks is the only sensible course. It may not cost much to play a little, a few quid here and there, but paying for World of Tanks is like pissing into the wind – you have no chance of success. Unlike a casino where the odds are regulated World of Tanks has no odds you always lose all your money and you only stand a tiny chance of gaining a small sense of accomplishment. I’ve always been against gambling, which may be a surprising attitude for a game player, but to me gambling is just handing your money over to a bunch of criminals whereas playing a game is pitting your skills against your fellow enthusiasts. World of Tanks flatlines any skill by replacing it with loaded dice and then screws you over for a shot at the little prize.

So if you see me installing the game or talking about it again just remind me gently of why World of Tanks is an unlicensed casino with loaded dice.