The magazine of the Melbourne PC User Group

Two QBASIC Programs, Now With More Features
Keith Phillips

Two QBASIC programs, QBchess!.bas and QBfigure.bas, are available for download from PC Update Online in a file named QB&more!.zip [158 KB]. They are enhanced versions of programs that have been published in PC Update

The QBchess!.bas Program

The simple chess program in PC Update November 2000 used QBASIC Screen0, which is a text-only screen, so letters were used to represent the chess pieces. The program on PC Update Online uses QBASIC Screen8 which can display both graphics and text. The chess pieces are displayed as shapes and the prompts are displayed as text. In VGA, Screen8 has four pages of video memory, each of which can store a screen image. All four video pages can be displayed, but only one at a time. QBchess!.bas is designed to display chess puzzles, end games and example games and to store them in data files. Full details are with the program on PC Update Online. 

Chess Startup

When the program starts, all the chess pieces are displayed on the board as shown in screen Image 1. Drag and drop moves the chess pieces. A left mouse click on any chess piece marks all the squares threatened by the piece as shown for a black queen and a white bishop in screen Image 2. [ Note: These images are contained in the file Image.zip contained in the main QB&more!.zip file.] The marks are useful for inexperienced chess players. It is also helpful to drag the piece along a path of marked squares when moving it across the chess board. A left click on any blank square, or moving a piece, removes all the marks. 

Chess Puzzles to be Solved in Two or Three Moves

Double Left click on "BlankScreen" clears the chess board. Single Left and Right clicks set up the puzzle. Double Left Click on "CopyMoves" copies the puzzle into one of the pages of video memory. After each move, Double Left Click on "CopyMoves" copies the move into a different page of video memory. Finally, Double Left Click on "ViewMoves0123" redisplays the video memory page by page. 

Chess Data Files

There are some example chess data files with the program in QB&more!.zip on PC Update Online. You can use existing data files and create new data files. 

Double Left Click on "SaveF" saves the displayed screen onto the end of a data file. Repeated use of "SaveF" builds a record of up to 255 moves. 

Double Left Click on "LoadF" displays chess moves from data files and it can also edit or delete data files. When "LoadF" is running the threatened squares can be marked either selectively or automatically, as shown in screen Image 3. The white marks show all the squares threatened by the white pieces and the shadow image of the black king shows which square it was moved from. The shadow piece disappears when any key is pressed. 

The QBfigure.bas Program 

"Figure It Out" puzzles are published in "The Saturday Age Extra". About three quarters of these puzzles can be solved by algebra alone. The puzzle in PC Update July 1999 is an example of this type of puzzle and screen Image 4 shows how QBfigure.bas displays the puzzle at the stage when all ten letters have been solved. 

The puzzle in PC Update August 1999 is an example of a puzzle that can't be completely solved by algebra. Screen Image5 shows how QBfigure.bas displays the puzzle at the stage when the table of results appears. The column of white letters shows the values for all the letters, including the lost letter. 

The puzzle in "The Age", 15 April, 2000 is the only example I've seen where there are two possible values for the missing letter. Screen Image6 shows the puzzle at the stage where H can be either 4 or 6. There are two sets of valid values for the ten equations. However, there is only one valid result for the missing letter. For H=4 & B=6 the missing letter is C=9, but for H=6 & B=4 the result is ?=11 which is not a valid value. 

How to Run These Qbasic Programs

If you don't have copies of qbasic.exe and qbasic.hlp on your hard drive, make a new folder on the hard drive named C:\QB (Or any other name of your own choice). Click the Start Menu and click Find to search your Windows 95 or 98 CDRom for qbasic. Copy the two qbasic files into C:\QB (Or your chosen folder name). Download QB&more!.zip from PC Update Online and unzip it into C:\QB (Or your chosen folder name) to obtain File_id.diz, Info.zip, QBchess!.zip and QBfigure.zip. Unzip Info.zip for more information. 

FOOTNOTE

QBfigure.bas solves the "Figure It Out" puzzle in "The Age", 24/Feb/01 as: A=8, B=3, C=4, D=8, E=4, F=7, G=0, H=6, J=2, K=3, which is an unacceptable result because of duplicate values. Change H=6 in the puzzle to H=9 and the solution becomes: A=5, B=3, C=1, D=8, E=4, F=7, G=0, H=9, J=2, K=6, which is the published result in "The Age", 3/Mar/01.

Reprinted from the May 2001 issue of PC Update, the magazine of Melbourne PC User Group, Australia

 

[About Melbourne PC User Group]