Shadowcasting in C#, Part Six

OK, let’s finish up this year and this series. We have an algorithm that can compute what cells in the zero octant are in view to a viewer at the origin when given a function that determines whether a given cell is opaque or transparent. It marks the visible points by calling an action with…


Shadowcasting in C#, Part Five

I hope you all had a pleasant Christmas and Boxing Day; we chose to not travel to see family this year and had a delightful time visiting friends. We’ll finish up 2011 here with a bit more on shadowcasting, and then pick up with more C# language design facts and opinions in January. OK, so…


Shadowcasting in C#, Part Four

Last time we saw how many different ways there were to get the calculation of the top cell based on the top vector wrong. Today we’ll take a briefer look at determining the bottom cell. We know from our discussion of last time that the right way to determine what is the top-most visible cell…


Shadowcasting in C#, Part Three

Before we get started, thanks for all the great comments to the previous couple of posts. I’ll be updating the algorithm to try to make even better-looking circles of light based on the comments. Like I said, there’s a lot of subtleties to these algorithms and I am just learning about them myself. To that…


Shadowcasting in C#, Part Two

I hope the basic idea of the shadow casting algorithm is now clear. Let’s start to implement the thing. There are two main concerns to deal with. The easy one is “what should the interface to the computation look like?” The second is “how to implement it?” Let’s deal with the easy one first; let’s…


Shadowcasting in C#, Part One

I’ve always loved the “roguelike” games; perhaps you’ve played some of them. Those are the games where you get a top-down view of a tile-based world, and have as much real time as you like to make a choice of action. The canonical plot is to enter a dungeon, get to the bottom, retrieve the…


Roguelike people

No technology today. Rather, some advice. I don’t know if there’s some sort of grifter convention going on, but I have seen four different short-con artists operating in Wallingford, the neighbourhood of Seattle where I live, in the last three days. Though that might be a slight mischaracterization. One of them was selling from a…


So many interfaces, part two

In my earlier article from April 2011 on interface implementation I noted that C# supports a seldom-used feature called “interface re-implementation”. This feature is useful when you need it but unfortunately is one of those features that can bite you if you use it incorrectly or accidentally. Every interface method of every interface you implement…


What’s the difference? Remainder vs Modulus

Today, another episode of my ongoing series “What’s the difference?” Today, what’s the difference between a remainder and a modulus, and which, if either, does the % operator represent in C#? A powerful idea that you see come up in mathematics and computer programming over and over again is the idea of an equivalence relation….


Why have a stack?

Last time I discussed why it is that we have all the .NET compilers target an “intermediate language”, or “IL”, and then have jitters that translate IL to machine code: because doing so ultimately reduces the costs of building a multi-language, multi-hardware platform. Today I want to talk a bit about why IL is the…