Skip to content

Commit 6d0ddce

Browse files
committed
shortening some lines
1 parent 7b71f5b commit 6d0ddce

File tree

6 files changed

+118
-114
lines changed

6 files changed

+118
-114
lines changed

Chip8/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# limitations under the License.
1616
import sys
1717
from argparse import ArgumentParser
18-
from Chip8.vm import VM, SCREEN_WIDTH, SCREEN_HEIGHT, TIMER_DELAY, FRAME_TIME_EXPECTED, ALLOWED_KEYS
18+
from Chip8.vm import VM, SCREEN_WIDTH, SCREEN_HEIGHT
19+
from Chip8.vm import TIMER_DELAY, FRAME_TIME_EXPECTED, ALLOWED_KEYS
1920
import pygame
2021
from timeit import default_timer as timer
2122
import os

Chip8/vm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
WHITE = 0xFFFFFFFF
2828
BLACK = 0
2929
TIMER_DELAY = 1/60 # in seconds... about 60 hz
30-
FRAME_TIME_EXPECTED = 1/500 # for limiting VM speed
30+
FRAME_TIME_EXPECTED = 1/500 # for limiting VM speed
3131
ALLOWED_KEYS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
3232
"a", "b", "c", "d", "e", "f"]
3333

@@ -102,7 +102,7 @@ def play_sound(self) -> bool:
102102

103103
# Draw a sprite at *x*, *y* using data at *i* and with a height of *height*
104104
def draw_sprite(self, x: int, y: int, height: int):
105-
flipped_black = False # were any pixels where this was drawn flipped from white to black?
105+
flipped_black = False # did drawing this flip any pixels from white to black?
106106
for row in range(0, height):
107107
row_bits = self.ram[self.i + row]
108108
for col in range(0, SPRITE_WIDTH):
@@ -116,7 +116,7 @@ def draw_sprite(self, x: int, y: int, height: int):
116116
flipped_black = True
117117
new_pixel = new_bit ^ old_bit # Chip 8 draws by XORing, which flips everything
118118
self.display_buffer[px, py] = WHITE if new_pixel else BLACK
119-
self.v[0xF] = 1 if flipped_black else 0 # set flipped flag in register for collision detection
119+
self.v[0xF] = 1 if flipped_black else 0 # set flipped flag for collision detection
120120

121121
def step(self):
122122
# we look at the opcode in terms of its nibbles (4 bit pieces)

KNN/fish.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class Fish(DataPoint):
3030

3131
@classmethod
3232
def from_string_data(cls, data: list[str]) -> Self:
33-
return cls(kind=data[0], weight=float(data[1]), length1=float(data[2]), length2=float(data[3]),
34-
length3=float(data[4]), height=float(data[5]), width=float(data[6]))
33+
return cls(kind=data[0], weight=float(data[1]), length1=float(data[2]),
34+
length2=float(data[3]), length3=float(data[4]),
35+
height=float(data[5]), width=float(data[6]))
3536

3637
def distance(self, other: Self) -> float:
3738
return ((self.length1 - other.length1) ** 2 + (self.length2 - other.length2) ** 2 +

0 commit comments

Comments
 (0)