I’m very proud to bring you what I’m calling the internet’s first “computer rendered Mandelbrot set-based image thing”

by acha11 13. November 2009 04:11

I guess this is the nerd equivalent to carrying baby photos around and producing them without any provocation, but…

Awwwww, look at the Mandelbrot set my program rendered! Look at its little chubby cheeks and pointy seahorse valleys!

 2

Look, I know that some modern techno-hippie dance-types do take their love of fractals to unnerving extremes, but in their defence: the Mandelbrot set is some seriously profound shit. Up on the screen, it stills even the roaring, gibbering horror and stinging shame of my kludgy implementation. It transcends the hack. My implementation’s glacially slow, but that just serves to build anticipation.

My dad coded a Mandelbrot set renderer some time in the early 90’s with Turbo C on our Amstrad PC1512. The thing had CGA graphics, according to the letter of the standard, but it did have a titillatingly taboo 16 color, high-res mode that was an extension to the standard.

I say “high-res”, but I’m somewhat deflated to report that it was actually 640 x 200 (wikipedia).

The point I’m making is this: the Mandelbrot set was still an amazing thing to see back then, in 16-color 640 x 200, after running overnight.

For a while, in fact, there was talk of getting an 8087 floating point co-processor unit, to speed up those overnight runs.

Here are some things I’d like to see:

  • A generalisation of the Mandelbrot set to higher dimensions. Maybe there’s one already?
    • To be honest, I knew about this in advance; it inspired me to do my own 2d renderer.
  • A GPU-based Mandelbrot zoomer/explorer. Maybe there’s one already?
    • This one I didn’t know about, and I’m a little disappointed; I thought for a moment I’d come up with a great idea.
  • A retro fractal rendering movement, targeting only antique hardware, but generating images of the highest possible precision. Maybe there’s one already? Google hasn’t found me anything yet.
    • Yeah! Niche of one!

Oh, and if you enjoy fractals and procedural generation in general, you might enjoy dmytry’s blog Mostly Polynomial.

Tags:

iStatistician 3.0 is out!

by acha11 10. November 2009 16:56

This release updates iStatistician again to handle iRacing’s November release website changes.

Go get the new version here!

Tags:

Bing cashback - Microsoft falls back on security through obscurity, breaks chair, keeps falling

by acha11 7. November 2009 17:01

Background

Bountii.com wrote a blog post which described (and demonstrated) some fairly half-assed security design in Microsoft’s Bing cashback system. I’d link you to it, but it’s now been taken down by the author at the request of Microsoft’s lawyers.

The class of problem we’re talking about

At its core, this is a case of what I’d call trusted-client syndrome.

As an example, imagine company A, company B, and a customer are involved in a transaction. Company A and company B need to exchange some info as part of the transaction, but it’s a real hassle (in 2009!) to integrate their systems directly. I mean, jeez, we’ve already built a customer-facing website, now we gotta build some B2B web services too?

So, to avoid the technical challenge of directly integrating company A and company B’s systems, company A passes transaction info indirectly to company B, via the customer’s browser.

Here’s the problem: as the info passes through the customer’s machine, it can be modified by the customer or by trojan software running on the client machine, allowing a range of attacks to be launched.

Why Microsoft’s position is inconsistent

The problem is this: MS implemented a dodgy design when MS itself believes it’s dodgy.

Over time, I’ve become a little (a little) more open to the school of thought that says “an occasional security hole is okay if the risk of exposure is low; after all, with usual reconciliation business processes, we’ll detect attackers down the track”.

  1. Let’s just ignore the implicit assumption that our knowledge of the system is perfect, and that there are no secondary vulnerabilities which would allow an attacker to cover tracks to work around the reconciliation processes.
  2. Also, assume that the people doing the reconciliation processes will keep running them :-)  (“hey, why bother recalculating all these per-vendor totals and matching them against our records? The computer already did that for us!” “Awesome. Let’s go to lunch.” “I was just thinking that.” “Me too.” “Hold me.”)

The crux of my argument is this: MS can’t justify this design on “low exposure, high chance of detection” grounds on the one hand, and then also believe it’s worth expunging any mention of the flaw from the internet. Which is it? Acceptable risk or dangerous security flaw? Do you have processes in place to catch discrepancies caused by this vulnerability or not? (Hint: the original bountii post seemed to indicate that the answer is “no”).

The whole thing’s demoralising because it all feels so 2001-ish; I was beginning to hope we were past this kind of crap as a profession. At least the billion-dollar corporate parts of the profession, anyway.

Here’s hoping that this is just a Bing-specific attitude of “time-to-market is more important than that over-engineering approach the Windows and Office nerds take. We’ve got a google to compete with.”

Tags:

iRacing disables 3rd-party extensions

by acha11 28. October 2009 03:30

iRacing released a quarterly update today. Aside from the release of Mosport, one of my favourite tracks from the Grand Prix Legends days, there’s a bunch of stuff to do with hosted racing, and a quick note as follows:

Security
Unverifiable third party replacements of system DLLs (including D3D9.DLL and DINPUT8.DLL) utilized by the simulator will now result in loading errors. If you encounter a Loading Error #66, please remove any third party replacements of D3D9.DLL, DINPUT8.DLL or other imposter system DLLs from your iRacing installation. SoftTH is an allowed dll.

By the sounds of it, this’ll break the Telemetry HUD Plugin I blogged about previously. I think the Telemetry HUD always pushed the boundaries of what’s “fair”, but hey, that whole dynamic’s just part of motorsport.

From my old post:

I’m really surprised that iRacing, an online multiplayer game (where you’d expect some cheat/hack countermeasures on the part of the developers), doesn’t have parasite detection code that picks up either unrecognised or suspicious-looking DLLs, or at least funky stuff like “hey, wait a sec, I have TWO d3d9.dlls loaded in my process space! uncool!”.

Well, I guess I’m happy to no longer be surprised.

I’m interested to see what happens next.  Security arms race ? (warning! hot duck oviduct & phallus-related blog post on the other side of that link). Plugin user revolt? (There’ve already been a few tantrums) Crickets chirping?

Tags:

Apollo 11 source code

by acha11 2. September 2009 01:06

Cool code snippet of the week: We flew to the moon. Computers did a lot of the heavy lifting. Source code for the Command and Lunar modules, as part of an effort to emulate the machines, is up on Google Code. Here's the project home page.

Tags:

Unicode table reveals timeless majesty of squiggly things

by acha11 25. August 2009 18:11

I know that you know that human language is really diverse. But, allow me to make this illuminating and subtly different point: human language is really really diverse.

http://www.ftrain.com/unicode/ is a pretty nice in-browser Unicode table that lets you wander around the wonderful world o’ glyphs. Imagine a secret version of the The Lettering Book, issued to all CIA operatives for use when hand-illuminating their post-mission reports from some far-from-home fox-hole by the light of a chemical flare.

image

Unicode defines alphabetic glyphs and also non-language glyphs. I like the run of symbols beginning at ⚬ (starting at the top-left of the screenshot above). 9000 is an unassuming MEDIUM WHITE SMALL CIRCLE. Fine. Not sure why you need another circle; plenty of circles defined elsewhere in Unicode, but whatever, there’s a lot of headroom in the Unicode spec. Then you’ve got symbol 9001 - two interlinked circles, named MARRIAGE SYMBOL. This changes everything: MEDIUM WHITE SMALL CIRCLE is no longer just a circle to me, it’s cooking for one and then hitting the late night singles bar scene. 9002 is two disjoint circles separated by a vertical line – DIVORCE SYMBOL. 9003 (pictured above) is UNMARRIED PARTNERSHIP SYMBOL (which would make a lovely tattoo for a couple). Then, the next three (which aren’t renderable in MS Arial Unicode) are COFFIN, FUNERAL URN, and NEUTER. It seems likely that someone, somewhere, made a conscious decision not to invest in typography for those particular glyphs in this particular font. Somebody has that job. What an age we live in.

Other favourites include:



TAMIL AS ABOVE. Seems like a long-ish shortcut to me.




TIBETAN MARK CARET YIG MGO PHUR SHAD MA.


TRIPLE NESTED GREATER THAN – useful for expressing the precise mathematical concept “much much greater than”


ATOM SYMBOL


HAMMER AND SICKLE

Tags:

Multi-value dictionary

by acha11 19. August 2009 21:45

This post’s about a simple extension to the Dictionary<TKey, TValue> type in .NET. It won’t change the world, but it’s a nice tool to have in the shed. I’ve quite possibly reinvented the wheel, here, too – if there’s something already floating around in the BCL that I’ve missed, please let me know :-).

