AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Kartenspiel Algorithmus

Ein Thema von Ömmel · begonnen am 3. Feb 2004 · letzter Beitrag vom 5. Feb 2004
 
Benutzerbild von d3g
d3g

Registriert seit: 21. Jun 2002
602 Beiträge
 
#17

Re: Kartenspiel Algorithmus

  Alt 3. Feb 2004, 19:16
Zitat von the_master:
Zitat von Nico1:
Eine Frage noch(bin nur so interresiert weil ich auch grad das brauche) aber warum kommt bei mir bis auf eine Herzausnahme NUR KARO?
Du musst im OnCreate der Form noch Randomize hinschreiben.
Er hat doch nicht etwa für jeden Funktionsaufruf das Programm neugestartet?

Ich hab übrigens noch einen Fehler gefunden... Mit 0 zu zählen zu beginnen ist ja doch besser. Jetzt tötet mich, ihr Pascal-Only-Jedis!

Delphi-Quellcode:
function PickCards(): String;
var
  Picked, i: Integer;
  Cards: set of 1..54;
  s: String;
begin
  Cards := [];
  for i := 1 to 10 do begin
    Picked := Random(54) + 1;
    if (not (Picked in Cards)) then
      Cards := Cards + [Picked];
  end;

  Result := '';
  for i := 1 to 54
    if (i in Cards) then begin
      case ((i - 1) div 13) of
        0: Result := 'Kreuz ';
        1: Result := 'Pik ';
        2: Result := 'Herz ';
        3: Result := 'Karo ';
      end;
      case ((i - 1) mod 13) of
        1: Result := Result + 'As';
        2..10: Result := Result + IntToStr(i mod 13);
        11: Result := Result + 'Bube';
        12: Result := Result + 'Dame';
        0: Result := Result + 'König';
      end;
    end;
end;
-- Crucifixion?
-- Yes.
-- Good. Out of the door, line on the left, one cross each.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:23 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz