Jul-07-2018, 04:01 AM
I used to enjoy writing games using BASIC way back in the day. I tried searching the forums but did not find an answer. Wondering if Python has a program command that will both clear the shell of text and home the cursor so that the next desired text will start displaying from the upper left corner?
Right now I am just tinkering with some text based game ideas. I came up with this simple card handling routine. Eventually I want to branch out into a text adventure idea. (I wrote a text adventure type game on my old computer back in the 80's in BASIC).
My card handling scheme so far is listed below. (But wondering about the clear IDLE and homing cursor for a prettier display.)
Right now I am just tinkering with some text based game ideas. I came up with this simple card handling routine. Eventually I want to branch out into a text adventure idea. (I wrote a text adventure type game on my old computer back in the 80's in BASIC).
My card handling scheme so far is listed below. (But wondering about the clear IDLE and homing cursor for a prettier display.)
from random import * # best results rifling should be <= 1/2 number of list elements cards=[] suitname=['Clubs','Diamonds','Spades','Hearts'] facename=[2,3,4,5,6,7,8,9,10,'J','Q','K','A'] for fill in range(0,52): cards.append(fill) print(" Unshuffled: ",cards,"\n") for rifling in range(1,4): shuffle(cards) print("After",rifling,"shuffles: ",cards) pick=randint(0,52) suit=pick//13 face=pick%13 print("You pulled the",facename[face],"of",suitname[suit])