larry avatar larry committed 9af1d59

Made Rosey sliiightly smarter: she doesn't play a hazard if you're stopped
(or a speed limit if you're slowed).

Comments (0)

Files changed (1)

 
 	On every turn she shuffles her cards.
 	Shen then tries each in order.
-	If she finds a card that is legally playable, she plays it.
+	If she finds a card that is legally playable, she plays it--
+		unless it's redundant (plays hazards only when stopped, plays
+		speed limit only if you don't already have one)
 	If she finds no legally playable cards, she discards a card at random.
 	(She will never discard a safety, because safeties are always legally playable.)
 	She extends if half the cards remain in the draw pile.
 		random.shuffle(cards)
 		for card in cards:
 			try:
-				playee = self.other() if isinstance(card, Hazard) else self
+				if not isinstance(card, Hazard):
+					playee = self
+				else:
+					playee = self.other()
+					if card is speed_limit:
+						if not playee.hand.autobahn():
+							continue
+					else:
+						if not playee.hand.rolling():
+							continue
 				self.hand.play(card, playee)
 				print("    du-uh, played", card, "on", "herself" if playee == self else "you")
 				if self.hand.won() and self.hand.mileage() == 700:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.