Ok, for some reason I just can't get this!!
I am programming a dice game that we play with our neighbors. And I'm having some real problems with a scoring function because I can't get the numbers to work with each other and divide the way I need them too!
So I have created a function that checks to see if there is more than 3 of a kind.
Can somebody please help me figure out this division??
Thanks!
Leslie
landrews@metrocourt.state.nm.us
SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
I am programming a dice game that we play with our neighbors. And I'm having some real problems with a scoring function because I can't get the numbers to work with each other and divide the way I need them too!
So I have created a function that checks to see if there is more than 3 of a kind.
Code:
function CheckKind(ARoll : array of integer; Dcounter : integer): integer;
var
pipsArray : array [1..6] of integer;
i, multiplier, base : integer;
begin
//reset all values to zero
for i := 1 to 6 do
pipsArray[i] := 0;
//ARoll is an array that contains 6 random values 1 - 6
//Dcounter is the number of dice rolled
for i := 0 to Dcounter - 1 do
begin
//I check the value of each slot in the ARoll array
//if the die value in ARoll[1] is 1 then pipsArray[1]
//increments; if the value in ARoll[2] is also 1 then
//pipsArray[1] increments to 2
Case ARoll[i] of
1 : inc(pipsArray[1]);
2 : inc(pipsArray[2]);
3 : inc(pipsArray[3]);
4 : inc(pipsArray[4]);
5 : inc(pipsArray[5]);
6 : inc(pipsArray[6]);
end;
end;
for i := 1 to 6 do
begin
//so now pipsArray has counts of the dice thrown
(1, 4, 4, 4, 6, 3)
//I only need to score if there are more than 3 of a kind
if pipsArray[i] >= 3 then
begin
base := 0;
//1's get a special score
if i = 1 then
multiplier := 1000
else
multiplier := 100;
//so in my array I have three 4's so I would get 400 points
//if I had four 4's i would get 600 (Take the DICE value
//(4) divide by 2 add to Dice Value (2 + 4) * 100.
//If I had three 3's I would get 300 points, four 3's would
//be 450 points (((3/2) + 3) * 100) = (1.5 + 3) * 100 = 450
if pipsArray[i] = 3 then
frmRollingBase.PendingScore := frmRollingBase.PendingScore + (i * multiplier)
else begin
//here is where the major trouble is!! This always rounds
//down to zero, so none of the over 3 scores are calculated
//correctly
base := (((pipsArray[i] - 3) div 2) + i);
frmRollingBase.PendingScore := frmRollingBase.PendingScore + (base * multiplier);
end;
end;
end;
Result := frmRollingBase.PendingScore;
end;
Thanks!
Leslie
landrews@metrocourt.state.nm.us
SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned