Files
basic-computer-games/75_Roulette/perl
Tom Wyant 09b0e972cd Port 75_Roulette to Perl.
The directory includes a Perl script to test the port (roulette-test.t)
and a Perl script to generate the test based on output from the BASIC
implementation (make-roulette-test.pl).
2022-01-11 17:00:28 -05:00
..
2022-01-11 17:00:28 -05:00
2022-01-11 17:00:28 -05:00
2022-01-11 17:00:28 -05:00

Original source downloaded from Vintage Basic

Conversion to Perl

This conversion consists of three files in 75_Roulette/perl/:

  • roulette.pl is the port of the BASIC to Perl;
  • roulette-test.t is a Perl test for correctness of display and payout;
  • make-roulette-test.pl generates roulette-test.t from roulette.bas.

The ported version of the game numbers the slots from 0 rather than 1, and uses a dispatch table to figure out the payout.

The Perl test loads roulette.pl and verifies the Perl slot display and payout logic against the BASIC for all combinations of slots and bets. If any tests fail that fact will be noted at the end of the output.

The test code is generated by reading the BASIC, retaining only the slot display and payout logic (based on line numbers), and wrapping this in code that generates all combinations of bet and spin result. The result is run, and the result is captured and parsed to produce roulette-test.t. make-roulette-test.pl has some command-line options that may be of interest. --help will display the documentation.