1,105,625 Community Members

Yahtzee type game

Member Avatar
Fireprufe15
Junior Poster in Training
52 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm programming a Yahtzee type game, but I have a problem checking for the different scoring types. So far I have everything but Full House, Small Straight and Large straight. It works like this: There are 5 variables (the dice) that are randomized to something between 1 and 6 every roll. I need to figure out a way to check if 1) Two of the variables are the same and three of the variables are also the same but a different number (Full House). Then I need to check if there are 4 variables in sequence (1,2,3,4 for example)(small Straight). Finally I need to check if all 5 are in sequence (large straight). How would I do this? Each of those have their own procedure, I just need to know what to put in there because after struggling a bit I can't seem to figure it out.
Thanks for any help.

Member Avatar
Fireprufe15
Junior Poster in Training
52 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

For the straight, I got this code, but it doesn't work. Can somebody tell me what's wrong?

var
counter, min, look, K : integer;
temp, iSequence : integer;

  for counter:=1 to Top do begin
    min:=counter;
    for look:=counter+1 to top do
      if aDiceScores[look]<aDiceScores[min] then min:=look;
    temp:= aDiceScores[min];
    aDiceScores[min]:=aDiceScores[counter];
    aDiceScores[counter]:=temp;
  end;

 iSequence := 0;
 for K := 1 to 5 do
    if aDiceScores[K] + 1 = aDiceScores[K + 1]
    then inc(iSequence);


  if iSequence = 5 then
  iScoreLarge := 40;
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article