Sinisterly
Steam game picker - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: Steam game picker (/Thread-Steam-game-picker)



Steam game picker - Inori - 08-30-2015

Whenever I get really bored, I end up just staring at my Steam library not knowing what the hell to do. I fixed that problem with this little program.
What it does is go through your local Steam files for your installed games and chooses 3 at random.

Source:
Code:
from random import randint as r from os import walk as f games = next(f('C:\Program Files (x86)\Steam\steamapps\common'))[1] disp = [games[r(0,len(games))]] def find_game(): for i in range(0,3): c = games[r(0,len(games))] disp.append(c) games.pop(games.index(c)) print "\t" + str(i+1) + ".",c.replace("_", " ") print "Selected games: " find_game()

Only bug: I occasionally get an IndexError, not totally sure why.

Anyway, enjoy your steam games Biggrin


RE: Steam game picker - White Demon - 09-01-2015

Hehe, thanks! I get bored a lot. Probably won't do much work because I have 7 or so games but anyway lmao.


RE: Steam game picker - Adorapuff - 09-01-2015

(08-30-2015, 06:45 AM)Chitoge Wrote: Whenever I get really bored, I end up just staring at my Steam library not knowing what the hell to do. I fixed that problem with this little program.
What it does is go through your local Steam files for your installed games and chooses 3 at random.

Source:
Code:
from random import randint as r from os import walk as f games = next(f('C:\Program Files (x86)\Steam\steamapps\common'))[1] disp = [games[r(0,len(games))]] def find_game(): for i in range(0,3): c = games[r(0,len(games))] disp.append(c) games.pop(games.index(c)) print "\t" + str(i+1) + ".",c.replace("_", " ") print "Selected games: " find_game()

Only bug: I occasionally get an IndexError, not totally sure why.

Anyway, enjoy your steam games Biggrin

On what line do you get an IndexError?


RE: Steam game picker - Inori - 09-01-2015

(09-01-2015, 05:11 PM)Adorapuff Wrote: On what line do you get an IndexError?

Code:
Traceback (most recent call last): File "steamPick.py", line 15 in <module> find_game() File "steamPick.py", line 9 in find_game c = games[r(0,len(games))] IndexError: list index out of range

I guess it's on 9, when it's picking a game. I've tried using try/except to catch it, but it doesn't seem to work.


RE: Steam game picker - Shebang - 09-03-2015

(09-01-2015, 05:26 PM)Chitoge Wrote:
Code:
Traceback (most recent call last): File "steamPick.py", line 15 in <module> find_game() File "steamPick.py", line 9 in find_game c = games[r(0,len(games))] IndexError: list index out of range

I guess it's on 9, when it's picking a game. I've tried using try/except to catch it, but it doesn't seem to work.

That's because randint uses the specified values inclusively Smile So len(games) should be len(games)-1.


RE: Steam game picker - Inori - 09-03-2015

(09-03-2015, 02:39 PM)Shebang Wrote: That's because randint uses the specified values inclusively Smile So len(games) should be len(games)-1.

ooooh. That makes more sense. Thanks Biggrin