-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactionqueue.py
More file actions
44 lines (31 loc) · 871 Bytes
/
actionqueue.py
File metadata and controls
44 lines (31 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
""" A chronologically ordered set of actions that a Being 'plans' to perform.
"""
from action import *
class ActionQueue:
""" ActionQueue( ) -> ActionQueue
An ordered queue of actions.
Attributes:
actions: A List of actions, in order.
"""
def __init__(self):
self.actions = []
def enqueue_action(self, action):
"""aq.enqueue_action( Action ) -> None
Puts this action at the bottom (lowest index) of the queue.
"""
self.actions.insert(0, action)
def dequeue_action(self):
""" aq.dequeue_action( ) -> Action
Pops the action at the top (highest index) of the queue.
"""
return self.actions.pop()
def clear(self):
""" aq.clear( ) -> None
Removes all actions from the queue.
"""
self.actions = []
def empty(self):
""" aq.empty( ) -> bool
Checks whether the queue contains any actions.
"""
return len(self.actions) == 0