Crack The Code a game by: - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Crack The Code a game by:

Description:

Crack The Code. a game by: Curt Stoeber. Nicholas Louckes. Group project, CSE 378 ... Guess the four digit code that is randomly generated by the micro-controller ... – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 13
Provided by: SECS
Category:
Tags: code | crack | curt | game

less

Transcript and Presenter's Notes

Title: Crack The Code a game by:


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 LEDs.
  • Formulate another guess.

A random four digit number is created and stored
within the game.
The LEDs tell the player if a digit in the
players 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 gt Rnd_num 0001 (1)
  • State 2 gt Rnd_num 0010 (2)
  • State 3 gt Rnd_num 0100 (4)
  • State 4 gt Rnd_num 1000 (8)

Number of possible combinations 4444 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
players 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 - (Players guess versus
computers solution)
Check the first digit of the players 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) lt '1'
If no match is found check the other three digits
of the solution against the first digit of the
players 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) lt '1' elsif (T(15 downto 12) N(7
downto 4)) then Y(3) lt '1'
elsif (T(15 downto 12) N(3 downto 0)) then
Y(3) lt '1' end if end if

Repeat this process for the remaining three
digits in the players guess.
11
WHYP Program used to generate our games 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_at_ 11 DIG! SHIFT ( n1 t -- n1 t
) \ Shift guess BEGIN DIG! GET.BTN
SW_at_ 1- 0 IF BTN_at_ 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_at_ 0 UNTIL DROP DROP
MAIN ( -- ) BEGIN 08 gtR
\ Load count into RStack GET.BTN
INITIAL ( -- rnd guess) BEGIN
SW_at_ 0F AND 0 0 \ Wait for switch set
UNTIL BEGIN BEGIN SW_at_
1- 0 \ Get switch settings
UNTIL SHIFT ( rnd guess -- rnd
guess ) BEGIN SW_at_ 81 - 0
\Safety to make sure switches right
UNTIL COMPARE ( rnd guess -- rnd
guess ld flag) Rgt 1- DUP gtR DIG! 0 OR
\ Decrement count UNTIL
\ and check for win DUP F0 - 0
IF RgtDROP WIN.LOSE
\ win ELSE RgtDROP 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 CLBs) 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.
Write a Comment
User Comments (0)
About PowerShow.com