January 27, 2008

notes on an apple iie front panel

I'm working on some ideas that may eventually evolve into a 'front panel' for my //e.
The proposed feature list (in descending order of likelyhood that I will have the time & skill to implement):

  • A toggle to flip between a 'standard' ROM and a crack-ROM (most likely "Senior PROM")
  • A debounced 'NMI' pushbutton
  • A 4 digit readout of the current program counter
  • hardware breakpoints (i.e. an address can be entered through a 4x4 keyboard, and when that address is executed, read or written, an NMI is generated).
  • A 'single step' mode.

I intend to use one or more Atmega8 microcontrollers in this. Here are some relevant links so I can keep track of them:

January 01, 2008

dsktool 0.4.2

I've just released version 0.4.2 of dsktool.rb, a command line tool
and library for working with DSK images, written in ruby.

The major changes in this version are:

* DOS 3.3 support now read/write
* NADOL support (read/write)
* ProDOS support (read only)
* Pascal support (read only)
* Hi Res Graphics converted to PNG

Instructions on how to install and get started with dsktool.rb are at
http://dsktool.jamtronix.com

November 11, 2007

quotes of the month

Those lulls in the conversation over dinner? That's the nerd working on his project in his head. Rands In Repose : The Nerd Handbook

Have you ever been fucking a blonde up the ass and then, like, pushed her face into your monitor filled with a maximized terminal window and shouted “SUDO MAKE ME A SANDWICH, BITCH!” That’s hawt. Dive Into Mark : Installing MySQL on Ubuntu (the NSFW way)

September 07, 2007

the yellow scarf

A new aussie rugby forum: The Yellow Scarf

August 26, 2007

two apple 2 related items

Item the first: 

I've turned the 'Hardcore Computist' article index into a web page so
you can navigate from each article directly to the page containing the
article. In the process, I've created a mirror of the scans from
http://www.computist-project.net/, so i could link directly to a page.

The article index is at http://computist.jamtronix.com/article_index.html

Item the second:

I've released a new version of dsktool.rb. Change log:

V0.2.1
* Added support for NADOL disks (Nibbles Away Disk Optimized Language)
* Added sector viewer to dskexplorer.rb
* DOS 3.3 support now more robust

If you don't know what NADOL is, it's the "Nibbles Away Disk Optimized Language" - a simple DOS + Pascal like language orientated towards building scripts for deprotecting disks. But it's turing complete, and has enough text and graphics commands to allow creation of (for example) a BRICKOUT clone. Docs are at http://www.textfiles.com/apple/DOCUMENTATION/nibbles.away.iii.txt and there's a DSK image at http://jamtronix.com/dsks/NADOL.DSK 

July 29, 2007

writing rock-paper-scissors bots in ruby

RubyShamBo is a framework for hosting RoShamBo (also known as Rock-Paper-Scissors) tournaments between different computer players (aka bots). RoShamBo is a simple game played between two players. On each turn, the players simultaneously choose one of "rock", "paper", or "scissors". If they choose the same item, the result is a tie; otherwise paper covers rock, scissors cuts paper, or rock crushes scissors. A match consists of a series of turns between the two players.

The game is trivial from a game-theory point of view. The optimal mixed strategy is to choose an action uniformly at random (one-third probability of each). This will ensure a break-even result in the long run, regardless of how strong (or how weak!) the opponent is.

However, against predictable opponents, a player can attempt to detect patterns in the opponent's play, and exploit those weaknesses with an appropriate counter-strategy.

A RubyShamBo tournament pits ruby programs, each implimenting different strategies, against each other. RubyShamBo was inspired by the International RoShamBo Programmming Competition. Much of this summary has been shamelessly stolen from the original announcement of that competition. After each turn, the winning bot recieves 1 point, and the losing bot losses 1 point. If the game ends in a tie, no points are awarded. At the end of the tournament, the bots are ranked by the total number of points they have gained in all matches against all bots.

Some of the programs in a RubyShamBo tournament will use sub-optimal strategies, and will be vulnerable to a perceptive and adaptive opponent. Of course, there is always a risk associated with such a prediction, as that player may be attempting to trap its opponent by anticipating the reaction to previous plays.

The most successful programs will recognize a variety of patterns and relationships, and use that information to gain an advantage over each opponent, without being susceptible to similar attacks.

