Skip to content

Commit 4d597ed

Browse files
committed
update animation
1 parent 1dc2866 commit 4d597ed

File tree

4 files changed

+23
-170
lines changed

4 files changed

+23
-170
lines changed

src/year2019/day13/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Advent of Code Cabinet 🎮
22

3-
[![asciicast](https://asciinema.org/a/bBZnFo6tAzRxECjVLY7OQmPOz.svg)](https://asciinema.org/a/bBZnFo6tAzRxECjVLY7OQmPOz)
3+
![Arkanoid](arkanoid.gif)
4+
5+
<!--
6+
asciinema rec arkanoid.cast --overwrite -f asciicast-v2 --command "python3 day13.py -v --limit 4000"
7+
agg --speed 0.8 --cols 42 --rows 30 --theme monokai --line-height 1.3 arkanoid.cast arkanoid.gif
8+
rm arkanoid.cast
9+
-->

src/year2019/day13/arkanoid.gif

305 KB
Loading

src/year2019/day13/day13.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def __init__(self, program):
3636

3737
self.flag_auto = True
3838
self.flag_show = False
39+
self.score_limit = 0
3940

4041
self.colorize = str.maketrans(
4142
{
42-
"W": "\033[93m" "█" "\033[0m",
43-
"x": "\033[92m" "☁︎" "\033[0m",
44-
"o": "\033[91m" "✿" "\033[0m",
45-
"=": "\033[96m" "▄" "\033[0m",
43+
"W": "\033[93m\033[0m",
44+
"x": "\033[92mx\033[0m", # "x": "\033[92m☁︎\033[0m",
45+
"o": "\033[91mo\033[0m", # "o": "\033[91m✿\033[0m",
46+
"=": "\033[96m\033[0m",
4647
}
4748
)
4849

@@ -101,6 +102,10 @@ def play(self):
101102
self.show()
102103
time.sleep(0.01)
103104

105+
# to limit the screencast
106+
if self.score_limit and self.score >= self.score_limit:
107+
return
108+
104109
self.computer.input.append(self.joystick())
105110

106111
def joystick(self):
@@ -122,9 +127,9 @@ def joystick(self):
122127

123128

124129
def main():
125-
126130
parser = argparse.ArgumentParser()
127131
parser.add_argument("-v", "--verbose", action="store_true")
132+
parser.add_argument("--limit", type=int)
128133
parser.add_argument("--elapsed", action="store_true")
129134
parser.add_argument("-p", "--play", action="store_true", help="play the game")
130135
parser.add_argument("input", nargs="?", default="input.txt")
@@ -140,12 +145,16 @@ def main():
140145

141146
if args.verbose:
142147
game.flag_show = True
148+
game.score_limit = args.limit
143149
if args.play:
144150
game.flag_show = True
145151
game.flag_auto = False
146152

147-
print(game.part1())
148-
print(game.part2())
153+
try:
154+
print(game.part1())
155+
print(game.part2())
156+
except KeyboardInterrupt:
157+
pass
149158

150159

151160
if __name__ == "__main__":

0 commit comments

Comments
 (0)