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
Antwort Antwort
Benutzerbild von d3g
d3g

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

Re: Kartenspiel Algorithmus

  Alt 3. Feb 2004, 18:24
Zitat von Jelly:
Bedenke aber noch bei dem Code keine Karten doppelt zu ziehen, sonst hast du plötzlich 5 Asse
Und dazu nimmst du am besten Sets, das beste an Pascal überhaupt.

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 := Randomize(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 div 13) of
        0: Result := 'Kreuz ';
        1: Result := 'Pik ';
        2: Result := 'Herz ';
        3: Result := 'Karo ';
      end;
      case (i 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;
[edit]Zum Sortieren kannst du das Sortier-Tutorial hier aus dem Forum zu Rate ziehen.[/edit]
-- Crucifixion?
-- Yes.
-- Good. Out of the door, line on the left, one cross each.
  Mit Zitat antworten Zitat
Antwort Antwort


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 01:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz