Skip to content

ブロック数,ブロック種類数,スプライト数,CTスコアを取得するための変更#3

Open
momoka-h wants to merge 43 commits intohyphen-o:mainfrom
momoka-h:branch1
Open

ブロック数,ブロック種類数,スプライト数,CTスコアを取得するための変更#3
momoka-h wants to merge 43 commits intohyphen-o:mainfrom
momoka-h:branch1

Conversation

@momoka-h
Copy link

No description provided.

Copy link
Owner

@hyphen-o hyphen-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

何個かコメントした!
ちゃんとプロジェクトの形に合わせてReadme変更してくれたり,prjmanにコメント追加してくれたりしてくれてるのは見やすくてめちゃくちゃありがたい!
Scratchのデータ構造理解するの難しいと思うけど,コメント内容踏まえて修正頑張ってほしい!


# ブロック数を取得
project_manager = ProjectManager(sample_id)
blocks_length = project_manager.get_blocks_length()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全部のブロックを取得するのはget_all_blocks_length()の方で取れるよ〜

project_manager = ProjectManager(sample_id)
blocks_length = project_manager.get_blocks_length()
# ブロックを取得
blockType = project_manager.get_blocks()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

現状get_blocksは動かないからコメントアウトした方がいいのと,__blocksはブロックの種類を格納してるわけじゃ無いから新しくブロックの種類数をカウントするような実装が必要になりそう

blocks_length = project_manager.get_blocks_length()
# ブロックを取得
blockType = project_manager.get_blocks()
# スプライト数を取得 "isStage"の数がスプライト数?1つはステージなので-1する
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうやね,isStageの数がスプライトの数を表してる(厳密にはisStageを格納してる配列の数を数えてあげればいいだけ)のはあってる!
ただ,下にも書いてあるけど,現状の実装ではそれが実現できてなさそうやから答えになっちゃうけどself.__spritesの配列の長さをとってあげれば実現できると思う

# スプライト数を取得 "isStage"の数がスプライト数?1つはステージなので-1する
sprits_length = project_manager.get_sprites_length()
# CTスコア合計点数を取得
mastery = drscratch_analyzer.Mastery(sample_id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drscratch_analyzerは分析先のprocess関数にファイル(作品のJSONファイル)のパスを渡して実行,analyze関数に出力先のJSONファイルのパスを渡して実行すると分析結果がファイルとして出力されるようになってるから,コンストラクタにIDを渡す必要はなくて,下記の実装にすると実行できると思う(パスは適宜変えてほしい)

mastery = Mastery()
mastery.process("../271001536.json")
mastery.analyze("./out.json")

self.__ID = id
self.__project = scratch_client.get_project(self.__ID)
self.__head_blocks = self.__project["targets"][1]["blocks"]
self.__start_splites = self.__project["targets"][0]["isStage"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは先頭のスプライトがステージかどうかのbooleanしか格納できてないと思う!

@momoka-h
Copy link
Author

Scratch3.0以降の作品を入力してください.
'target'
Traceback (most recent call last):
File "/works/app/sample/sample.py", line 18, in
blocks_length = project_manager.get_all_blocks_length()
AttributeError: 'ProjectManager' object has no attribute 'get_all_blocks_length'. Did you mean: 'get_blocks_length'?

このエラーの対処法わかりますでしょうか...
作品はID:797975999でやってます

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants