Published:2011/8/17 21:17:00 Author:Phyllis From:SeekIC
By Andy&Rose Morrell
Rules for playing Solitaire
As the name suggests, Solitaire is a game to be played on your own. The board is made up of 33 LEDs laid out in a cross shape, where a piece on the board (or ’peg’) is indicated by an active LED.
The aim of this game is to be left with as few pieces as possible at the end of the game. You can claim victory if you have only one piece left in the centre of the ’board’. As you will discover, that’s very hard to do! So how do you arrive at this desired state?
When you turn the game on, there will be 32 LEDs lit up continuously and one, at the centre, flashing. The flashing LED shows your position on the board. The first step is to decide either to play your turn where your piece is or to move the position of your piece. So how do you move your position should you wish to?
1. To move your position simply use the four directions switches S1-S4. You can move your position to wherever you like.
2. When you are positioned to where you want to be, press the SELECT button. The LED that you are positioned on will flash even faster. This means that you are in jump mode. To jump a piece, which must be next to yours — up, down, left or right, but not diagonal — press the appropriate direction switch. The piece you are positioned on will jump over that piece onto the space on the other side, and the jumped piece will disappear. You can only jump a piece if there is a space on the other side of that piece to be jumped, and if there is a piece where you are positioned. It is not always obvious if there is a piece where you are positioned, because the flashing LED looks the same whether it is just your position or whether you actually have a piece there. If the jump is requested and it is impossible, you will hear a beep. The jump mode will be cancelled for that move and you can then continue as before.
3. You continue this procedure until you can jump no more. The smaller the number of pieces left, the better. If (you think) a ’move’ is no longer possible, then the player can press the STALEMATE button. Depending on the score, the buzzer will produce a number of beeps indicating your result:
1 beep = < 10 remaining pieces
2 beeps = 8 remaining pieces
3 beeps = 4 remaining pieces
4 beeps = 1 remaining piece!
Where ’piece’ should be taken to mean ’peg’ or, in electronic parlance, ’LED’! In the assembly code listing, you’ll find labels like ’bad_luck’, ’excellent’, ’well_done’, ’very_good’ and ’good’ to describe relevant routines.
Construction
The game is built on a double-sided printed circuit board of which the copper track layout and component mounting plan are shown in Figure 2. The parts in the enclosed area (LEDs and pushbuttons) should be mounted at the solder side of the board. You may want to do the same with the on/off switch, SI. This is necessary to allow the board to be mounted as close as possible to the inside of the enclosure top panel (with appropriate cutouts for the switches). If you want to use solder pins for the battery connections, these are also best fitted at the solder side.
The photograph in Figure 3 shows the board before it was fitted behind the opaque panel. The red filter enhances the visibility of the LEDs. Actually, that’s achieved by making the board and the other component less visible!
Software
The complete source code listing for the program executed by the AT90S micro is available free of charge from the Publishers’ website at www.elek-tor-electronics.co.uk as file number 030410-11.zip.
The program listing is a good example of simple code with comment where necessary. An extract of the program appears in Listing 1 — this part looks after the LED activity on the ’board’. Finally, those of you unwilling or unable to program your own micro for the project will like to know that the AT90S2313 can also be bought ready-programmed from us under order code 030410-41.
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/17/PLAY_SOLITAIRE_packed_in_an_AT90S_micro__(2).html
Print this Page | Comments | Reading(291)
Author:Ecco Reading(33516)
Author:Ecco Reading(3534)
Author:Ecco Reading(3250)
Author:Ecco Reading(3816)
Author:Ecco Reading(5341)
Author:Ecco Reading(3318)
Author:Ecco Reading(3474)
Author:Ecco Reading(3620)
Author:Ecco Reading(4017)
Author:Ecco Reading(3819)
Author:Ecco Reading(3760)
Author:Ecco Reading(3790)
Author:Ecco Reading(6103)
Author:Ecco Reading(3778)
Author:Ecco Reading(4587)