At this stage there are no firm plans to host a public RubyShamBo tournament, but if you'd like to enter (or even help organise) such an event, please send an email to jonno at jamtronix dot com expressing your interest.

running a tournament

First, you will need to have ruby installed. Windows users should get the latest version of the One-Click Ruby Installer. Users of other platforms can consult the Ruby downloads site for a suitable version.

Once ruby is set up on your machine, download the zip file containing latest RubyShamBo release and unzip to somewhere on to your local drive. The zip file will include the following folders :

  • lib/ which contains 'rubyshambo.rb' which has all of the code for hosting a tournament
  • bots/ which has a number of files each containing the code for a single bot
  • test/ which contains 'test_tournament.rb', which will set up and run a tournament that pits every bot defined in the bots/ directory against each other, and then print out the results.
At the command line, cd to the test/ directory and type ruby test_tournament.rb. After about a second, the tournament results will be printed to the screen like so:
C:\src\rubyshambo\test>ruby test_tournament.rb
Wagner 1            : 6027
YoungGun 1          : 2925
CivilWarBuff 1      : 2596
Bot 1               : 1
OldGeneral 1        : -442
SensitiveLefty 1    : -586
SportsFan 1         : -2608
BrokenRecord 1      : -7913
This shows the most successful bot in this tournament is 'Wagner 1' which won 6027 more turns than it lost. The least succesful bot was 'BrokenRecord 1' which lost 7913 more turns than it won.

creating your own bot

Creating a new RubyShamBo bot requires some knowledge of programming in ruby. You should at least be able to complete the introductory browser-based tutorial at the Try Ruby! website. The rules that must be followed by each bot competing in a RubyShamBo tournament are:
  1. The bot must be a subclass of Bot (which is defined in rubyshambo.rb)
  2. The bot must impliment a method called 'get_throw' which takes a single parameter, which is a MatchHistory object (also defined in rubyshambo.rb), and returns a symbol, which must be either :rock, :paper, or :scissors.
  3. If you define an 'initialize' method for the bot, it must not have any mandatory parameters (else the tournament framework can't autoload it)

The MatchHistory object that gets passed in to each call contains the following fields:

  • turns_played will be 0 on the first turn against a new opponent
  • my_throws is an array recording every throw you've made in the current match. Since ruby arrays are zero-indexed, match_history.my_throws[0] will have the throw you selected on the first turn in this match, match_history.my_throws[6] will have the move you made on the seventh turn, and match_history.my_throws.last will have the last throw you made.
  • opponent_throws is an array recording every throw the current opponent has made in this match. The throw the opponent made last turn is in match_history.opponent_throws.last
  • my_score is the score for the current match. The opponents score for the current match will always be the inverse of your score. i.e. if match_history.my_score is 5, that means you have won 5 more turns than you have lost in the current match (and thus the opponent's score must be -5).
There are some helper methods and arrays you can use:
  • VALID_THROWS is an array containing [:paper,:scissors,:rock], i.e. VALID_THROWS[1] will return :scissors
  • WINNING_THROW is a hash where the keys are possible throws and the values are the throw that beats the key. i.e. WINNING_THROW[:rock] returns :paper.
  • Turn.random_throw will return a random throw.

an example bot

Here is the bot called 'Old General' (found in bots/oldgeneral.rb). He's called that because he's always planning to fight the last war. On the first turn he throws at random. On every subsequent turn, he throws whatever would have won the last turn
class OldGeneral<Bot
	def get_throw(match_history)
		if (match_history.turns_played==0) then
			return Turn.random_throw
		end
		return WINNING_THROW[match_history.opponent_throws.last]
	end	
end

useful links

June 24, 2007

dskexplorer.rb

dskexplorer.rb is a browser based DSK archive exploring tool. It can explore both local disk and remote web archives. It is part of the dsktool.rb package. You will need to have ruby installed.

To install dskexplorer.rb, you just need to install the dsktool.rb rubygem. Depending on your OS, that is done by typing either gem install dsktool or sudo gem install dsktool at a command prompt.

To use, run dskexplorer.rb and specify the location of the DSK archive to explore using the '-r' switch.
For example dskexplorer.rb -r http://www.apple2.org.za/mirrors/
Then open a browser, and navigate to http://localhost:6502/