seigot / tetris

A Tetris Game for programming education in Japanese
MIT License
30 stars 107 forks source link

UnicodeDecodeError: 'cp932' codec can't decode byte 0x87 in position 47: illegal multibyte sequence #71

Closed seigot closed 1 year ago

seigot commented 1 year ago

https://github.com/seigot https://github.com/seigot/tetris/commit/886badcae40958fec9f223347c5641b8f9dcb7f1

PS C:\Users\staka\Desktop\work\tetris> python.exe .\start.py -m predict_sample -l2 -t5 --predict_weight .\weight\DQN\sample_weight.pt
game_level: 2
game_time: 5
RANDOM_SEED: -1
IS_MODE :predict_sample
OBSTACLE_HEIGHT: 0
OBSTACLE_PROBABILITY: 0
USER_NAME: window_sample
SHAPE_LIST_MAX: 6
BLOCK_NUM_MAX: 180
RESULT_LOG_JSON: result.json
TRAIN_YAML: config/default.yaml
PREDICT_WEIGHT: .\weight\DQN\sample_weight.pt
Python 3.10.9
CompletedProcess(args='python --version', returncode=0, stderr='')
Traceback (most recent call last):
  File "C:\Users\staka\Desktop\work\tetris\game_manager\game_manager.py", line 267, in timerEvent
    self.nextMove = BLOCK_CONTROLLER_TRAIN.GetNextMove(nextMove, GameStatus,yaml_file=self.train_yaml,weight=self.predict_weight)
  File "C:\Users\staka\Desktop\work\tetris\game_manager\machine_learning\block_controller_train_sample.py", line 499, in GetNextMove
    self.set_parameter(yaml_file=yaml_file,predict_weight=weight)
  File "C:\Users\staka\Desktop\work\tetris\game_manager\machine_learning\block_controller_train_sample.py", line 62, in set_parameter
    cfg = self.yaml_read(yaml_file)
  File "C:\Users\staka\Desktop\work\tetris\game_manager\machine_learning\block_controller_train_sample.py", line 40, in yaml_read
    cfg = yaml.safe_load(f)
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\__init__.py", line 79, in load
    loader = Loader(stream)
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\loader.py", line 34, in __init__
    Reader.__init__(self, stream)
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\reader.py", line 85, in __init__
    self.determine_encoding()
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\reader.py", line 124, in determine_encoding
    self.update_raw()
  File "C:\Users\staka\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\yaml\reader.py", line 178, in update_raw
    data = self.stream.read(size)
UnicodeDecodeError: 'cp932' codec can't decode byte 0x87 in position 47: illegal multibyte sequence
error: subprocess failed.
PS C:\Users\staka\Desktop\work\tetris>
seigot commented 1 year ago
diff --git a/game_manager/machine_learning/block_controller_train_sample.py b/game_manager/machine_learning/block_controller_train_sample.py
index a1cceff..00b428c 100644
--- a/game_manager/machine_learning/block_controller_train_sample.py
+++ b/game_manager/machine_learning/block_controller_train_sample.py
@@ -36,7 +36,7 @@ class Block_Controller(object):

     #パラメータ読み込み
     def yaml_read(self,yaml_file):
-        with open(yaml_file) as f:
+        with open(yaml_file, encoding='utf-8') as f:
             cfg = yaml.safe_load(f)
         return cfg

diff --git a/game_manager/machine_learning/block_controller_train_sample2.py b/game_manager/machine_learning/block_controller_train_sample2.py
index d10f8ee..c91e330 100644
--- a/game_manager/machine_learning/block_controller_train_sample2.py
+++ b/game_manager/machine_learning/block_controller_train_sample2.py
@@ -36,7 +36,7 @@ class Block_Controller(object):

     #パラメータ読み込み
     def yaml_read(self,yaml_file):
-        with open(yaml_file) as f:
+        with open(yaml_file, encoding='utf-8') as f:
             cfg = yaml.safe_load(f)
         return cfg