Competitive Pachinko

The Game

Pachinko machines are vertical, flat panels with metal pins sticking out, perpendicular to the surface. Balls fall down from the top, bounce around on the pins, and find their way along more-or-less random paths to one of several exit points at the bottom. As they hit the pins, the balls trigger ping-ding sounds. It's sort of musical and entertaining. Pachinko players can operate some knobs that influence the paths of the balls. Usually, there is money involved, and some of the exit points are more desirable than others. Basically, pachinko is Japanese pinball-cum-slot-machine.

photo courtesy of
hope they don't mind

This project involves designing and implementing  a competitive video-game inspired by pachinko machines. Two players compete to attract a single ball to a collection tray on their side of the screen. The ball falls from a random slot at the top down through a grid of deflectors, to one of two collection trays at the bottom. A deflector directs the ball toward one side or the other, depending on its orientation when the ball hits the deflector. Players occupy a position on the grid. They can reverse the orientation of the deflector at their current position, and they can change positions. The ball moves on its own, bouncing down through the maze of deflectors. Movements and deflector-reversals by the players are controlled through the keyboard, and the screen shows the current orientations of the deflectors and the position of the ball as it falls through the grid. Unfortunately, there will be no ping-ding sounds.

Key Assignments. The player on the left side of the keyboard will use the WASD keys for navigating the deflector grid, and may use either F or Tab for toggling a deflector. The player on the right side will use PL:" (that's the P-key, the L-key, the colon/semicolon key, and the quotation-mark/apostrophe key) for navigation and may use either K or Enter for toggling a deflector. No restrictions on key assignments for game enhancements. (See "Key Events", below, to find out how to interpret key-strokes from passed from DrScheme to your ACL2 code.)

The World. Your pachinko program will need to import the world teachpack. See the worm program on the DrACuLa website for an example program that makes use of the world teachpack. You will also need to import the rand teachpack if you want, for example, to place the deflectors in random directions at the start of a game.

Defstructure. The worm program also uses defstructures. If you want to use them, you can find some documentation on the ACL2 website, or here. Give your program access to the defstructure facility through the following import command:
    (include-book "data-structures/structures" :dir :system)

Graphics. The DrScheme teachpack called "image" provides graphics primitives. All of them are exported by the "world" teachpack, so when you import world, you get the graphics primitives automatically. Use the DrScheme Help Desk (Find docs for: to find out what primitives are available. The sample pachinko code imports the world teachpack, and you will also need to import where you define the world-image function because you will need support for graphics.

Key Events. DrScheme represents key-strokes as characters (for most keys) or symbols (for keys such as F2). It delivers the symbol RELEASE on the upstroke of any key, but it doesn't identify the released key. Some keys (Shift, Ctrl, Alt, and some others) do not generate signals. Mouse events are handled similarly.
    Example programs: key-reps.lisp, mouse-demo.lisp

Standards and Enhancements. This is the basic game. You may want to add features of their own to make the game more entertaining.

Tests and Theorems

You will need to design a data structure to represent the state of the game, and numerous other data structures for other aspects of your software. Your functions will accept and/or generate these structures. As a minimum, every function (except those defined in the world-image hierarchy) should be accompanied by tests and theorems that state that if the function is supplied with arguments with the expected kind, it will deliver values of the expected kind.