1 / 12

Crack The Code a game by:

Crack The Code a game by:. Curt Stoeber Nicholas Louckes Group project, CSE 378. What is the object of the game?. Guess the four digit code that is randomly generated by the micro-controller using a limit of eight tries.

chun
Download Presentation

Crack The Code a game by:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Crack The Codea game by: Curt Stoeber Nicholas Louckes Group project, CSE 378

  2. What is the object of the game? Guess the four digit code that is randomly generated by the micro-controller using a limit of eight tries. Each of the four buttons is assigned a 7-segment display and can cycle through the four available numeric choices by pressing the button several times. Pushing button (1) three times would produce the above result.

  3. How can I play Crack the Code? • Start the game using a button and switch combination. • Enter a guess using the four buttons to cycle the 7-segment displays. • Submit the guess using a button and switch combination. • Evaluate the clues returned to you on the LED’s. • Formulate another guess. A random four digit number is created and stored within the game. The LED’s tell the player if a digit in the player’s guess is in the solution, and if a digit is in the proper location.

  4. The building blocks of any good game...

  5. What changes are needed to create this game? Added random number generator Added button module to determine if a button was pushed and what button was pushed Made minor modifications to the control, and step display modules Changed Data Stack module to regulate game play

  6. Inside the random number generator • State 1 => Rnd_num = 0001 (1) • State 2 => Rnd_num = 0010 (2) • State 3 => Rnd_num = 0100 (4) • State 4 => Rnd_num = 1000 (8) Number of possible combinations 4*4*4*4 = 256 Each bit of the 3 bit counter is used as a clock input to three of the state machines, effectively changing its state each time the bit is a one.

  7. What changes were made to the DataStack_ALU? Original DataStack_ALU

  8. Modifications to the DataStack_ALU are as follows... Added LSX module to cycle the 7-segment displays Added compare feature to ALU3 to compare the player’s four digit guess to the solution stored in the game Revised stack to accommodate the new 16 bit bus width.

  9. Detailed analysis of the bit shifting module T1 hold the 16 bits of register T, the current top of the stack and the values that are currently displayed on the 7-segment displays. Within the module this value is divided into four sets of four bits tshift delivers the number of the button pushed by the player 0001 0010 LSX Module The left_shift registers then shift the four bits selected by a corresponding button push

  10. Algorithm used to compare register T contents to register N contents - (Player’s guess versus computer’s solution) Check the first digit of the player’s guess against the first digit of solution and light the first LED of the left group if a match is found. if (T(15 downto 12) = N(15 downto 12)) then Y(7) <= '1'; If no match is found check the other three digits of the solution against the first digit of the player’s guess, and light the first LED of the right group if a match is found. else if (T(15 downto 12) = N(11 downto 8)) then Y(3) <= '1'; elsif (T(15 downto 12) = N(7 downto 4)) then Y(3) <= '1'; elsif (T(15 downto 12) = N(3 downto 0)) then Y(3) <= '1'; end if; end if; Repeat this process for the remaining three digits in the player’s guess.

  11. WHYP Program used to generate our game’s ROM HEX : DELAY ( -- ) \ Delay F0 FOR NEXT ; : GET.BTN ( -- ) \ Wait for button push BEGIN BTN? 0= UNTIL BEGIN BTN? UNTIL ; : INITIAL ( -- n1 t ) \ Initialize game RND@ 11 DIG! ; : SHIFT ( n1 t -- n1 t ) \ Shift guess BEGIN DIG! GET.BTN SW@ 1- 0= IF BTN@ 1- DUP 0= IF SWAP SHIFT1 SWAP ELSE DROP THEN 1- DUP 0= IF SWAP SHIFT2 SWAP ELSE DROP THEN 1- DUP 0= IF SWAP SHIFT3 SWAP ELSE DROP THEN 1- DUP 0= IF SWAP SHIFT4 SWAP ELSE DROP THEN ELSE 0= THEN UNTIL ; : COMPARE ( n1 t -- n3 n2 n1 f ) \ Compare guess COMP LD! DUP F0 - 0= ; : WIN.LOSE ( n2 n1 t -- ) \ Display win or loss LD! DROP BEGIN SWAP DIG! DELAY FLASH DELAY SW@ 0= UNTIL DROP DROP ; : MAIN ( -- ) BEGIN 08 >R \ Load count into RStack GET.BTN INITIAL ( -- rnd guess) BEGIN SW@ 0F AND 0= 0= \ Wait for switch set UNTIL BEGIN BEGIN SW@ 1- 0= \ Get switch settings UNTIL SHIFT ( rnd guess -- rnd guess ) BEGIN SW@ 81 - 0= \Safety to make sure switches right UNTIL COMPARE ( rnd guess -- rnd guess ld flag) R> 1- DUP >R DIG! 0= OR \ Decrement count UNTIL \ and check for win DUP F0 - 0= IF R>DROP WIN.LOSE \ win ELSE R>DROP DROP -ROT DROP FALSE WIN.LOSE \ loss THEN AGAIN ;

  12. Demonstration of game Unfortunately we are unable to demonstrate this game. We have verified that our design works using the simulation program for the Xilinx chip, but due to the size of our design (402 CLB’s) we were unable to program our chip and physically test the game. Our chief suspect in the unfortunate size of our game is the 16-bit bus width that we deemed necessary to simplify various design issues.

More Related