Issues with achieving a "Bingo" in Bingo game. 
	 
	
		| Author | 
		Message | 
	 
		 
		RazorBlade
 
 
 
    
		 | 
		
		
			
				  Posted: Tue Nov 30, 2010 4:10 pm    Post subject: Issues with achieving a "Bingo" in Bingo game.  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I'm trying to create a bingo game using Turing 4.1.1 and I have the cards, and I have the board, and I have it so it picks numbers and colours the ones that are unpicked. I have no idea how to compare the numbers on the card to check for 5 in a row horizontal, vertical or diagonal. I've thought about my code, but I just can't come to a solution.
 
 
 
So far I have this:
 
 
	  | Turing: | 	 		  
%               %
%%%%Variables%%%%
var NR  : int := 5 %Number of Rows
var NC  : int := 5 %Number of Columns
var NCARDS  : int := 5 %Number of Cards
var CARD  : array 1 .. NCARDS,  1 .. NR,  1 .. NC  of int
var RAND  : int
var key  : string (1)
var A  : int
var B  : int
var CARDFACTORforROW  := 0
var CARDFACTORforCOLUMN  := 0
var NUMS  : array 1 ..  75 of int
var NUMBER  : int
var MIN  : int
var SPOT  : int
var TEMP  : array 1 .. NR  of int
var SORTCARD  : array 1 .. NCARDS,  1 .. NR,  1 .. NC  of int
var Board  : array 1 ..  75 of int
var Hopper  : array 1 ..  75 of int
var ColourPalette  : array 0 ..  1 of int
var Boardcolour  : array 1 ..  75 of int
var Choice  : int
var Picked  : array 1 ..  75 of int
var CardColour  : array 1 .. NCARDS,  1 .. NR,  1 .. NC  of int
var BALLNUM  : int := 0
var BINGO  : boolean := false
ColourPalette  (0) := brightblue
ColourPalette  (1) := brightred
%%%%%%%%%%%%%%%%%
%               %
proc Init
     for i  : 1 ..  75
        Board  (i ) := i
     end for
    for i  : 1 ..  75
        Picked  (i ) := 0
    end for
    for i  : 1 ..  75
        Boardcolour  (i ) := 0
    end for
    for x  : 1 .. NCARDS
         for k  : 1 ..  75
            NUMS  (k ) := 0
        end for
        for i  : 1 .. NR
             for j  : 1 .. NC
                 loop
                    NUMBER  := Rand.Int  ((j -  1) * 15 +  1, j  * 15)
                    exit when NUMS  (NUMBER ) = 0
                end loop
                CARD  (x, i, j ) := NUMBER
 
                NUMS  (NUMBER ) := 1
            end for
        end for
    end for
    for x  : 1 .. NCARDS
         for i  : 1 .. NR
             for j  : 1 .. NC
 
                TEMP  (j ) := CARD  (x, i, j )
                SORTCARD  (x, i, j ) := 0
                CardColour  (x, i, j ) := 0
            end for
        end for
    end for
end Init
 proc Sort
     for x  : 1 .. NCARDS
         for j  : 1 .. NC
             for i  : 1 .. NR
 
                TEMP  (i ) := CARD  (x, i, j )
            end for
            for i  : 1 .. NR
 
                MIN  := 999
                for k  : 1 .. NR
                     if TEMP  (k ) < MIN  then
                        MIN  := TEMP  (k )
                        SPOT  := k
                     end if
                end for
                TEMP  (SPOT ) := 999
                SORTCARD  (x, i, j ) := MIN
             end for
        end for
    end for
end Sort
 proc PreChoose
     var Rand1  : int
    var Rand2  : int
    var HopperTemp  : int
    for i  : 1 ..  75
        Hopper  (i ) := i
     end for
    put ""
    for i  : 1 ..  1000
        Rand1  := Rand.Int  (1,  75)
        Rand2  := Rand.Int  (1,  75)
        HopperTemp  := Hopper  (Rand1 )
        Hopper  (Rand1 ) := Hopper  (Rand2 )
        Hopper  (Rand2 ) := HopperTemp
     end for
    put ""
end PreChoose
 proc Boardproc
     for x  : 1 .. NCARDS
         for i  : 1 .. NR
             for j  : 1 .. NC
                 if Choice  = SORTCARD  (x, i, j ) then
                    CardColour  (x, i, j ) := 1
                end if
            end for
        end for
    end for
end Boardproc
 proc Display
 
    CARDFACTORforROW  := 0
    CARDFACTORforCOLUMN  := 0
    for x  : 1 .. NCARDS
         for i  : 1 .. NR
             for j  : 1 .. NC
 
                A  := i + CARDFACTORforROW
 
                B  := (j -  1) * 3 +  1 + CARDFACTORforCOLUMN
                 locate (A, B )
                colour (ColourPalette  (CardColour  (x, i, j )))
                put SORTCARD  (x, i, j ) : 2
            end for
        end for
        CARDFACTORforCOLUMN + = 22
        if x  = 4 or x  = 8 or x  = 12 then
            CARDFACTORforROW + = 9
            CARDFACTORforCOLUMN - = 88
        end if
    end for
    put ""
    for i  : 1 ..  75
        colour (ColourPalette  (Boardcolour  (i )))
        put Board  (i ) : 4 ..
     end for
end Display
 proc Bingo
     for x  : 1 .. NCARDS
         for i  : 1 .. NR
             for j  : 1 .. NC
                 %if ... then
                BINGO  := true
                % end if
            end for
        end for
    end for
end Bingo
 %
%Mainline
%
Init
 
Sort
 
PreChoose
 
BALLNUM  := 0
loop
    BALLNUM + = 1
    Choice  := Hopper  (BALLNUM )
    Boardproc
 
    Boardcolour  (Choice ) := 1
    %Picked (Choice) := 1
    %locate (24, 30)
    %put "The number is ", Hopper (BALLNUM)
    Display
     getch (key )
    %Bingo
    exit when BINGO
 end loop
  | 	  
 
 
The Bingo procedure is where I've started the solving of the issue but I just don't know where to go from there. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		RazorBlade
 
 
 
    
		 | 
		
		
			
				  Posted: Tue Dec 07, 2010 11:16 pm    Post subject: RE:Issues with achieving a "Bingo" in Bingo game.  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Still haven't found a solution. Anyone? :/ | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		TokenHerbz
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 08, 2010 4:31 am    Post subject: Re: Issues with achieving a "Bingo" in Bingo game.  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				well to make things easy.  have your 3Darray contain a boolean to show if that "number" has been selected.  if it has been, then its true.
 
 
in your code, you check to see if a pattern of those numbers (boolean) are true for a bingo.
 
 
The simplest example and test would be to start with some corners...
 
 
Now i have many suggestions to improve your game, however lets first give you an idea to make it work.
 
 
Here are some codes to add...
 
	  | Turing: | 	 		  
%your new variable is here.  This will tell us if the numbers are selected to use to figure out a BINGO
var is_card_number_selected  : array 1 .. NCARDS,  1 .. NR,  1 .. NC  of boolean
                %%%Set all cards to false INSIDE proc Init..
                is_card_number_selected  (x, i, j ) := false
                    %%CARD NUMBERS SELECTED PUT INSIDE PROC Boardproc
                    is_card_number_selected  (x, i, j ) := true
proc Bingo
     for x  : 1 .. NCARDS
         for i  : 1 .. NR
             for j  : 1 .. NC
                 %%%NOW HERE we have to "CHECK" the CARDS for the card numbers to see which have been selected (is_card_number_selected = true)
                %%And use that to see if we have a BINGO, ex: line / BOX / X / FULL CARD...   We will do CORNERS for this test...
                if is_card_number_selected  (x,  1,  1) = true and is_card_number_selected  (x,  1, NC ) = true and
                        is_card_number_selected  (x, NR,  1) = true and is_card_number_selected  (x, NR, NC ) = true then %%these are 4 corners!
                    %%%BINGO for corners right?!?
                    BINGO  := true
                    put "BINGO, CARD ", x,  " WINS WITH CORNERS!"  %%NOTE:  if other cards TIE for BINGO - 1st card will display as winner
                    Input.Pause %to see the bingo  /// Easy fix this is to give you a starting ground.  If you need help with some line logic let me know
                      %%but i want to see some effort and code first :)  This is a quick fix, i'd personally of used a class :) then are fun to use!
                end if
                
                %%%Here you can use some math to check CARD LINES HORRIZONTAL/VERTICLE (unless your lazy and type them all out but my god thats so much work) //math FTW
                %%CODE FOR LINES // X // Black out // etc...  (you can even make an option for making your bingo style, which will go for only 1 win (EX 1st BLACKOUT)
            end for
        end for
    end for
end Bingo
 %%Dont forget to uncomment your BINGO IN MAIN LOOP %% Test run it, and go from there :)
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |