
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 '==Can be any number from 1 to 6==<BR>d2 = 0 '==Can be any number from 1 to 6==<BR>d3 = 0 '==Can be any number from 1 to 6==<BR>d4 = 0 '==Can be any number from 1 to 6==<BR>d5 = 0 '==Can be any number from 1 to 6==<BR>d6 = 0 '==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>'== 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 <> I Then<BR> Response.Write("Tower: " & All & "p")<BR> End If<BR> Next<BR>End If<BR>Next<BR><BR>'== 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

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'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>

I thought it looked
like homework too ; )<BR><BR>He also needs to understand that vbscript arrays are zerobased (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 'full house' example.

Minor point of disagreement...
> He also needs to understand that vbscript arrays are zerobased <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'm working with more naturally lends itself to thinking from 1 to N instead of from 0 to N1. Just ignore the zero slot. You're wasting a whole 16 bytes of memory by doing so. Whoopee.<BR><BR><BR>

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'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> '== 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>

Okay, you got the Yatzy right...
...sorry about that.<BR><BR>So your full house code is just a variation on that, isn'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 ' why do you keep using UBOUND? It's ALWAYS 6<BR> If arrAntal(I) >= 3 Then<BR> For J = I+1 To 6<BR> If arrAntal(J) >= 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>

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

STILL A DORK!
Sheesh! I can't a simple thing like this right! Aaarrrgghh.<BR><BR>ONE MORE TRY:<BR><BR>For I = 1 To 6 ' why do you keep using UBOUND? It's ALWAYS 6<BR> If arrAntal(I) >= 3 Then<BR> For J = [hl="yellow"]1[/hl] To 6<BR> If [hl="yellow"]J <> I AND[/hl] arrAntal(J) >= 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>

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) >= 3 Then <BR> For J = 1 To 6 <BR> If J <> I AND arrAntal(J) >= 2 Then<BR> If I > 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

Think I got it...
I have to use 2 loops to get it right:<BR><BR> '== Kåk =========================<BR> For I = 1 To 6<BR> If arrAntal(I) >= 3 Then <BR> For J = 1 To 6 <BR> If J <> I AND arrAntal(J) = 3 Then<BR> If J < I And I >= 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) >= 3 Then <BR> For J = 1 To 6 <BR> If J <> I AND arrAntal(J) = 2 Then<BR> If J > I And I >= 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

Forum Rules

