     function Computer_player(Var New_Cup: Dice):boolean;

         Type Type_of_score = (straight,three_pairs,
                                        three_of_a_kind,second_three,
                                                               aces,fives);
              Scores = record
                            Points:         real;
                            Dice_used:      array[1..6] of boolean;
                         end;


         Var Talley:              array[1..6] of integer;
             Number:              array[1..6] of integer;
             Dice_that_score:     array[1..6] of boolean;
             Potential_score:     array[straight..fives] of Scores;
             Kind:                Type_of_score;
             Cup:                 Dice;
             All_used:            boolean;
             Num_of_scores:       integer;
             Count:               integer;
             I,J,K:               integer;
             Pulled_score:        real;

         procedure Display_diagnostics(Special_case:real);

              Var I:     integer;
                  kind:  Type_of_score;

              begin
              window(36,2,78,24);
              clrscr;
              writeln(Special_case:6:0);
              writeln;
              write('Cup[I].Saved: ');
              for I:= 1 to 6 do
                   if Cup[I].Saved
                        then
                           write(I:1,', ');
              writeln;
              writeln;
              write('Talley: ');
              for I:= 1 to 6 do
                   write(I:1,'= ',Talley[I]:1,', ');
              writeln;
              writeln;
              write('Number: ');
              for I:= 1 to 6 do
                   write(I:1,'=',Number[I]:1,', ');
              writeln;
              writeln;
              for kind:= straight to fives do
                   begin
                   case kind of
                        straight: write('Straight:    ');
                     three_pairs: write('3 Pairs:     ');
                 three_of_a_kind: write('3 of a kind: ');
                    second_three: write('Second 3:    ');
                            aces: write('Aces:        ');
                           fives: write('Fives:       ');
                        end;
                   with Potential_score[kind] do
                        begin
                        write(Points:5:0,'  ');
                        for I:= 1 to 6 do
                             if Dice_used[I]
                                  then
                                     write(I:1,', ');
                        writeln;
                        end;
                   end;
              write('Dice_that_score: ');
              for I:= 1 to 6 do
                   if Dice_that_score[I]
                        then
                           write(I:1,', ');
              writeln;
              writeln('Count:  ',Count:1);
              writeln('Number of Scoring Dice = ',Num_of_scores:1);
              writeln;
              write('Cup[I].Marked:  ');
              for I:= 1 to 6 do
                   if Cup[I].Marked
                        then
                           write(I:1,', ');
              writeln;
              writeln;
              write('Cup[I].Pulled:  ');
              for I:= 1 to 6 do
                   if Cup[I].Pulled
                        then
                           write(I:1,', ');
              writeln;
              repeat until keypressed;
              window(2,2,34,24);
              end;

         Procedure Take_them;

              Var I:    integer;

              begin
              for I:= 1 to 6 do
                   if (not Cup[I].Saved) and Dice_that_score[I]
                        then
                           Cup[I].Pulled:= True;
              end;


         Procedure Take_aces(How_many: integer);

              Var I:              integer;
                  Pulled_dice:    integer;

              begin
              Pulled_dice:= 0;
              for I:= 1 to 6 do
                   if (Cup[I].Value = 1) and (How_many > 0) and
                         (not Cup[I].Saved) and (not Cup[I].Pulled)
                        then
                           begin
                           Pulled_dice:= Pulled_dice + 1;
                           How_many:= How_many - 1;
                           Cup[I].Pulled:= True;
                           Cup[I].Marked:= True;
                           end;
              Pulled_score:= Pulled_score + 100 * Pulled_dice;
              end;

         Procedure Take_fives(How_many: integer);

              Var I:              integer;
                  Pulled_dice:    integer;

              begin
              Pulled_dice:= 0;
              for I:= 1 to 6 do
                   if (Cup[I].Value = 5) and (How_many > 0) and
                         (not Cup[I].Saved) and (not Cup[I].Pulled)
                        then
                           begin
                           Pulled_dice:= Pulled_dice + 1;
                           How_many:= How_many - 1;
                           Cup[I].Pulled:= True;
                           Cup[I].Marked:= True;
                           end;
              Pulled_score:= Pulled_score + 50 * Pulled_dice;
              end;

         Function Comp1: boolean;


              begin
              Pulled_score:= 0.0;
              if Points_available < Needed
                   then
                      begin
                      if Potential_score[three_of_a_kind].Points >= 300.0
                           then
                              begin
                              Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                              for I:= 1 to 6 do
                                   Cup[I].Pulled:=
                                        Potential_score
                                             [three_of_a_kind].Dice_used[I];
                              end
                           else
                              if (Potential_score[aces].Points < 100.0) and
                                 (Potential_score[fives].Points < 50.0) and
                                 (Potential_score[three_of_a_kind].Points > 0)
                                   then
                                      begin
                                      Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                                      for I:= 1 to 6 do
                                           Cup[I].Pulled:=
                                                Potential_score
                                                [three_of_a_kind].Dice_used[I];
                                      end
                                   else
                                      if Potential_score[aces].Points >= 100.0
                                           then
                                              Take_aces(1)
                                           else
                                              Take_fives(1);
                      if Num_of_scores = Count
                           then
                              begin
                              Take_them;
                              Comp1:= False;
                              end;
                      Comp1:= False;
                      if (Pulled_score + Points_available >= Needed) and
                         (not Score[Current_player].On_board) and not
                         (Num_of_scores = Count)
                           then
                              begin
                              Take_them;
                              Comp1:= True;
                              end;
                      Count:= 6;
                      for I:= 1 to 6 do
                           if (Cup[I].Saved) or (Cup[I].Pulled)
                                then
                                   Count:= Count - 1;
                      if (Pulled_score + Points_available >= Needed) and
                         (Score[Current_player].On_board) and (Count <= 2)
                         and not (Count = 0)
                           then
                              begin
                              Take_them;
                              Comp1:= True;
                              end;
                      end;

              if (Points_available >= Needed) and
                             (not Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp1:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                               3,4,5: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;

                        end;
              if (Points_available >= Needed) and
                             (Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp1:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp1:= false;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp1:= false;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                 4,5: begin
                                      Take_them;
                                      Comp1:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp1:= False;
                                      end;
                                end;

                        end;
              end;

         function Comp2(Var Cup: Dice): boolean;

              Var Closest:        real;
                  Now_available:  real;

              begin
              Pulled_score:= 0.0;
              if Points_available < Needed
                   then
                      begin
                      if Potential_score[three_of_a_kind].Points >= 300.0
                           then
                              begin
                              Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                              for I:= 1 to 6 do
                                   Cup[I].Pulled:=
                                        Potential_score
                                             [three_of_a_kind].Dice_used[I];
                              end
                           else
                              if (Potential_score[aces].Points < 100.0) and
                                 (Potential_score[fives].Points < 50.0) and
                                 (Potential_score[three_of_a_kind].Points > 0)
                                   then
                                      begin
                                      Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                                      for I:= 1 to 6 do
                                           Cup[I].Pulled:=
                                                Potential_score
                                                [three_of_a_kind].Dice_used[I];
                                      end
                                   else
                                      if Potential_score[aces].Points >= 100.0
                                           then
                                              Take_aces(1)
                                           else
                                              Take_fives(1);
                      if Num_of_scores = Count
                           then
                              begin
                              Take_them;
                              Comp2:= False;
                              end;
                      Comp2:= False;
                      if Problems then Display_diagnostics(Pulled_score);
                      if (Pulled_score + Points_available >= Needed) and
                         (not Score[Current_player].On_board) and not
                         (Num_of_scores = Count)
                           then
                              begin
                              Take_them;
                              Comp2:= True;
                              end;
                      Count:= 6;
                      for I:= 1 to 6 do
                           if (Cup[I].Saved) or (Cup[I].Pulled)
                                then
                                   Count:= Count - 1;
                      if (Pulled_score + Points_available >= Needed) and
                         (Score[Current_player].On_board) and (Count <= 2)
                         and not (Count = 0)
                           then
                              begin
                              Take_them;
                              Comp2:= True;
                              end;
                      end;

              if (Points_available >= Needed) and
                             (not Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp2:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                               3,4,5: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;

                        end;
              if (Points_available >= Needed) and
                             (Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp2:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp2:= false;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp2:= false;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                 4,5: begin
                                      Take_them;
                                      Comp2:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                end;

                        end;
              Now_available:= Pulled_score + Points_available +
                                  Score[Current_player].Points;
              if (Now_available > 5000.0) and
                 (Now_available - Score[Current_player].Points > Needed)
                   then
                      begin
                      Closest:= 0.0;
                      for I:= 1 to Number_of_players do
                           if I <> Current_player
                                then
                                   if Score[I].Points > Closest
                                        then
                                           Closest:= Closest + Score[I].Points;
                      if abs(Now_available - Closest) < 750
                           then
                              begin
                              Count:= 0;
                              for I:= 1 to 6 do
                                   begin
                                   Cup[I].Marked:= False;
                                   Cup[I].Pulled:= False;
                                   if not Cup[I].Saved
                                        then
                                           Count:= Count + 1;
                                   end;
                              case Count of
                                   1: begin
                                      Take_them;
                                      Comp2:= False;
                                      end;
                                   2: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                           2: begin
                                              Take_them;
                                              Comp2:= False;
                                              end;
                                        end;
                                   3: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                           2: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                           3: begin
                                              Take_them;
                                              Comp2:= False;
                                              end;
                                        end;
                                   4: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                         2,3: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                           4: begin
                                              Take_them;
                                              Comp2:= False;
                                              end;
                                        end;
                                   5: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp2:= false;
                                              end;
                                           2: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                         3,4: begin
                                              Take_them;
                                              Comp2:= True;
                                              end;
                                           5: begin
                                              Take_them;
                                              Comp2:= False;
                                              end;
                                        end;
                                   6: case Num_of_scores of
                                           1: begin
                                           Take_them;
                                           Comp2:= false;
                                           end;
                                        2: begin
                                           Take_them;
                                           Comp2:= True;
                                           end;
                                    3,4,5: begin
                                           Take_them;
                                           Comp2:= True;
                                           end;
                                        6: begin
                                           Take_them;
                                           Comp2:= False;
                                           end;
                                        end;
                                 end;
                              end;
                      end;
              end;

         function Comp3(Var Cup: Dice): boolean;

              Var Closest:        real;
                  Now_available:  real;

              begin
              Pulled_score:= 0.0;
              if Points_available < Needed
                   then
                      begin
                      if Potential_score[three_of_a_kind].Points >= 300.0
                           then
                              begin
                              Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                              for I:= 1 to 6 do
                                   Cup[I].Pulled:=
                                        Potential_score
                                             [three_of_a_kind].Dice_used[I];
                              end
                           else
                              if (Potential_score[aces].Points < 100.0) and
                                 (Potential_score[fives].Points < 50.0) and
                                 (Potential_score[three_of_a_kind].Points > 0)
                                   then
                                      begin
                                      Pulled_score:= Pulled_score +
                                       Potential_score[three_of_a_kind].Points;
                                      for I:= 1 to 6 do
                                           Cup[I].Pulled:=
                                                Potential_score
                                                [three_of_a_kind].Dice_used[I];
                                      end
                                   else
                                      if Potential_score[aces].Points >= 100.0
                                           then
                                              Take_aces(1)
                                           else
                                              Take_fives(1);
                      if Num_of_scores = Count
                           then
                              begin
                              Take_them;
                              Comp3:= False;
                              end;
                      Comp3:= False;
                      if Problems then Display_diagnostics(Pulled_score);
                      if (Pulled_score + Points_available >= Needed) and
                         (not Score[Current_player].On_board) and not
                         (Num_of_scores = Count)
                           then
                              begin
                              Take_them;
                              Comp3:= True;
                              end;
                      Count:= 6;
                      for I:= 1 to 6 do
                           if (Cup[I].Saved) or (Cup[I].Pulled)
                                then
                                   Count:= Count - 1;
                      if (Pulled_score + Points_available >= Needed) and
                         (Score[Current_player].On_board) and (Count <= 2)
                         and not (Count = 0)
                           then
                              begin
                              Take_them;
                              Comp3:= True;
                              end;
                      end;

              if (Points_available >= Needed) and
                             (not Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp3:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                               3,4,5: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;

                        end;
              if (Points_available >= Needed) and
                             (Score[Current_player].On_board)
                   then
                      case Count of
                           1: begin
                              Take_them;
                              Comp3:= False;
                              end;
                           2: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           3: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   3: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           4: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   4: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           5: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= false;
                                      end;
                                   2: begin
                                      Take_them;
                                      Comp3:= false;
                                      end;
                                 3,4: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   5: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;
                           6: case Num_of_scores of
                                   1: begin
                                      Take_them;
                                      Comp3:= false;
                                      end;
                                 2,3: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                 4,5: begin
                                      Take_them;
                                      Comp3:= True;
                                      end;
                                   6: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                end;

                        end;
              Now_available:= Pulled_score + Points_available +
                                  Score[Current_player].Points;
              if ((Now_available > 5000.0) or (Score[0].Points >= 5000)) and
                 (Now_available - Score[Current_player].Points > Needed)
                   then
                      begin
                      Closest:= 0.0;
                      for I:= 1 to Number_of_players do
                           if I <> Current_player
                                then
                                   if Score[I].Points > Closest
                                        then
                                           Closest:= Score[I].Points;
                      if (abs(Now_available - Closest) < 750) or
                         ((Now_available < Score[0].Points) and
                                          (Score[0].Points >= 5000))
                           then
                              begin
                              Count:= 0;
                              for I:= 1 to 6 do
                                   begin
                                   Cup[I].Marked:= False;
                                   Cup[I].Pulled:= False;
                                   if not Cup[I].Saved
                                        then
                                           Count:= Count + 1;
                                   end;
                              case Count of
                                   1: begin
                                      Take_them;
                                      Comp3:= False;
                                      end;
                                   2: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp3:= True;
                                              end;
                                           2: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                        end;
                                   3: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                           2: begin
                                              Take_them;
                                              Comp3:= True;
                                              end;
                                           3: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                        end;
                                   4: case Num_of_scores of
                                         1,2: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                           3: begin
                                              Take_them;
                                              Comp3:= True;
                                              end;
                                           4: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                        end;
                                   5: case Num_of_scores of
                                           1: begin
                                              Take_them;
                                              Comp3:= false;
                                              end;
                                         3,2: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                           4: begin
                                              Take_them;
                                              Comp3:= True;
                                              end;
                                           5: begin
                                              Take_them;
                                              Comp3:= False;
                                              end;
                                        end;
                                   6: case Num_of_scores of
                                        1: begin
                                           Take_them;
                                           Comp3:= false;
                                           end;
                                    3,4,2: begin
                                           Take_them;
                                           Comp3:= False;
                                           end;
                                        5: begin
                                           Take_them;
                                           Comp3:= True;
                                           end;
                                        6: begin
                                           Take_them;
                                           Comp3:= False;
                                           end;
                                        end;
                                 end;
                              end;
                      end;
              end;


         begin
         Count:= 0;
         Num_of_scores:= 0;
         for I:= 1 to 6 do
              Dice_that_score[I]:= False;
         All_used:= True;
         Cup:= New_Cup;
         fillchar(Talley,Sizeof(Talley),0);
         fillchar(Number,sizeof(Number),0);
         for Kind:= straight to fives do
              with Potential_score[Kind] do
                   begin
                   Points:= 0.0;
                   for I:= 1 to 6 do
                        Dice_used[I]:= False;
                   end;
         for I:= 1 to 6 do
              begin
              if not Cup[I].saved
                   then
                      begin
                      Count:= Count + 1;
                      Talley[Cup[I].Value]:= Talley[Cup[I].Value] + 1;
                      Cup[I].Marked:= False;
                      Cup[I].Pulled:= False;
                      end;
              Dice_that_score[I]:= False;
              end;
         if Count >0
              then
                 begin
                 fillchar(Number,sizeof(Number),0);
                 for I:= 1 to 6 do
                      Case Talley[I] of
                           1: Number[1]:= Number[1] + 1;
                           2: Number[2]:= Number[2] + 1;
                           3: Number[3]:= Number[3] + 1;
                           4: Number[3]:= Number[3] + 1;
                           5: Number[3]:= Number[3] + 1;
                           6: Number[3]:= Number[3] + 2;
                        end;
                 if Number[1] = 6
                      then
                         with Potential_score[straight] do
                              begin
                              Points:= 1500;
                              for I:= 1 to 6 do
                                   begin
                                   Dice_used[I]:= True;
                                   Cup[I].Marked:= True;
                                   end;
                              end;
                 if Number[2] = 3
                      then
                         with Potential_score[three_pairs] do
                              begin
                              Points:= 500;
                              for I:= 1 to 6 do
                                   begin
                                   Dice_used[I]:= True;
                                   Cup[I].Marked:= True;
                                   end;
                              end;
                 if Number[3] > 0
                      then
                         with Potential_score[three_of_a_kind] do
                              begin
                              Number[3]:= Number[3] - 1;
                              I:= 1;
                              while (Talley[I] <3) do
                                   I:= I + 1;
                              Count:= 0;
                              for J:= 1 to 6 do
                                   if (Cup[J].Value = I) and
                                                 (not Cup[J].Saved) and
                                                      (Count < 3)
                                        then
                                           begin
                                           Dice_used[J]:= True;
                                           Cup[J].Marked:= True;
                                           Count:= Count + 1;
                                           end;
                              Points:= 100 * I;
                              if I = 1
                                   then
                                      Points:= 1000.0;
                              end;
                 if Number[3] = 1
                      then
                         with Potential_score[second_three] do
                              begin
                              Number[3]:= Number[3] - 1;
                              I:= 1;
                              while (Talley[I] <> 3) and (Talley[I] <> 6) do
                                   I:= I + 1;
                              Count:= 0;
                              for J:= 1 to 6 do
                                   if (Cup[J].Value = I) and
                                                 (not Cup[J].Marked) and
                                                      (Count < 3)
                                        then
                                           begin
                                           Dice_used[J]:= True;
                                           Cup[J].Marked:= True;
                                           Count:= Count + 1;
                                           end;
                              Points:= 100 * I;
                              if I = 1
                                   then
                                      Points:= 1000.0;
                              end;
                 for I:= 1 to 6 do
                      begin
                      if (Cup[I].Value = 1) {and (not Cup[I].Marked)} and
                                                (not Cup[I].Saved)
                           then
                              begin
                              Potential_score[aces].Points:=
                                   Potential_score[aces].Points + 100;
                              Potential_score[aces].Dice_used[I]:= True;
                              Cup[I].Marked:= True;
                              end;
                      if (Cup[I].Value = 5) {and (not Cup[I].Marked) }and
                                                (not Cup[I].Saved)
                           then
                              begin
                              Potential_score[fives].Points:=
                                   Potential_score[fives].Points + 50;
                              Potential_score[fives].Dice_used[I]:= True;
                              Cup[I].Marked:= True;
                              end;
                      end;
                 end;
         Count:= 0;
         for I:= 1 to 6 do
              begin
              All_used:= All_used and (Cup[I].Marked or Cup[I].Pulled);
              if not Cup[I].Saved
                   then
                      Count:= Count + 1;
              end;
         for Kind:= straight to fives do
              for I:= 1 to 6 do
                   Dice_that_score[I]:= Dice_that_score[I] or
                                       Potential_score[Kind].Dice_used[I];
         for I:= 1 to 6 do
              if Dice_that_score[I]
                   then
                      Num_of_scores:= Num_of_scores + 1;
         case Score[Current_player].Player_type of
              Comp_1: Computer_player:= Comp1;
              Comp_2: Computer_player:= Comp2(Cup);
              Comp_3: Computer_player:= Comp3(Cup);
           end;
         for I:= 1 to 6 do
              Cup[I].Marked:= False;
         New_Cup:= Cup;
         end;