What does it do?

The extension simplifies working with Dictionaries that contain zero, one or many Values corresponding to each potential TKey.

How does it do it?

The naive (and simplest!) approach is to declare a Dictionary<TKey, List<TValue>>, and do the plumbing manually when adding a new value for a key. That is, when you’re adding a new value V for a key K, you need to detect the case where there is no List<TValue> for that K, and construct a List<TValue> and add it to the Dictionary so you can then add the V to the end of your List<TValue>.

Well, I’ve written that code three times over the last six months, so I’ve made a generic extension to Dictionary<TKey, TValue> which does the above.

[code:c#] 

    public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>>
    {
        public MultiValueDictionary()
        {
        }

        public void Add(TKey key, TValue value)
        {
            List<TValue> valueList;

            if (base.TryGetValue(key, out valueList))
            {
                valueList.Add(value);
            }
            else
            {
                base.Add(key, new List<TValue>() { value });
            }
        }

 

Why bother?

For a recent project, I had a whole buncha legacy code parsed into a Abstract Syntax Trees. I wanted to traverse the trees just once each (to improve locality of reference), applying transformations from a large-ish library based on the type of the current node. So a Dictionary<NodeType, ITransformer> gives me some of what I need, but falls down when I want to have multiple ITransformers for a single NodeType.

So, instead of using a Dictionary<NodeType, ITransformer>, I use a MultValueDictionary<NodeType, ITransformer>, which provides all the functionality of Dictionary<NodeType, List<ITransformer>> as well as a convenient Add() overload which takes care of constructing a new List in the (most common) case where there’s no existing List for that value of NodeType.

 

Tags: ,

Version 2.9 of iStatistician is out

by acha11 15. August 2009 18:41

This release updates iStatistician to handle some recent changes on the iRacing member website.

Go get the new version here!

Technically, this release should never have been necessary. iRacing added two additional fields to a JSON data structure they return over HTTP. They’re fields that iStatistician could safely ignore. Unfortunately, the third-party JSON adapter I’m using to deserialize JSON from a string into a POCO chokes if a field present in the JSON has no corresponding target field/property on the target POCO type. More than that, there seems to be no option to tolerate such missing target fields. You might be wondering, since I’m in .NET-land anyway, why I’m not using MS’s own JSON parser (part of WCF). Unfortunately, I found that the MS JSON serializer is a long way from being able to handle the peculiarities of the dialect of JSON that iRacing returns. Actually, that’s probably unfair. More likely, the problem is that MS’ JSON parser expects peculiarities which JSON doesn’t actually prescribe. More later, probably, because…

The long and the short of it is that I’ve recently been working with the ANTLR parser and lexer generator, and it might be fun to roll my own JSON parser (nothing like re-reinventing the wheel again again) which handles both MS- and iRacing-dialect JSON, as well as giving the tolerant behaviour I really want.

Tags:

NHibernate on SQLite 3.0 – a workaround for “Could not find any resources appropriate for the specified culture or the neutral culture”

by acha11 29. June 2009 17:08

My iRacing stats tool, iStatistician, keeps its data store in a SQL Server Compact Edition database. I’m experimenting with SQLite using the SQLite ADO.NET 2.0 Provider as an alternative for use in a few small projects at work – it has a lighter deployment (one dll versus several), better performance, and (as far as I can tell; this is part of the test) presents no additional compatibility issues over SQL Server CE when used through an ORM.

I ran into a problem yesterday setting up NHibernate over SQLite 3.0:

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "System.Data.SQLite.SR.resources" was correctly embedded or linked into assembly "System.Data.SQLite" at compile time, or that all the satellite assemblies required are loadable and fully signed.
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at System.Data.SQLite.SR.get_Keywords()
   at System.Data.SQLite.SQLiteConnection.Schema_ReservedWords()
   at System.Data.SQLite.SQLiteConnection.GetSchema(String collectionName, String[] restrictionValues)
   at System.Data.SQLite.SQLiteConnection.GetSchema(String collectionName)
   at NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords() in c:\CSharp\NH\nhibernate\src\NHibernate\Dialect\Schema\AbstractDataBaseSchema.cs:lin
e 97
   at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) in c:\CSharp\NH\nhibernate\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:line 47
   at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) in c:\CSharp\NH\nhibernate\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:line 17
   at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) in c:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:line 169
   at NHibernate.Cfg.Configuration.BuildSessionFactory() in c:\CSharp\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1117

Reading the stack trace, it looks as though NHibernate is asking SQLite for a list of reserved words (by calling GetSchema(string)), and SQLite is trying to retrieve that list from the available embedded resource files/satellite assemblies and failing for some reason. SQLite certainly looks like it’s meant to support this kind of querying – its GetSchema() is calling into Schema_ReservedWords() and from there into its resource wrapper’s get_Keywords(), which is triggering the throw.

I haven’t solved the underlying problem, and googling hasn’t turned up anybody else with the same issue. This post is just to record the workaround i’m using in the very short term, which is to apply the NHibernate configuration setting “hbm2ddl.keywords” = “none”, which is telling NHibernate not to worry about retrieving the list of reserved words from the provider. I guess the impact of this setting is that NHibernate will not proactively escape column or table names that it knows will collide with SQLite’s reserved words, possibly leading to errors. This can be worked around – it’s possible to instruct NHibernate to escape a particular identifier in the mapping file on a column-by-column basis. So I’m going to plough ahead with the experiment and see what other issues I run into.

Tags:

Simulating a transport network part #4 – multi-lane highways

by acha11 15. June 2009 03:39

Last time, I outlined two different approaches to modelling multi-lane highways. To recap, option one was to handle every lane as its own special bit of geometry, with manually-defined start & end points and beginning & ending tangents. Option two, on the other hand, economised on the geometry a bit – only the “spine” of a multi-lane road would have a start and end point and tangent, and lanes would just be offset to one side or the other of that spine. This is an earth-shattering decision. Ramifications will be far-reaching. Nations will rise and fall, etc.

I chose the second approach; I thought that the extra up-front work would pay off in the long run because it’d be easier to make the spine-based approach editable. Plus, “spine” and “spline” are dangerously (although not actually hilariously) similar sounding, and I’m a sucker for a pun. Maybe I can drop in a SimCity reference by using the phrase “reticulating spines” on a loading screen.

I’m skipping over the maths for now, unless one of you comes back interested; I took an embarrassingly fudge-y approach rather than coming up with a nice way of deriving a “parallel” hermite based on a spine and an offset – I’m not even sure that concept’s coherent. I am sure that I wouldn’t know how to even approach the problem without spending a few nights reading.

So instead, here’s a pretty video that looks a bit like a blue velcro rainbow in space with smurfs running across it:

Features added since last time

  • Multi-lane highways

What’s working well

  • I’m very happy with the way the offset curves turned out. It’s nice that a beautiful abstraction (hermites) could give beautiful results even after I’ve tried to hide its light under a bushel of ugly hack-maths.

What’s not working well

I’m not actually unhappy about this point; it’s just somewhere I’m saying “that’s good enough for now” and moving on:

My approach treats all lanes on the same “spine” as having the same length. The main consequence is that a car in lane 0 in the video above travelling at the same speed as a car in lane 9 would take exactly the same amount of time to cross the road, which to me is clearly (a) bollocks and (b) just fine, thanks. This leads to some subtle weirdness (like, cars in the outside lane become more widely spaced while they’re on the curve, and cars in the innermost lane become more tightly packed) as a side-effect of the way I subdivide the spine into sections based on length, and then assign that length (which is a poor approximation, it turns out) to the corresponding length of each lane that is marked off by the same beginning and ending radial.

Upcoming decisions

  • Nothing on my radar that’s earth-shattering right now.

To do (short term)

  • Still to do to achieve multi-lanedness:
    • Demonstrate connected-ness for lanes that are defined relative to a spine.
    • Support “reverse” lanes, along which traffic flows in the opposite direction to the spine. Nothing rocket science-y here, just a lot of subtracting other numbers from 1.
  • Cars look “sideways” as well as forwards, so that they merge cautiously and safely.
  • Model vehicle arrivals using a Poisson distribution vehicles so my mouse button doesn’t wear out

To do (long term)

  • Cars slow down according to the tightness of a curve
  • Make the network interactively editable
  • Cross-overs (either a 2d-fudge or genuine 3d)
  • Cosmetic
    • Render an “underlay” for lanes hanging off the same spine so that they look more like a shared width of bitumen.
    • 3d display engine rewrite (i.e. make it beautiful)

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

RecentComments

Comment RSS