Full House ?

1. Junior Member
Join Date
Dec 1969
Posts
10

## Full House ?

Please help :)<BR>How to Identify and calculate the highest score of Full House with 6 Dices when Full House is only 5 Dices ( 3 + 2)<BR>The Problem is not realy to Identify that you have a Full House, the problem start when you want to calculate the score.<BR><BR>example:<BR>I roll, 2 2 3 4 4 2<BR>(Full House = 222+44)<BR>Roll the 3 again and get a 4, so now the Full House is: 444+22 (and a 2 that that is useless)<BR><BR>with Six dices you can have a Full House when you roll:<BR>3+2+1<BR>2+3+1<BR>1+2+3<BR>3+1+2<BR>3+3<B R>4+2<BR>2+4<BR><BR>I have included "Tower" and "Yatzy" calculations, they are pretty basic but may help you understand how I think.<BR>======================================== ================================================== <BR><BR><BR>d1 = 0 &#039;==Can be any number from 1 to 6==<BR>d2 = 0 &#039;==Can be any number from 1 to 6==<BR>d3 = 0 &#039;==Can be any number from 1 to 6==<BR>d4 = 0 &#039;==Can be any number from 1 to 6==<BR>d5 = 0 &#039;==Can be any number from 1 to 6==<BR>d6 = 0 &#039;==Can be any number from 1 to 6==<BR><BR>All = d1 + d2 + d3 + d4 + d5 + d6 <BR><BR>Dim arrAntal(6)<BR>arrDices = Array("", d1, d2, d3, d4, d5, d6)<BR><BR>For I = 1 To Ubound(arrDices)<BR>arrNrDice(arrDices(I)) = arrNrDice(arrDices(I)) + 1<BR>Next<BR><BR>&#039;== Tower ========================<BR>For I = 1 To Ubound(arrNrDice)<BR>If arrNrDice(I) = 4 Then<BR> For J = 1 to Ubound(arrAntal)<BR> If arrAntal(J) = 2 And J &#060;&#062; I Then<BR> Response.Write("Tower: " & All & "p")<BR> End If<BR> Next<BR>End If<BR>Next<BR><BR>&#039;== Yatzy ========================<BR>For I = 1 To Ubound(arrNrDice)<BR>If arrNrDice(I) = 6 Then<BR>YatzyPts = 100<BR>Response.Write("Yatzy: 100p !!")<BR>End If<BR>Next

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Homework problem, it seems

And your answer for Yatzy is *WRONG*. Period.<BR><BR>The right answer would be something like:<BR><BR>sum = 0<BR>For I = 1 To 6 <BR> sum = sum + arrNrDice(I) <BR>Next<BR>If sum = 36 Then <BR> YatzyPts = 100<BR> Response.Write("Yatzy: 100p !!")<BR>End If<BR><BR>Or even, given the code you showed, simply:<BR><BR>If all = 36 Then <BR> YatzyPts = 100<BR> Response.Write("Yatzy: 100p !!")<BR>End If<BR><BR>********************<BR><BR>Your TOWER code is all screwed up, too, I think.<BR><BR>Maybe you need to think about this a *lot* longer.<BR><BR>HINT: First things first, *SORT* the array.<BR>Makes it *MUCH* easiers.<BR><BR>And what in the flying world is *this* code for:<BR> For I = 1 To Ubound(arrDices)<BR> arrNrDice(arrDices(I)) = arrNrDice(arrDices(I)) + 1<BR> Next<BR>???<BR><BR>I think you need to start over.<BR><BR>Oh... and this isn&#039;t *really* advanced.<BR><BR>Oh, the logic for the pattern matching might be a little advanced, but the programming part of it is not, really.<BR><BR><BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
3,195

## I thought it looked

like homework too ; )<BR><BR>He also needs to understand that vbscript arrays are zero-based (i.e. - that means they start at 0 not 1 ; )<BR><BR>Also, I would recommend looking at using a two dimensional array and storing the individual dice counts as well and then do some sorting. Though I would caution this is not as easy at it looks especially if he has other requirements like accounting for other occurrences beside just his &#039;full house&#039; example.

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Minor point of disagreement...

&#062; He also needs to understand that vbscript arrays are zero-based <BR><BR>He obviously *does* understand that part. Look here:<BR> arrDices = Array("", d1, d2, d3, d4, d5, d6)<BR><BR>See? He purposely put a "junk" value in the zero slot.<BR><BR>I use this technique myself, from time to time, when the data I&#039;m working with more naturally lends itself to thinking from 1 to N instead of from 0 to N-1. Just ignore the zero slot. You&#039;re wasting a whole 16 bytes of memory by doing so. Whoopee.<BR><BR><BR>

5. Junior Member
Join Date
Dec 1969
Posts
10

## Sorry

