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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
diff --git a/client/tilepainter.py b/client/tilepainter.py
--- a/client/tilepainter.py
+++ b/client/tilepainter.py
@@ -89,7 +89,7 @@ class TilePainter:
img = self.tile_images[name]
w = img.get_width()
h = img.get_height()
- screen.blit(pygame.transform.smoothscale(img, (w/4, h/4)), position)
+ screen.blit(pygame.transform.smoothscale(img, (w//4, h//4)), position)
def draw_tile_list(self, screen, position, tile_names, space = 0):
for i, tile_name in enumerate(tile_names):
diff --git a/server/botengine.py b/server/botengine.py
index 03623f9..b128135 100644
--- a/server/botengine.py
+++ b/server/botengine.py
@@ -71,7 +71,7 @@ class BotEngine():
def get_tiles(self, blocking = False):
if self._is_next_line() or blocking:
- return map(Tile, (self._read_line().strip().split()))
+ return [*map(Tile, (self._read_line().strip().split()))]
else:
return None
diff --git a/server/eval.py b/server/eval.py
index 042ee54..dc7e463 100644
--- a/server/eval.py
+++ b/server/eval.py
@@ -19,6 +19,7 @@ from tile import Pon, Chi
from tile import red_dragon, white_dragon, green_dragon, dragons
from tile import bamboos, chars, pins, all_tiles, honors
from copy import copy
+import functools
def is_hand_open(sets):
for set in sets:
@@ -97,14 +97,14 @@
if wintype == "Ron":
if player_wind.name == "WE":
- return (name, round_to_base(score / 2 * 3, 100))
+ return (name, round_to_base(score // 2 * 3, 100))
else:
return (name, score)
else:
if player_wind.name == "WE":
- return (name, (round_to_base(score / 2, 100), 0))
+ return (name, (round_to_base(score // 2, 100), 0))
else:
- return (name, (round_to_base(score / 4, 100), round_to_base(score / 2, 100)))
+ return (name, (round_to_base(score // 4, 100), round_to_base(score // 2, 100)))
def quick_pons_and_kans(hand):
d = {}
@@ -274,7 +275,7 @@ def eval_sets(pair, sets, round_wind, player_wind, last_tile, wintype):
# Other hands
for name, fn in score_functions:
score = fn(pair, sets)
- if score > 0:
+ if score:
result.append((name, score))
# Pinfu
@@ -304,7 +305,7 @@ def eval_sets(pair, sets, round_wind, player_wind, last_tile, wintype):
def sum_over_sets(sets, fn):
- return reduce(lambda a, s: fn(s) + a, sets, 0)
+ return functools.reduce(lambda a, s: fn(s) + a, sets, 0)
def for_all_tiles_in_sets(sets, fn):
return for_all_sets(sets, lambda s: s.all_tiles(fn))
|