Menu

playing cards

2021-05-06
2021-08-04
  • James Gilchrist

    James Gilchrist - 2021-05-06

    how do you make a deck of cards so cards wont repeat themselves

     
    • Marc 'BlackJack' Rintsch

      Two nested loops over suits and values will do the trick:

      10 DIM C$(51),S$(3):S$(0)="diamonds":S$(1)="hearts":S$(2)="clubs":S$(3)="spades"
      20 FOR I=0 TO 3:FOR J=0 TO 12:READ V$:C$(I*12+J)=V$+" of "+S$(I):NEXT:RESTORE:NEXT
      30 FOR I=0 TO 51:PRINT C$(I),:NEXT
      100 DATA 2,3,4,5,6,7,8,9,10,Jack,Queen,King,Ace
      

      c$() now contains all the cards.

       
  • Theruler76

    Theruler76 - 2021-08-04

    just my two cents, to properly display all the aces you have to count to 13 in DATA:
    READ V$:C$(I*13+J)

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.