comparing arrays

Blitz3D Forums/Blitz3D Programming/comparing arrays

'Simple solution':

How about chaining together the digits on the wheels and using a Select statement to create a virtual lookup table for wins...

wheel1 = EvalWheel(Position1)
wheel2 = EvalWheel(Position2)
wheel3 = EvalWheel(Position3)
wheel4 = EvalWheel(Position4)

Allwheels = 1000*wheel1 + 100*wheel2 + 10*wheel3 + wheel4

Select Allwheels
       case 0 ; i.e 0000 = 4 lemons
             ... pay out for 4 lemons
       case 1111 ; = 4 cherries
             ... pay out for 4 cherries
       case 1116 ; = 3 cherries and wildcard
             ... pay out for 3 cherries and wildcard
       case 1161 ; = 3 cherries and wildcard
             ... pay out for 3 cherries and wildcard
       case 1611 ; = 3 cherries and wildcard
             ... pay out for 3 cherries and wildcard
       case 6111 ; = 3 cherries and wildcard
             ... pay out for 3 cherries and wildcard

       ... etc ...


       default
             ; no win
End Select
   
Function EvalWheel(itsPosition)
    if (itsposition = 5) or (itsPosition = 8)
       return 1
    endif
    if (itsPosition = 7)
       return 3
    endif

   return itsPosition
End Function


The EvalWheel() function ignores the actual position and only considers the 'object' on the display, so there is less coding, but still a lot of work to figure all winning positions.

A possible improvement would be to sort the wheel values before entering the Select block, so that 1116, 1161, 1611 and 6111 would all be evaluated by the 1116 case.