Permalink
Browse files

Initial randomization foo

  • Loading branch information...
craigmaloney committed Mar 8, 2012
1 parent a3b7348 commit 73ef7fcf560da87d3d6e70405145a7ecd62e2033
Showing with 13 additions and 5 deletions.
  1. +10 −2 command_moment.py
  2. +3 −3 commands.json
View
@@ -1,11 +1,19 @@
import random
-
import json
class CommandList:
def __init__(self):
- self.commands = []
+ self.commands = {}
def load_commands(self):
file = open('./commands.json', 'r')
self.commands = json.load(file)
+
+ def active_commands(self):
+ all_true = [key for key, val in self.commands.iteritems() if val]
+ return all_true
+
+ def pick_command(self):
+ active = self.active_commands()
+ random.shuffle(active)
+ return active.pop()
View
@@ -1,5 +1,5 @@
{
- "ls":1,
- "mv":1,
- "cp":1
+ "ls":true,
+ "mv":true,
+ "cp":false
}

0 comments on commit 73ef7fc

Please sign in to comment.