Posts Tagged With 'porting'

Awari AI

Written by Tracy Poff in misc on Sun 21 February 2010. Tags: awari, BASIC, porting,

I’ve sorted out the BASIC version of Awari I’m porting into the ‘draw the board’ routine, the ‘make a move’ routine and the ‘incomprehensible AI’ routine. The AI seems to first sow from the first nonempty pit, then makes some weird comparison and modifies a value:

860 FOR I=0 TO N-1:IF F(N)*6+K=INT(F(I)/6^(7-C)+.1) THEN Q=Q-2

The reason for that is fairly inscrutable. F is some array, and the program claims to have a learning mechanism to improve the AI, so I suspect this is that mechanism, but I’m not at all sure how it’s meant to work. I think I’ll have to make a flow chart or something to decipher this thing. This would be easier if the variables had meaningful names. I remember once, when I was first learning to program, I thought that using meaningful names was a big waste of time, since after all the code should be pretty self-evident, right? A second look at my code after some weeks disabused me of that notion, and this serves to reinforce that: code should be self-evident, but it won’t be if you don’t work at it.

Oh well. With any luck, I’ll be able to sort this out with an hour or so of concerted effort–it’s just that reading BASIC is giving me a headache and I haven’t yet put in the requisite time. I must persevere!


Written by Tracy Poff in misc on Sat 13 February 2010. Tags: awari, BASIC, porting,

Trying to decipher an ancient implementation of Awari in a dialect of BASIC I’m not familiar with. Fun!

LETTER, a simple guessing game

Written by Tracy Poff in misc on Thu 11 February 2010. Tags: python, game, porting, BASIC,

Recently, I’ve been looking through a book called Basic Computer Games: Microcomputer Edition, edited by David H. Ahl. The book contains lots of type-in computer games written in Microsoft BASIC for the Altair. A fair number of these ‘games’ are more like toys, and some aren’t even interactive, but a few look like real fun, and they’re all little pieces of computing history, which I find very interesting.

I thought I’d port a few of the more interesting games to a more modern language so people could check them out and see how far we’ve come (or, in some cases, how far we haven’t come). Of course, I thought I’d start by doing exactly what I didn’t set out to do, and port a very simple and not very interesting game, just to get a feel for it. Even this gave me a little pause, as I’ll get into. First, the game: Letter, by Bob Albrecht. That link leads to a scan of (a different edition of) the book I got the game from, so you can see the original BASIC code I was porting. Programmers among us will recognize that it’s extraordinarily simple, and, for a BASIC program, quite clean and readable. One thing gave me a little trouble:

510 FOR N=1 TO 15: PRINT CHR$(7);: NEXT N</pre>

This line didn’t seem to affect the output in the printed sample run of the game, so I got an Altair emulator, just to be sure. Indeed, it doesn’t actually print, though I have no idea why. Whatever the reason, I left it out so as to faithfully reproduce the game as it was on the original system, whatever the code says.

A part of my intention in porting these is to provide sample code for people who may be interested in learning to program; these simple games should prove to be pretty easy to understand for anyone who cares to look. Having just read through quite a lot of BASIC code, I wasn’t in a very pythonic frame of mind when writing this, but I think it’ll be clear enough.

Enough about my troubles, though. You can find the game here. If you have python installed, you can just get the tiny python source file. If not, or if you’re not sure, you can get a ZIP with a Windows executable, instead, which should run on anything from Windows 95 through Vista. If it won’t run, or complains of missing files, you may need this.

I’ll port something more interesting, and hopefully more fun, next time. Until then, I HAVE A LETTER. START GUESSING.