Sorry, should have read through the code after trying to translate it all to english (all variables was in swedish and I thought it might help to translate them.)<BR><BR>The Code:<BR>For I = 1 To Ubound(arrDices)<BR>arrNrDice(arrDices(I)) = arrNrDice(arrDices(I)) + 1<BR><BR>Make a new array with the # of 1,2,3,4,5,6, example:<BR>I roll 3,3,4,5,5,6<BR>Then the arrNrDice looks like this: arrNrDice("",0,0,2,1,2,1)<BR><BR>I&#039;ll post the original code instead:<BR><BR> Dim arrAntal(6)<BR> arrDices = Array("", d1, d2, d3, d4, d5, d6)<BR><BR> For I = 1 To Ubound(arrDices)<BR> arrAntal(arrDices(I)) = arrAntal(arrDices(I)) + 1<BR> Next<BR><BR> &#039;== Yatzy ========================<BR> For I = 1 To Ubound(arrAntal)<BR> If arrAntal(I) = 6 Then<BR> YatzyPts = 100<BR> Response.Write("Yatzy: 100p GRATTIS !!<BR>")<BR> End If<BR> Next<BR><BR><BR>I stil have the "Full House" problem :)<BR>

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Okay, you got the Yatzy right...

...sorry about that.<BR><BR>So your full house code is just a variation on that, isn&#039;t it?<BR><BR>If you find a 3 or 4 in arrAntal(I), then search it again looking for a 2 or 3. Presto.<BR><BR>For I = 1 To 6 &#039; why do you keep using UBOUND? It&#039;s ALWAYS 6<BR> If arrAntal(I) &#062;= 3 Then<BR> For J = I+1 To 6<BR> If arrAntal(J) &#062;= 2 Then<BR> Response.Write "Full House: " & I & " and " & J<BR> End If<BR> Next<BR> End If<BR>Next<BR><BR>Naturally, you should only do this check *after* rejecting 4 of a kind as a play.<BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
96,118

Sorry!<BR><BR>For I = 1 To 6 &#039; why do you keep using UBOUND? It&#039;s ALWAYS 6<BR> If arrAntal(I) &#062;= 3 Then<BR> For J = [hl="yellow"]1[/hl] To 6<BR> If arrAntal(J) &#062;= 2 Then<BR> Response.Write "Full House: " & I & " and " & J<BR> End If<BR> Next<BR> End If<BR>Next<BR><BR>

8. Senior Member
Join Date
Dec 1969
Posts
96,118

## STILL A DORK!

Sheesh! I can&#039;t a simple thing like this right! Aaarrrgghh.<BR><BR>ONE MORE TRY:<BR><BR>For I = 1 To 6 &#039; why do you keep using UBOUND? It&#039;s ALWAYS 6<BR> If arrAntal(I) &#062;= 3 Then<BR> For J = [hl="yellow"]1[/hl] To 6<BR> If [hl="yellow"]J &#060;&#062; I AND[/hl] arrAntal(J) &#062;= 2 Then<BR> Response.Write "Full House: " & I & " and " & J<BR> End If<BR> Next<BR> End If<BR>Next<BR><BR>Grumble grumble...this makes me feel really stupid.<BR><BR>

9. Junior Member
Join Date
Dec 1969
Posts
10

## RE: STILL A DORK!

Thankyou Bill, but like I said in the first post: the problem is not realy to Identify it as a "Full House", the problem start when you want to calculate the highest score. Test this roll with your code: 333444<BR>And try to make it get to get the score: 4+4+4 + 3+3 = 18 and then write it to the page. I just cant think in the proper way to make it work, Im sure its just some "simple" thing I havent thought of... geez this should be easy :P your not the only one who feels stupid :)<BR><BR>Some stupid code that doesnt work:<BR>For I = 1 To 6<BR> If arrAntal(I) &#062;= 3 Then <BR> For J = 1 To 6 <BR> If J &#060;&#062; I AND arrAntal(J) &#062;= 2 Then<BR> If I &#062; J And J = 3 Then<BR> KakPts = I*3 + J*2<BR> Response.Write KakPts & "<BR>"<BR> Response.Write I & "<BR>"<BR> Response.Write J & "<BR>"<BR> Else<BR> KakPts = J*3 + I*2<BR> Response.Write KakPts & "<BR>"<BR> Response.Write I & "<BR>"<BR> Response.Write J & "<BR>"<BR> End If<BR> End If <BR> Next <BR> End If <BR>Next

10. Junior Member
Join Date
Dec 1969
Posts
10

## Think I got it...

I have to use 2 loops to get it right:<BR><BR> &#039;== Kåk =========================<BR> For I = 1 To 6<BR> If arrAntal(I) &#062;= 3 Then <BR> For J = 1 To 6 <BR> If J &#060;&#062; I AND arrAntal(J) = 3 Then<BR> If J &#060; I And I &#062;= 3 Then<BR> KakPts = I*3 + J*2<BR> Response.Write KakPts & "<BR>"<BR> Response.Write I & "<BR>"<BR> Response.Write J & "<BR>"<BR> End If<BR> End If <BR> Next <BR> End If <BR> Next <BR><BR> For I = 1 To 6<BR> If arrAntal(I) &#062;= 3 Then <BR> For J = 1 To 6 <BR> If J &#060;&#062; I AND arrAntal(J) = 2 Then<BR> If J &#062; I And I &#062;= 2 Then<BR> KakPts = I*3 + J*2<BR> Response.Write KakPts & "<BR>"<BR> Response.Write I & "<BR>"<BR> Response.Write J & "<BR>"<BR> End If<BR> End If <BR> Next <BR> End If <BR> Next

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•