After converting the Awari game, I got cocky and went ahead with converting a maze generator called Amazing, even though it had been converted before. That one knocked the stuffing out of me, and after messing with it for half the week, I learned that the original code had the same bugs I was trying to squash.

Bagels was an easy conversion, that is identical to the game known of as Mastermind.

Banner was hard to work with without a line-flow printer. It’s converted but would need an actual printer to test whether it works properly or not. It also seems weird to have a banner printer mixed in with the games, but okay. I’ll no doubt come across other oddities that have been included in with the games.

Basketball and Batnum converted without too much trouble, and I’m getting a lot better at using regular expressions to find/replace large parts of the code. I will at some stage have to come up with a converting program, as manually converting the code is quite the time-consuming process.

Battle was a confusing one to convert, for it used the same name for both variable names and numbers, where c() is an array, and r and c are also separate numbers as well.

1290 IF C(F(R,C))<4 THEN 1340

Because JavaScript does not allow using the same variable name for separate types, the only way to convert this is to give different names for the array and the numbers. As strings are given a dollar sign suffix, it makes sense to give arrays some other type of suffix, so at the moment I’m giving the arrays an Arr suffix.

I’ve also found it useful to flip the conditions that are being checked. That way instead jumping over to line 1340, we can instead check for the inverse condition and execute that code only when that inverse condition occurs. My reason currently for keeping the obscure single letter names is that I eventually want to write a converting program that will do much of the work for me.

if (cArr[fArr[r][c]] >= 4) {

Battle also became easier to convert when I divided up the code in to several separate functions. One of the variables called M was difficult to incorporate in to an improved structure of the code. The purpose of the M variable was for when looking at a previous array location. If you were at the first location there would be no previous one to look at, so M was used to prevent you looking at the previous until after the first one had been done.

170 FOR K=1 TO N
180 IF M>1 THEN 240
190 IF B(K)=6 THEN 230
200 IF F(A,B(K)+1)>0 THEN 230
210 B(K+1)=B(K)+1
220 GOTO 280
230 M=2

Instead of setting the value of M only once, it became much easier in the structure of the code for the M variable to be set every single time.

for (k = 1; k <= n; k += 1) {
    if (m > 1 ||
            (bArr[k] === 6) ||
            (f_[a][bArr[k] + 1] > 0)) {
        m = 2;

After working my way through those issues, I came to my next challenge – Blackjack. This is a monster of the game that’s three times larger than anything else so far. It’s time to put my regular expression skills to work and start creating a program to help me convert large parts of the code.

Advertisements