zjowowen commited on
Commit
525dd07
โ€ข
1 Parent(s): 04df190

Add DI-sheep

Browse files
This view is limited to 50 files because it contains too many changes. ย  See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. DI-sheep/LICENSE +202 -0
  3. DI-sheep/README.md +103 -0
  4. DI-sheep/service/agent_app.py +161 -0
  5. DI-sheep/service/app.py +142 -0
  6. DI-sheep/service/ckpt_best.pth.tar +3 -0
  7. DI-sheep/service/requirement-train.txt +1 -0
  8. DI-sheep/service/requirement.txt +8 -0
  9. DI-sheep/service/sheep_env.py +248 -0
  10. DI-sheep/service/sheep_model.py +126 -0
  11. DI-sheep/service/sheep_ppo_level9_main.py +123 -0
  12. DI-sheep/service/sheep_ppo_main.py +122 -0
  13. DI-sheep/service/test_sheep_env.py +23 -0
  14. DI-sheep/service/test_sheep_model.py +19 -0
  15. DI-sheep/ui/.commitlintrc.cjs +9 -0
  16. DI-sheep/ui/.editorconfig +15 -0
  17. DI-sheep/ui/.eslintignore +9 -0
  18. DI-sheep/ui/.eslintrc.cjs +28 -0
  19. DI-sheep/ui/.gitignore +24 -0
  20. DI-sheep/ui/.husky/commit-msg +4 -0
  21. DI-sheep/ui/.husky/pre-commit +4 -0
  22. DI-sheep/ui/.lintstagedrc.cjs +11 -0
  23. DI-sheep/ui/.prettierrc.cjs +12 -0
  24. DI-sheep/ui/.stylelintrc.cjs +12 -0
  25. DI-sheep/ui/.versionrc.cjs +5 -0
  26. DI-sheep/ui/LICENSE.md +674 -0
  27. DI-sheep/ui/README.md +3 -0
  28. DI-sheep/ui/index.html +31 -0
  29. DI-sheep/ui/package.json +41 -0
  30. DI-sheep/ui/preview.png +0 -0
  31. DI-sheep/ui/public/demo.gif +3 -0
  32. DI-sheep/ui/public/favicon.ico +0 -0
  33. DI-sheep/ui/public/github.svg +5 -0
  34. DI-sheep/ui/public/song_of_kedaya.mp3 +0 -0
  35. DI-sheep/ui/public/sound-disco.mp3 +3 -0
  36. DI-sheep/ui/qrcode.png +0 -0
  37. DI-sheep/ui/src/App.css +110 -0
  38. DI-sheep/ui/src/App.tsx +449 -0
  39. DI-sheep/ui/src/GithubIcon.tsx +28 -0
  40. DI-sheep/ui/src/index.css +78 -0
  41. DI-sheep/ui/src/main.tsx +10 -0
  42. DI-sheep/ui/src/themes/default/index.ts +40 -0
  43. DI-sheep/ui/src/themes/default/sounds/sound-button-click.mp3 +0 -0
  44. DI-sheep/ui/src/themes/default/sounds/sound-triple.mp3 +0 -0
  45. DI-sheep/ui/src/themes/di/images/+1.png +0 -0
  46. DI-sheep/ui/src/themes/di/images/emo.png +0 -0
  47. DI-sheep/ui/src/themes/di/images//345/206/262/351/270/255.png +0 -0
  48. DI-sheep/ui/src/themes/di/images//345/212/240/347/217/255.png +0 -0
  49. DI-sheep/ui/src/themes/di/images//345/234/250/347/272/277/346/221/270/351/261/274.png +0 -0
  50. DI-sheep/ui/src/themes/di/images//346/203/263/345/210/260/344/272/206.png +0 -0
.gitattributes CHANGED
@@ -32,3 +32,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ DI-sheep/service/ckpt_best.pth.tar filter=lfs diff=lfs merge=lfs -text
36
+ DI-sheep/ui/public/demo.gif filter=lfs diff=lfs merge=lfs -text
37
+ DI-sheep/ui/public/sound-disco.mp3 filter=lfs diff=lfs merge=lfs -text
DI-sheep/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2017 Google Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
DI-sheep/README.md ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DI-sheep๏ผšๆทฑๅบฆๅผบๅŒ–ๅญฆไน  + ็พŠไบ†ไธช็พŠ
2
+
3
+ ๅฝ“ AI ๆŠ€ๆœฏ็š„ๆ˜Ž็ โ€”โ€”ๆทฑๅบฆๅผบๅŒ–ๅญฆไน ๏ผŒ้‡ๅˆฐๅท็งฐโ€œ้€šๅ…ณ็Ž‡ๅชๆœ‰0.01%โ€็š„ๆธธๆˆโ€œ็พŠไบ†ไธช็พŠโ€๏ผŒไผš็ขฐๆ’žๅ‡บๅ“ชไบ›ๅฅ‡ๆ€ๅฆ™ๆƒณๅ‘ข๏ผŸ
4
+
5
+ P.S. ่ทฏ่ฟ‡่ฎฐๅพ—็‚นไธช star ![stars - di-sheep](https://img.shields.io/github/stars/opendilab/di-sheep?style=social) ๏ผŒๆŒ็ปญๆ›ดๆ–ฐingใ€‚
6
+
7
+ P.S.S. ๆƒณไบ†่งฃๆ›ดๅคšๆทฑๅบฆๅผบๅŒ–ๅญฆไน ็›ธๅ…ณ็Ÿฅ่ฏ†๏ผŸๅฟซๆฅ [DI-engine](https://github.com/opendilab/DI-engine) ่ฎญ็ปƒ่‡ชๅทฑ็š„ๆ™บ่ƒฝไฝ“ใ€‚
8
+
9
+ <div align="center">
10
+ <a href="https://github.com/opendilab/DI-sheep"><img width="500px" height="auto" src="https://github.com/opendilab/DI-sheep/blob/master/ui/public/demo.gif"></a>
11
+ </div>
12
+
13
+ # News
14
+ - [bilibili] [็พŠ็พคๅŠ ไธ่ฟ›ๅŽป๏ผŸ้‚ฃๅฐฑๆฅๅŠ ็Œซ็พคๅญ๏ผๆทฑๅบฆๅผบๅŒ–ๅญฆไน ็‰ˆ็š„็พŠไบ†ไธช็พŠๆฅไบ†](https://www.bilibili.com/video/BV1N24y1o7Lw/?spm_id_from=333.999.0.0)
15
+ - [WeChat] [ไธ‡ไบ‹ๅผ€ๅคด้šพ๏ผŸๅ–ตๅฐDI็Žฉโ€œ็พŠไบ†ไธช็พŠโ€ๅฏไธ้šพ](https://mp.weixin.qq.com/s/4Z3WtkcWRp6x4x60RVELfQ)
16
+
17
+ # ไฝฟ็”จๆŒ‡ๅ—
18
+
19
+ ## ็ฎ—ๆณ•ๅŽŸ็†่งฃๆž
20
+ ![disheep drawio](https://user-images.githubusercontent.com/33195032/191955286-7c309e9d-6e35-491f-93b3-b14cd1fe033f.png)
21
+
22
+ ## ๅฟซ้€ŸไธŠๆ‰‹
23
+
24
+ - ๅฆ‚ๆžœๆƒณ**ๅœจ็บฟ่ฏ•็Žฉ** --> [ๅœจ็บฟ็ฝ‘้กต๏ผˆๆ”น่ฟ›ไธญ๏ผ‰](https://opendilab.net/sheep)
25
+ - ๅฆ‚ๆžœๆƒณ**ๆœฌๅœฐ้ƒจ็ฝฒ/ๆต‹่ฏ•**
26
+ - ๆœๅŠก็ซฏ๏ผˆPython๏ผ‰
27
+ ```shell
28
+ # ้ข„ๅ…ˆๅฎ‰่ฃ…ๅฅฝ Python3
29
+ cd service
30
+ pip install -r requirement.txt
31
+ FLASK_APP=app.py flask run # ็Žฉๅฎถ่ฏ•็Žฉ
32
+ # FLASK_APP=agent_app.py flask run # ็Žฉๅฎถ + AI ่ฏ•็Žฉ
33
+ ```
34
+ - ๅฎขๆˆท็ซฏ๏ผˆreact๏ผ‰
35
+ ```shell
36
+ # ้ข„ๅ…ˆๅฎ‰่ฃ…ๅฅฝ node.js ๅ’Œ react
37
+ cd ui
38
+ npm run build
39
+ npm run preview
40
+ ```
41
+ ็„ถๅŽๅœจ็ฝ‘้กตไธญๆ‰“ๅผ€ๅฏนๅบ”้“พๆŽฅๅณๅฏ
42
+ - ๅฆ‚ๆžœๆƒณ่ฟ›่กŒๅฎŒๆ•ด็š„ๆทฑๅบฆๅผบๅŒ–ๅญฆไน ่ฎญ็ปƒ
43
+ ```shell
44
+ # ้ข„ๅ…ˆๅฎ‰่ฃ…ๅฅฝ Python3
45
+ cd service
46
+ pip install -r requirement-train.txt
47
+ python3 -u sheep_ppo_main.py
48
+ ```
49
+ - ๅฆ‚ๆžœๆƒณไฝฟ็”จๅฎšไน‰ๅฅฝ็š„ gym ็พŠไบ†ไธช็พŠ็Žฏๅขƒ --> ็‚นไธช star ไน‹ๅŽ็›ดๆŽฅๆšดๅŠ› CTRL C+V ๆ‹ฟ่ตฐ `service/sheep_env.py` ๅฐฝๆƒ…้ญ”ๆ”น
50
+ - ๅฆ‚ๆžœๆƒณ่Žทๅพ—่ฎญ็ปƒๅฅฝ็š„ๆทฑๅบฆๅผบๅŒ–ๅญฆไน ๆจกๅž‹ --> ่ฎฟ้—ฎ [OpenDILabๅฎ˜็ฝ‘ไธ‹่ฝฝ้“พๆŽฅ](https://opendilab.net/download/DI-sheep/) ๏ผˆ็›ฎๅ‰ๆไพ›ไบ†ไธค็ง่ฏ•็Žฉๆจกๅž‹๏ผŒไฝ†ๆ™บ่ƒฝไฝ“ไปๆœ‰ๅพˆๅคš่ฟ›ๆญฅ็ฉบ้—ด๏ผ‰
51
+ - ๅฆ‚ๆžœๆƒณไบ†่งฃๆ›ดๅคšๆทฑๅบฆๅผบๅŒ–ๅญฆไน ็›ธๅ…ณ็Ÿฅ่ฏ† --> ๆฌข่ฟŽๅ‚้˜… [DI-engine](https://github.com/opendilab/DI-engine) ๅ’Œ[็›ธๅ…ณๆ–‡ๆกฃ](https://di-engine-docs.readthedocs.io/zh_CN/latest/)
52
+ - ๅฆ‚ๆžœๆƒณไบ†่งฃๆœชๆฅ็š„ๆ›ดๆ–ฐ่ฎกๅˆ’ --> ่ฏทๅ‚้˜…[ๆ›ดๆ–ฐ่ฎกๅˆ’](#ๆ›ดๆ–ฐ่ฎกๅˆ’)
53
+ - ๅฆ‚ๆžœๆœ‰ๅ…ถไป–้—ฎ้ข˜ๆˆ–ๆƒณๆณ• --> ๆฌข่ฟŽ github ISSUE ๅŒบ่ฎจ่ฎบ๏ผŒๆˆ–ๆ˜ฏ่ดก็Œฎ Pull requests
54
+
55
+ ## ้กน็›ฎ็ป“ๆž„
56
+ ```text
57
+ .
58
+ โ”œโ”€โ”€ LICENSE
59
+ โ”œโ”€โ”€ ui --> react ็ฝ‘้กตๅ‰็ซฏ
60
+ โ””โ”€โ”€ service --> Python ๆ ธๅฟƒๆจกๅ—๏ผˆ็ฎ—ๆณ•ๅ’ŒๆœๅŠก็ซฏ๏ผ‰
61
+ โ”œโ”€โ”€ app.py --> flask ๆœๅŠก app (ไป…ไบบ็ฑปๆ“ไฝœ)
62
+ โ”œโ”€โ”€ agent_app.py --> flask ๆœๅŠก app๏ผˆไบบ็ฑป+AIๆ“ไฝœ๏ผ‰
63
+ โ”œโ”€โ”€ requirement.txt --> Python ไพ่ต–ๅบ“ๅˆ—่กจ
64
+ โ”œโ”€โ”€ sheep_env.py --> gym ๆ ผๅผ็Žฏๅขƒ
65
+ โ”œโ”€โ”€ sheep_model.py --> ๅŸบไบŽ PyTorch ็š„ Actor-Critic ็ฅž็ป็ฝ‘็ปœๆจกๅž‹
66
+ โ”œโ”€โ”€ sheep_ppo_main.py --> ๅŸบไบŽ DI-engine ็š„ๆทฑๅบฆๅผบๅŒ–ๅญฆไน ่ฎญ็ปƒไธปๅ‡ฝๆ•ฐ
67
+ โ”œโ”€โ”€ test_sheep_env.py --> gym ๆ ผๅผ็Žฏๅขƒ็š„ๅ•ๅ…ƒๆต‹่ฏ•
68
+ โ””โ”€โ”€ test_sheep_model.py --> ็ฅž็ป็ฝ‘็ปœๆจกๅž‹็š„ๅ•ๅ…ƒๆต‹่ฏ•
69
+ ```
70
+
71
+
72
+
73
+ # ๆ›ดๆ–ฐ่ฎกๅˆ’
74
+
75
+ ## ็ฎ—ๆณ•
76
+
77
+ - [ ] ๅผบๅŒ–ๅญฆไน ่ฎญ็ปƒๅ‚ๆ•ฐ่ฐƒๆ•ดๅ’Œ็ฎ—ๆณ•ๅพฎ่ฐƒ
78
+ - [ ] ๆไพ›ๅฏไพ›ๆœฌๅœฐ่ฏ•็Žฉ็š„ๆจกๅž‹ๆƒ้‡
79
+ - [ ] ่ฏฆ็ป†็š„็ฅž็ป็ฝ‘็ปœๅ’ŒๅผบๅŒ–ๅญฆไน ็ฎ—ๆณ•่ฎพ่ฎกๆ–‡ๆกฃ
80
+ - [ ] model-based RL ๅ’Œ planning ็ฎ—ๆณ•
81
+ - [ ] ็ฅž็ป็ฝ‘็ปœๅŽ‹็ผฉ๏ผˆ็”จไบŽ้ƒจ็ฝฒ๏ผ‰
82
+
83
+ ## ็Žฏๅขƒ
84
+ - [ ] ๆทปๅŠ ๅŽŸ็ฑปๅž‹ๆธธๆˆ๏ผˆๆฏ”ๅฆ‚3tiles๏ผ‰ไธญ็š„ๅ„็ง้“ๅ…ท
85
+ - [ ] ็‰Œ็š„ๅฑ‚ๆ•ฐ้—ฎ้ข˜ๅฆ‚ไฝ•ๅฎšไน‰
86
+ - [ ] ็ป“ๅˆ JAX ไผ˜ๅŒ–็Žฏๅขƒ่ฟ่กŒ้€Ÿๅบฆ
87
+ - [ ] ๆ›ดๅคš็ป“ๅˆ AI ็š„็Žฉๆณ•่ฎพ่ฎก
88
+
89
+
90
+ ## ๅบ”็”จ
91
+ - [x] ๆ›ดๅคš่‡ชๅฎšไน‰ไธป้ข˜ๅ’Œ BGM
92
+ - [x] ๅœจ็บฟ็ฝ‘้กต็ซฏ้ƒจ็ฝฒ
93
+ - [x] ๆ ทไพ‹็ฅž็ป็ฝ‘็ปœๆƒ้‡ไธ‹่ฝฝ
94
+ - [ ] ๆ›ดๅคš AI ่ฎญ็ปƒๆ—ถ็š„่กŒไธบๅˆ†ๆž
95
+ - [ ] ็งปๅŠจ็ซฏๅบ”็”จ๏ผˆๆฌข่ฟŽAndroid/IOSๅผ€ๅ‘่€…ๆ”ฏๆŒ๏ผ‰
96
+
97
+
98
+ # ่‡ด่ฐข
99
+ - react ๅ‰็ซฏ้ƒจๅˆ†ไธป่ฆๅ‚่€ƒ https://github.com/StreakingMan/solvable-sheep-game ๏ผŒ่ฏทๅคงๅฎถไนŸๅคšๅคšๆ”ฏๆŒ่ฟ™ไธช repo
100
+
101
+
102
+ # License
103
+ DI-sheep is released under the Apache 2.0 license.
DI-sheep/service/agent_app.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import numpy as np
3
+ import torch
4
+ from flask import Flask, request, jsonify, make_response
5
+ from flask_restplus import Api, Resource, fields
6
+ from threading import Thread
7
+ from sheep_env import SheepEnv
8
+ from sheep_model import SheepModel
9
+
10
+ flask_app = Flask(__name__)
11
+ app = Api(
12
+ app=flask_app,
13
+ version="0.0.1",
14
+ title="DI-sheep App",
15
+ description="Play Sheep with Deep Reinforcement Learning, Powered by OpenDILab"
16
+ )
17
+
18
+ name_space = app.namespace('DI-sheep', description='DI-sheep APIs')
19
+ model = app.model(
20
+ 'DI-sheep params', {
21
+ 'command': fields.String(required=False, description="Command Field", help="reset, step"),
22
+ 'argument': fields.Integer(required=False, description="Argument Field", help="reset->level, step->action"),
23
+ }
24
+ )
25
+ MAX_ENV_NUM = 50
26
+ ENV_TIMEOUT_SECOND = 60
27
+ envs = {}
28
+ model = SheepModel(item_obs_size=80, item_num=30, global_obs_size=19)
29
+ ckpt = torch.load('ckpt_best.pth.tar', map_location='cpu')['model']
30
+ ckpt = {'item_encoder.encoder' + k.split('item_encoder')[-1] if 'item_encoder' in k else k: v for k, v in ckpt.items()} # compatibility for v1 and v2 model
31
+ model.load_state_dict(ckpt)
32
+
33
+
34
+ def random_action(obs, env):
35
+ action_mask = obs['action_mask']
36
+ action = np.random.choice(len(action_mask), p=action_mask / action_mask.sum())
37
+ return action
38
+
39
+
40
+ def env_monitor():
41
+ while True:
42
+ cur_time = time.time()
43
+ pop_keys = []
44
+ for k, v in envs.items():
45
+ if cur_time - v['update_time'] >= ENV_TIMEOUT_SECOND:
46
+ pop_keys.append(k)
47
+ for k in pop_keys:
48
+ envs.pop(k)
49
+ time.sleep(1)
50
+
51
+
52
+ app.env_thread = Thread(target=env_monitor, daemon=True)
53
+ app.env_thread.start()
54
+
55
+
56
+ @name_space.route("/")
57
+ class MainClass(Resource):
58
+
59
+ def options(self):
60
+ response = make_response()
61
+ response.headers.add("Access-Control-Allow-Origin", "*")
62
+ response.headers.add('Access-Control-Allow-Headers', "*")
63
+ response.headers.add('Access-Control-Allow-Methods', "*")
64
+ return response
65
+
66
+ @app.expect(model)
67
+ def post(self):
68
+ try:
69
+ t_start = time.time()
70
+ data = request.json
71
+ cmd, arg, uid = data['command'], data['argument'], data['uid']
72
+ ip = request.remote_addr + uid
73
+
74
+ if ip not in envs:
75
+ if cmd == 'reset':
76
+ if len(envs) >= MAX_ENV_NUM:
77
+ response = jsonify(
78
+ {
79
+ "statusCode": 501,
80
+ "status": "No enough env resource, please wait a moment",
81
+ }
82
+ )
83
+ response.headers.add('Access-Control-Allow-Origin', '*')
84
+ return response
85
+ else:
86
+ env = SheepEnv(1, agent=True, max_padding=True)
87
+ env.seed(0)
88
+ envs[ip] = {'env': env, 'update_time': time.time()}
89
+ else:
90
+ response = jsonify(
91
+ {
92
+ "statusCode": 501,
93
+ "status": "No response for too long time, please reset the game",
94
+ }
95
+ )
96
+ response.headers.add('Access-Control-Allow-Origin', '*')
97
+ return response
98
+ else:
99
+ env = envs[ip]['env']
100
+ envs[ip]['update_time'] = time.time()
101
+
102
+ if cmd == 'reset':
103
+ obs = env.reset(arg)
104
+ action = model.compute_action(obs)
105
+ # action = random_action(obs, env)
106
+ scene = [item.to_json() for item in env.scene if item is not None]
107
+ response = jsonify(
108
+ {
109
+ "statusCode": 200,
110
+ "status": "Execution action",
111
+ "result": {
112
+ "scene": scene,
113
+ "max_item_num": env.total_item_num,
114
+ "action": action,
115
+ }
116
+ }
117
+ )
118
+ elif cmd == 'step':
119
+ obs, _, done, _ = env.step(arg)
120
+ action = model.compute_action(obs)
121
+ # action = random_action(obs, env)
122
+ scene = [item.to_json() for item in env.scene if item is not None]
123
+ bucket = [item.to_json() for item in env.bucket]
124
+ response = jsonify(
125
+ {
126
+ "statusCode": 200,
127
+ "status": "Execution action",
128
+ "result": {
129
+ "scene": scene,
130
+ "bucket": bucket,
131
+ "done": done,
132
+ "action": action,
133
+ }
134
+ }
135
+ )
136
+ else:
137
+ response = jsonify({
138
+ "statusCode": 500,
139
+ "status": "Invalid command: {}".format(cmd),
140
+ })
141
+ response.headers.add('Access-Control-Allow-Origin', '*')
142
+ return response
143
+ print('backend process time: {}'.format(time.time() - t_start))
144
+ print('current env number: {}'.format(len(envs)))
145
+ response.headers.add('Access-Control-Allow-Origin', '*')
146
+ return response
147
+ except Exception as e:
148
+ import traceback
149
+ print(repr(e))
150
+ print(traceback.format_exc())
151
+ response = jsonify({
152
+ "statusCode": 500,
153
+ "status": "Could not execute action",
154
+ })
155
+ response.headers.add('Access-Control-Allow-Origin', '*')
156
+ return response
157
+
158
+ if __name__ == "__main__":
159
+ flask_app.run(host='0.0.0.0')
160
+
161
+
DI-sheep/service/app.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from flask import Flask, request, jsonify, make_response
3
+ from flask_restplus import Api, Resource, fields
4
+ from threading import Thread
5
+ from sheep_env import SheepEnv
6
+
7
+ flask_app = Flask(__name__)
8
+ app = Api(
9
+ app=flask_app,
10
+ version="0.0.1",
11
+ title="DI-sheep App",
12
+ description="Play Sheep with Deep Reinforcement Learning, Powered by OpenDILab"
13
+ )
14
+
15
+ name_space = app.namespace('DI-sheep', description='DI-sheep APIs')
16
+ model = app.model(
17
+ 'DI-sheep params', {
18
+ 'command': fields.String(required=False, description="Command Field", help="reset, step"),
19
+ 'argument': fields.Integer(required=False, description="Argument Field", help="reset->level, step->action"),
20
+ }
21
+ )
22
+ MAX_ENV_NUM = 50
23
+ ENV_TIMEOUT_SECOND = 60
24
+ envs = {}
25
+
26
+
27
+ def env_monitor():
28
+ while True:
29
+ cur_time = time.time()
30
+ pop_keys = []
31
+ for k, v in envs.items():
32
+ if cur_time - v['update_time'] >= ENV_TIMEOUT_SECOND:
33
+ pop_keys.append(k)
34
+ for k in pop_keys:
35
+ envs.pop(k)
36
+ time.sleep(1)
37
+
38
+
39
+ app.env_thread = Thread(target=env_monitor, daemon=True)
40
+ app.env_thread.start()
41
+
42
+
43
+ @name_space.route("/")
44
+ class MainClass(Resource):
45
+
46
+ def options(self):
47
+ response = make_response()
48
+ response.headers.add("Access-Control-Allow-Origin", "*")
49
+ response.headers.add('Access-Control-Allow-Headers', "*")
50
+ response.headers.add('Access-Control-Allow-Methods', "*")
51
+ return response
52
+
53
+ @app.expect(model)
54
+ def post(self):
55
+ try:
56
+ t_start = time.time()
57
+ data = request.json
58
+ cmd, arg, uid = data['command'], data['argument'], data['uid']
59
+ ip = request.remote_addr
60
+ ip = str(ip) + str(uid)
61
+
62
+ if ip not in envs:
63
+ if cmd == 'reset':
64
+ if len(envs) >= MAX_ENV_NUM:
65
+ response = jsonify(
66
+ {
67
+ "statusCode": 501,
68
+ "status": "No enough env resource, please wait a moment",
69
+ }
70
+ )
71
+ response.headers.add('Access-Control-Allow-Origin', '*')
72
+ return response
73
+ else:
74
+ env = SheepEnv(1, agent=False)
75
+ envs[ip] = {'env': env, 'update_time': time.time()}
76
+ else:
77
+ response = jsonify(
78
+ {
79
+ "statusCode": 501,
80
+ "status": "No response for too long time, please reset the game",
81
+ }
82
+ )
83
+ response.headers.add('Access-Control-Allow-Origin', '*')
84
+ return response
85
+ else:
86
+ env = envs[ip]['env']
87
+ envs[ip]['update_time'] = time.time()
88
+ if cmd == 'reset':
89
+ env.reset(arg)
90
+ scene = [item.to_json() for item in env.scene if item is not None]
91
+ response = jsonify(
92
+ {
93
+ "statusCode": 200,
94
+ "status": "Execution action",
95
+ "result": {
96
+ "scene": scene,
97
+ "max_item_num": env.total_item_num,
98
+ }
99
+ }
100
+ )
101
+ elif cmd == 'step':
102
+ _, _, done, _ = env.step(arg)
103
+ scene = [item.to_json() for item in env.scene if item is not None]
104
+ bucket = [item.to_json() for item in env.bucket]
105
+ response = jsonify(
106
+ {
107
+ "statusCode": 200,
108
+ "status": "Execution action",
109
+ "result": {
110
+ "scene": scene,
111
+ "bucket": bucket,
112
+ "done": done,
113
+ }
114
+ }
115
+ )
116
+ else:
117
+ response = jsonify({
118
+ "statusCode": 500,
119
+ "status": "Invalid command: {}".format(cmd),
120
+ })
121
+ response.headers.add('Access-Control-Allow-Origin', '*')
122
+ return response
123
+ print('backend process time: {}'.format(time.time() - t_start))
124
+ print('current env number: {}'.format(len(envs)))
125
+ response.headers.add('Access-Control-Allow-Origin', '*')
126
+ return response
127
+ except Exception as e:
128
+ import traceback
129
+ print(repr(e))
130
+ print(traceback.format_exc())
131
+ response = jsonify({
132
+ "statusCode": 500,
133
+ "status": "Could not execute action",
134
+ })
135
+ response.headers.add('Access-Control-Allow-Origin', '*')
136
+ return response
137
+
138
+ if __name__ == "__main__":
139
+ flask_app.run(host='0.0.0.0')
140
+
141
+
142
+
DI-sheep/service/ckpt_best.pth.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fda262054a2d69e44b9a2189c82be0203f412f432a37a7e9ec9b93dd0416e18
3
+ size 3403809
DI-sheep/service/requirement-train.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ DI-engine>=0.4.5
DI-sheep/service/requirement.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ flask==1.1.2
2
+ flask-restplus==0.13.0
3
+ werkzeug==0.16.0
4
+ jinja2==3.0.3
5
+ markupsafe==2.0.1
6
+ itsdangerous==2.0.1
7
+ numpy
8
+ gym
DI-sheep/service/sheep_env.py ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Tuple, Optional, Dict
2
+ from collections import deque
3
+ import copy
4
+ import gym
5
+ import json
6
+ import uuid
7
+ import numpy as np
8
+
9
+
10
+ class Item:
11
+
12
+ def __init__(self, icon, offset, row, column):
13
+ self.icon = icon
14
+ self.offset = offset
15
+ self.row = row
16
+ self.column = column
17
+ self.uid = str(uuid.uuid4())
18
+ self.x = column * 100 + offset
19
+ self.y = row * 100 + offset
20
+ self.grid_x = self.x % 25
21
+ self.grid_y = self.y % 25
22
+ self.accessible = 1
23
+ self.visible = 1
24
+
25
+ def __repr__(self) -> str:
26
+ return 'icon({})'.format(self.icon)
27
+
28
+ def to_json(self):
29
+ return json.dumps(self, default=lambda o: o.__dict__ if hasattr(o, '__dict__') else int(o) if isinstance(o,np.int64) else "", sort_keys=True, indent=2)
30
+
31
+
32
+ class SheepEnv(gym.Env):
33
+ max_level = 10
34
+ R = 10
35
+ icons = [i for i in range(10)]
36
+ ranges = [
37
+ [2, 6],
38
+ [1, 6],
39
+ [1, 7],
40
+ [0, 7],
41
+ [0, 8],
42
+ ]
43
+
44
+ def __init__(self, level: int, bucket_length: int = 7, agent: bool = True, max_padding: bool = False) -> None:
45
+ self.level = level
46
+ assert 1 <= self.level <= self.max_level
47
+ self.bucket_length = bucket_length
48
+ self.agent = agent
49
+ self.max_padding = max_padding
50
+ self._make_game()
51
+
52
+ def seed(self, seed: int) -> None:
53
+ self._seed = seed
54
+ np.random.seed(self._seed)
55
+
56
+ def _make_game(self) -> None:
57
+ # TODO wash scene
58
+ self.icon_pool = self.icons[:2 * self.level]
59
+ self.offset_pool = [0, 25, 50, 75][:1 + self.level]
60
+ self.selected_range = self.ranges[min(4, self.level - 1)]
61
+ self.max_item_per_icon = 9
62
+ self.max_level_item_num = len(self.icons) * self.max_item_per_icon + 2
63
+ if self.level >= 10:
64
+ self.item_per_icon = 6 + (self.level - 5 + 1) // 2
65
+ # add non-divisible items
66
+ self.item_non_div = 2
67
+ else:
68
+ self.item_per_icon = 6
69
+ self.item_non_div = 0
70
+ self.total_item_num = len(self.icon_pool) * self.item_per_icon + self.item_non_div
71
+
72
+ self.scene = []
73
+ self.bucket = deque(maxlen=self.bucket_length)
74
+
75
+ N = self.selected_range[1] - self.selected_range[0] - 1
76
+ for i in range(len(self.icon_pool)):
77
+ for j in range(self.item_per_icon):
78
+ row = self.selected_range[0] + np.int64(N * np.random.random())
79
+ column = self.selected_range[0] + np.int64(N * np.random.random())
80
+ offset = self.offset_pool[np.int64(np.random.random() * len(self.offset_pool))]
81
+ item = Item(self.icon_pool[i], offset, row, column)
82
+ self.scene.append(item)
83
+ if self.item_non_div > 0:
84
+ for icon in np.random.choice(self.icon_pool, size=self.item_non_div, replace=False):
85
+ row = self.selected_range[0] + np.int64(N * np.random.random())
86
+ column = self.selected_range[0] + np.int64(N * np.random.random())
87
+ offset = self.offset_pool[np.int64(np.random.random() * len(self.offset_pool))]
88
+ item = Item(int(icon), offset, row, column)
89
+ self.scene.append(item)
90
+
91
+ self.cur_item_num = len(self.scene)
92
+ self.reward_3tiles = self.R * 0.5 / (len(self.scene) // 3)
93
+
94
+ self._update_visible_accessible()
95
+ self._set_space()
96
+
97
+ def _update_visible_accessible(self) -> None:
98
+ for i in range(self.total_item_num):
99
+ covered_items = []
100
+ item1 = self.scene[i]
101
+ if item1 is None:
102
+ continue
103
+ item1.accessible = 1
104
+ for j in range(i + 1, self.total_item_num):
105
+ item2 = self.scene[j]
106
+ if item2 is None:
107
+ continue
108
+ if not (item2.x + 100 <= item1.x or item2.x >= item1.x + 100 or item2.y + 100 <= item1.y
109
+ or item2.y >= item1.y + 100):
110
+ item1.accessible = 0
111
+ if not self.agent:
112
+ break
113
+ covered_items.append(item2)
114
+ if self.agent and len(covered_items) > 0:
115
+ flag = np.zeros((2, 2)).astype(np.int64) # core offset 50x50 is visible
116
+ core_x, core_y = item1.x + 25, item1.y + 25
117
+ for item in covered_items:
118
+ min_x = max(core_x, item.x)
119
+ max_x = min(core_x + 50, item.x + 100)
120
+ min_y = max(core_y, item.y)
121
+ max_y = min(core_y + 50, item.y + 100)
122
+ if min_x < max_x or min_y < max_y:
123
+ # top left: (max_x, max_y)
124
+ # bottom right: (min_x, min_y)
125
+ flag[(min_x - core_x) // 25:(max_x - core_x) // 25,
126
+ (min_y - core_y) // 25:(max_y - core_y) // 25] = 1
127
+ if flag.sum() == 4:
128
+ break
129
+ item1.visible = int(flag.sum() < 4)
130
+ else:
131
+ item1.visible = 1
132
+
133
+ def _execute_action(self, action: int) -> float:
134
+ action_item = copy.deepcopy(self.scene[action])
135
+ assert action_item is not None, action
136
+ self.scene[action] = None
137
+ self.cur_item_num -= 1
138
+ same_items = []
139
+ for i in range(len(self.bucket)):
140
+ item = self.bucket[i]
141
+ if item.icon == action_item.icon:
142
+ same_items.append(item)
143
+
144
+ if len(same_items) == 2:
145
+ for item in same_items:
146
+ self.bucket.remove(item)
147
+ return copy.deepcopy(self.reward_3tiles) # necessary deepcopy
148
+ else:
149
+ self.bucket.append(action_item)
150
+ return 0.
151
+
152
+ def reset(self, level: Optional[int] = None) -> Dict:
153
+ if level is not None:
154
+ self.level = level
155
+ assert 1 <= self.level <= self.max_level
156
+ self._make_game()
157
+ self._set_space()
158
+ return self._get_obs()
159
+
160
+ def close(self) -> None:
161
+ pass
162
+
163
+ # usually overwritten methods
164
+
165
+ def step(self, action: int) -> Tuple:
166
+ rew = self._execute_action(action)
167
+ self._update_visible_accessible()
168
+
169
+ obs = self._get_obs()
170
+ if self.cur_item_num == 0:
171
+ rew += self.R
172
+ done = True
173
+ elif len(self.bucket) == self.bucket_length:
174
+ rew -= self.R
175
+ done = True
176
+ else:
177
+ done = False
178
+ info = {}
179
+ return obs, rew, done, info
180
+
181
+ def _get_obs(self) -> Dict:
182
+ item_obs = np.zeros((self.total_item_num, self.item_size))
183
+ action_mask = np.zeros(self.total_item_num).astype(np.uint8)
184
+
185
+ L, N = self.L, self.N
186
+ p1, p2, p3 = L + N, L + N + N, L + N + N + 2
187
+ for i in range(len(self.scene)):
188
+ item = self.scene[i]
189
+ if item is None:
190
+ item_obs[i][L - 1] = 1
191
+ else:
192
+ item_obs[i][L + item.grid_x] = 1
193
+ item_obs[i][p1 + item.grid_y] = 1
194
+ item_obs[i][p3 + item.visible] = 1
195
+ if item.visible:
196
+ item_obs[i][item.icon] = 1
197
+ item_obs[i][p2 + item.accessible] = 1
198
+ else:
199
+ item_obs[i][L - 2] = 1
200
+ if item.accessible:
201
+ action_mask[i] = 1
202
+
203
+ bucket_obs = np.zeros(3 * len(self.icons))
204
+ bucket_icon_stat = [0 for _ in range(len(self.icons))]
205
+ for item in self.bucket:
206
+ bucket_icon_stat[item.icon] += 1
207
+ for i in range(len(bucket_icon_stat)):
208
+ bucket_obs[i * 3 + bucket_icon_stat[i]] = 1
209
+
210
+ global_obs = np.zeros(self.global_size)
211
+ if self.max_padding:
212
+ global_obs[self.cur_item_num // self.max_item_per_icon] = 1
213
+ else:
214
+ global_obs[self.cur_item_num // self.item_per_icon] = 1
215
+ global_obs[self.global_size - self.bucket_length - 1 + len(self.bucket)] = 1
216
+
217
+ return {
218
+ 'item_obs': item_obs,
219
+ 'bucket_obs': bucket_obs,
220
+ 'global_obs': global_obs,
221
+ 'action_mask': action_mask,
222
+ }
223
+
224
+ def _set_space(self) -> None:
225
+ if self.max_padding:
226
+ N = self.ranges[-1][1] - self.ranges[-1][0]
227
+ # icon + x + y + accessible + visible
228
+ L = len(self.icons) + 2 # +2 for not visible and move out
229
+ else:
230
+ N = self.selected_range[1] - self.selected_range[0]
231
+ # icon + x + y + accessible + visible
232
+ L = len(self.icon_pool) + 2 # +2 for not visible and move out
233
+ self.L, self.N = L, N
234
+ self.item_size = L + 4 * N * 2 + 2 + 2
235
+ if self.max_padding:
236
+ self.global_size = self.max_level_item_num // self.max_item_per_icon + 1 + self.bucket_length + 1
237
+ else:
238
+ self.global_size = self.total_item_num // self.item_per_icon + 1 + self.bucket_length + 1
239
+ self.observation_space = gym.spaces.Dict(
240
+ {
241
+ 'item_obs': gym.spaces.Box(0, 1, dtype=np.float32, shape=(self.total_item_num, self.item_size)),
242
+ 'bucket_obs': gym.spaces.Box(0, 1, dtype=np.float32, shape=(3 * len(self.icons), )),
243
+ 'global_obs': gym.spaces.Box(0, 1, dtype=np.float32, shape=(self.global_size, )),
244
+ 'action_mask': gym.spaces.Box(0, 1, dtype=np.float32, shape=(self.total_item_num, )) # TODO
245
+ }
246
+ )
247
+ self.action_space = gym.spaces.Discrete(self.total_item_num)
248
+ self.reward_space = gym.spaces.Box(-self.R * 1.5, self.R * 1.5, dtype=np.float32)
DI-sheep/service/sheep_model.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import treetensor.torch as ttorch
4
+ from ding.torch_utils import Transformer, MLP, unsqueeze, to_tensor
5
+
6
+
7
+ class ItemEncoder(nn.Module):
8
+ encoder_type = ['TF', 'MLP', 'two_stage_MLP']
9
+
10
+ def __init__(self, item_obs_size=60, item_num=30, item_encoder_type='TF', hidden_size=64, activation=nn.ReLU()):
11
+ super(ItemEncoder, self).__init__()
12
+ assert item_encoder_type in self.encoder_type, "not support item encoder type: {}/{}".format(item_encoder_type, self.encoder_type)
13
+ self.item_encoder_type = item_encoder_type
14
+ self.item_num = item_num
15
+ self.hidden_size = hidden_size
16
+
17
+ if self.item_encoder_type == 'TF':
18
+ self.encoder = Transformer(
19
+ item_obs_size,
20
+ hidden_dim=2 * hidden_size,
21
+ output_dim=hidden_size,
22
+ activation=activation
23
+ )
24
+ elif self.item_encoder_type == 'MLP':
25
+ self.encoder = MLP(
26
+ item_obs_size,
27
+ hidden_size,
28
+ hidden_size,
29
+ layer_num=3,
30
+ activation=activation
31
+ )
32
+ elif self.item_encoder_type == 'two_stage_MLP':
33
+ self.trans_len = 16
34
+ self.encoder_1 = MLP(
35
+ item_obs_size,
36
+ hidden_size,
37
+ self.trans_len,
38
+ layer_num=3,
39
+ activation=activation
40
+ )
41
+ self.encoder_2 = MLP(
42
+ self.trans_len*self.item_num,
43
+ hidden_size,
44
+ self.item_num*hidden_size,
45
+ layer_num=2,
46
+ activation=activation
47
+ )
48
+
49
+ def forward(self, item_obs):
50
+ if self.item_encoder_type == 'two_stage_MLP':
51
+ item_embedding_1 = self.encoder_1(item_obs) # (B, M, L)
52
+ item_embedding_2 = torch.reshape(item_embedding_1, [-1, self.trans_len*self.item_num])
53
+ item_embedding = self.encoder_2(item_embedding_2)
54
+ item_embedding = torch.reshape(item_embedding, [-1, self.item_num, self.hidden_size])
55
+ else:
56
+ item_embedding = self.encoder(item_obs)
57
+ return item_embedding
58
+
59
+
60
+ class SheepModel(nn.Module):
61
+ mode = ['compute_actor', 'compute_critic', 'compute_actor_critic']
62
+
63
+ def __init__(self, item_obs_size=60, item_num=30, item_encoder_type='TF', bucket_obs_size=30, global_obs_size=17, hidden_size=64, activation=nn.ReLU(), ttorch_return=False):
64
+ super(SheepModel, self).__init__()
65
+ self.item_encoder = ItemEncoder(item_obs_size, item_num, item_encoder_type, hidden_size, activation=activation)
66
+ self.bucket_encoder = MLP(bucket_obs_size, hidden_size, hidden_size, layer_num=3, activation=activation)
67
+ self.global_encoder = MLP(global_obs_size, hidden_size, hidden_size, layer_num=2, activation=activation)
68
+ self.value_head = nn.Sequential(
69
+ MLP(hidden_size, hidden_size, hidden_size, layer_num=2, activation=activation), nn.Linear(hidden_size, 1)
70
+ )
71
+ self.ttorch_return = ttorch_return
72
+
73
+ def compute_actor(self, x):
74
+ item_embedding = self.item_encoder(x['item_obs'])
75
+ bucket_embedding = self.bucket_encoder(x['bucket_obs'])
76
+ global_embedding = self.global_encoder(x['global_obs'])
77
+
78
+ key = item_embedding
79
+ query = bucket_embedding + global_embedding
80
+ query = query.unsqueeze(1)
81
+ logit = (key * query).sum(2)
82
+ logit.masked_fill_(~x['action_mask'].bool(), value=-1e9)
83
+ if self.ttorch_return:
84
+ return logit
85
+ else:
86
+ return {'logit': logit}
87
+
88
+ def compute_critic(self, x):
89
+ item_embedding = self.item_encoder(x['item_obs'])
90
+ bucket_embedding = self.bucket_encoder(x['bucket_obs'])
91
+ global_embedding = self.global_encoder(x['global_obs'])
92
+
93
+ embedding = item_embedding.mean(1) + bucket_embedding + global_embedding
94
+ value = self.value_head(embedding)
95
+ if self.ttorch_return:
96
+ return value.squeeze(1)
97
+ else:
98
+ return {'value': value.squeeze(1)}
99
+
100
+ def compute_actor_critic(self, x):
101
+ item_embedding = self.item_encoder(x['item_obs'])
102
+ bucket_embedding = self.bucket_encoder(x['bucket_obs'])
103
+ global_embedding = self.global_encoder(x['global_obs'])
104
+
105
+ key = item_embedding
106
+ query = bucket_embedding + global_embedding
107
+ query = query.unsqueeze(1)
108
+ logit = (key * query).sum(2)
109
+ logit.masked_fill_(~x['action_mask'].bool(), value=-1e9)
110
+
111
+ embedding = item_embedding.mean(1) + bucket_embedding + global_embedding
112
+ value = self.value_head(embedding)
113
+ if self.ttorch_return:
114
+ return ttorch.as_tensor({'logit': logit, 'value': value.squeeze(1)})
115
+ else:
116
+ return {'logit': logit, 'value': value.squeeze(1)}
117
+
118
+ def forward(self, x, mode):
119
+ assert mode in self.mode, "not support forward mode: {}/{}".format(mode, self.mode)
120
+ return getattr(self, mode)(x)
121
+
122
+ def compute_action(self, x):
123
+ x = unsqueeze(to_tensor(x))
124
+ with torch.no_grad():
125
+ logit = self.compute_actor(x)['logit']
126
+ return logit.argmax(dim=-1)[0].item()
DI-sheep/service/sheep_ppo_level9_main.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from easydict import EasyDict
3
+ from tensorboardX import SummaryWriter
4
+ from ding.config import compile_config
5
+ from ding.envs import create_env_manager, DingEnvWrapper, EvalEpisodeReturnEnv
6
+ from ding.policy import PPOPolicy
7
+ from ding.worker import BaseLearner, create_serial_collector, InteractionSerialEvaluator
8
+ from ding.utils import set_pkg_seed
9
+
10
+ from sheep_env import SheepEnv
11
+ from sheep_model import SheepModel
12
+
13
+ sheep_ppo_config = dict(
14
+ exp_name='level9/sheep_ppo_MLP_1M_seed0',
15
+ env=dict(
16
+ env_id='Sheep-v0',
17
+ level=10,
18
+ collector_env_num=8,
19
+ evaluator_env_num=10,
20
+ n_evaluator_episode=10,
21
+ # stop_value=15,
22
+ stop_value=1e6, # to run fixed env step
23
+ ),
24
+ policy=dict(
25
+ cuda=True,
26
+ recompute_adv=True,
27
+ action_space='discrete',
28
+ model=dict(),
29
+ learn=dict(
30
+ epoch_per_collect=10,
31
+ batch_size=320,
32
+ learning_rate=3e-4,
33
+ value_weight=0.5,
34
+ entropy_weight=0.001,
35
+ clip_ratio=0.2,
36
+ adv_norm=False,
37
+ value_norm=True,
38
+ ),
39
+ collect=dict(
40
+ n_sample=3200,
41
+ discount_factor=0.99,
42
+ gae_lambda=0.95,
43
+ ),
44
+ eval=dict(evaluator=dict(eval_freq=500, )),
45
+ ),
46
+ )
47
+ sheep_ppo_config = EasyDict(sheep_ppo_config)
48
+ main_config = sheep_ppo_config
49
+
50
+ sheep_ppo_create_config = dict(
51
+ env=dict(
52
+ type='mujoco',
53
+ import_names=['dizoo.mujoco.envs.mujoco_env'],
54
+ ),
55
+ env_manager=dict(type='subprocess'),
56
+ policy=dict(type='ppo', ),
57
+ )
58
+ sheep_ppo_create_config = EasyDict(sheep_ppo_create_config)
59
+ create_config = sheep_ppo_create_config
60
+
61
+
62
+ def sheep_env_fn(level):
63
+ return DingEnvWrapper(
64
+ SheepEnv(level), cfg={'env_wrapper': [
65
+ lambda env: EvalEpisodeReturnEnv(env),
66
+ ]}
67
+ )
68
+
69
+
70
+ def main(input_cfg, seed, max_env_step=int(1e6), max_train_iter=int(1e6)):
71
+ cfg, create_cfg = input_cfg
72
+ cfg = compile_config(cfg, seed=seed, auto=True, create_cfg=create_cfg)
73
+ collector_env = create_env_manager(
74
+ cfg.env.manager, [lambda: sheep_env_fn(cfg.env.level) for _ in range(cfg.env.collector_env_num)]
75
+ )
76
+ evaluator_env = create_env_manager(
77
+ cfg.env.manager, [lambda: sheep_env_fn(cfg.env.level) for _ in range(cfg.env.evaluator_env_num)]
78
+ )
79
+ collector_env.seed(cfg.seed, dynamic_seed=False)
80
+ evaluator_env.seed(cfg.seed, dynamic_seed=False)
81
+ set_pkg_seed(cfg.seed, use_cuda=cfg.policy.cuda)
82
+
83
+ obs_space = collector_env._env_ref.observation_space
84
+ model = SheepModel(
85
+ obs_space['item_obs'].shape[1],
86
+ obs_space['item_obs'].shape[0],
87
+ 'TF',
88
+ obs_space['bucket_obs'].shape[0],
89
+ obs_space['global_obs'].shape[0]
90
+ )
91
+ policy = PPOPolicy(cfg.policy, model=model, enable_field=['learn', 'collect', 'eval'])
92
+
93
+ tb_logger = SummaryWriter(os.path.join('./{}/log/'.format(cfg.exp_name), 'serial'))
94
+ learner = BaseLearner(cfg.policy.learn.learner, policy.learn_mode, tb_logger, exp_name=cfg.exp_name)
95
+ collector = create_serial_collector(
96
+ cfg.policy.collect.collector,
97
+ env=collector_env,
98
+ policy=policy.collect_mode,
99
+ tb_logger=tb_logger,
100
+ exp_name=cfg.exp_name
101
+ )
102
+ evaluator = InteractionSerialEvaluator(
103
+ cfg.policy.eval.evaluator, evaluator_env, policy.eval_mode, tb_logger, exp_name=cfg.exp_name
104
+ )
105
+
106
+ learner.call_hook('before_run')
107
+
108
+ while True:
109
+ if evaluator.should_eval(learner.train_iter):
110
+ stop, reward = evaluator.eval(learner.save_checkpoint, learner.train_iter, collector.envstep)
111
+ if stop:
112
+ break
113
+ new_data = collector.collect(train_iter=learner.train_iter)
114
+
115
+ learner.train(new_data, collector.envstep)
116
+ if collector.envstep >= max_env_step or learner.train_iter >= max_train_iter:
117
+ break
118
+
119
+ learner.call_hook('after_run')
120
+
121
+
122
+ if __name__ == "__main__":
123
+ main([main_config, create_config], seed=0)
DI-sheep/service/sheep_ppo_main.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from easydict import EasyDict
3
+ from tensorboardX import SummaryWriter
4
+ from ding.config import compile_config
5
+ from ding.envs import create_env_manager, DingEnvWrapper, EvalEpisodeReturnEnv
6
+ from ding.policy import PPOPolicy
7
+ from ding.worker import BaseLearner, create_serial_collector, InteractionSerialEvaluator
8
+ from ding.utils import set_pkg_seed
9
+
10
+ from sheep_env import SheepEnv
11
+ from sheep_model import SheepModel
12
+
13
+ sheep_ppo_config = dict(
14
+ exp_name='sheep_ppo_seed0',
15
+ env=dict(
16
+ env_id='Sheep-v0',
17
+ level=2,
18
+ collector_env_num=8,
19
+ evaluator_env_num=10,
20
+ n_evaluator_episode=10,
21
+ stop_value=15,
22
+ ),
23
+ policy=dict(
24
+ cuda=True,
25
+ recompute_adv=True,
26
+ action_space='discrete',
27
+ model=dict(),
28
+ learn=dict(
29
+ epoch_per_collect=10,
30
+ batch_size=320,
31
+ learning_rate=3e-4,
32
+ value_weight=0.5,
33
+ entropy_weight=0.001,
34
+ clip_ratio=0.2,
35
+ adv_norm=False,
36
+ value_norm=True,
37
+ ),
38
+ collect=dict(
39
+ n_sample=3200,
40
+ discount_factor=0.99,
41
+ gae_lambda=0.95,
42
+ ),
43
+ eval=dict(evaluator=dict(eval_freq=500, )),
44
+ ),
45
+ )
46
+ sheep_ppo_config = EasyDict(sheep_ppo_config)
47
+ main_config = sheep_ppo_config
48
+
49
+ sheep_ppo_create_config = dict(
50
+ env=dict(
51
+ type='mujoco',
52
+ import_names=['dizoo.mujoco.envs.mujoco_env'],
53
+ ),
54
+ env_manager=dict(type='subprocess'),
55
+ policy=dict(type='ppo', ),
56
+ )
57
+ sheep_ppo_create_config = EasyDict(sheep_ppo_create_config)
58
+ create_config = sheep_ppo_create_config
59
+
60
+
61
+ def sheep_env_fn(level):
62
+ return DingEnvWrapper(
63
+ SheepEnv(level), cfg={'env_wrapper': [
64
+ lambda env: EvalEpisodeReturnEnv(env),
65
+ ]}
66
+ )
67
+
68
+
69
+ def main(input_cfg, seed, max_env_step=int(1e7), max_train_iter=int(1e7)):
70
+ cfg, create_cfg = input_cfg
71
+ cfg = compile_config(cfg, seed=seed, auto=True, create_cfg=create_cfg)
72
+ collector_env = create_env_manager(
73
+ cfg.env.manager, [lambda: sheep_env_fn(cfg.env.level) for _ in range(cfg.env.collector_env_num)]
74
+ )
75
+ evaluator_env = create_env_manager(
76
+ cfg.env.manager, [lambda: sheep_env_fn(cfg.env.level) for _ in range(cfg.env.evaluator_env_num)]
77
+ )
78
+ collector_env.seed(cfg.seed, dynamic_seed=False)
79
+ evaluator_env.seed(cfg.seed, dynamic_seed=False)
80
+ set_pkg_seed(cfg.seed, use_cuda=cfg.policy.cuda)
81
+
82
+ obs_space = collector_env._env_ref.observation_space
83
+ model = SheepModel(
84
+ obs_space['item_obs'].shape[1],
85
+ obs_space['item_obs'].shape[0],
86
+ 'TF',
87
+ obs_space['bucket_obs'].shape[0],
88
+ obs_space['global_obs'].shape[0]
89
+ )
90
+ policy = PPOPolicy(cfg.policy, model=model, enable_field=['learn', 'collect', 'eval'])
91
+
92
+ tb_logger = SummaryWriter(os.path.join('./{}/log/'.format(cfg.exp_name), 'serial'))
93
+ learner = BaseLearner(cfg.policy.learn.learner, policy.learn_mode, tb_logger, exp_name=cfg.exp_name)
94
+ collector = create_serial_collector(
95
+ cfg.policy.collect.collector,
96
+ env=collector_env,
97
+ policy=policy.collect_mode,
98
+ tb_logger=tb_logger,
99
+ exp_name=cfg.exp_name
100
+ )
101
+ evaluator = InteractionSerialEvaluator(
102
+ cfg.policy.eval.evaluator, evaluator_env, policy.eval_mode, tb_logger, exp_name=cfg.exp_name
103
+ )
104
+
105
+ learner.call_hook('before_run')
106
+
107
+ while True:
108
+ if evaluator.should_eval(learner.train_iter):
109
+ stop, reward = evaluator.eval(learner.save_checkpoint, learner.train_iter, collector.envstep)
110
+ if stop:
111
+ break
112
+ new_data = collector.collect(train_iter=learner.train_iter)
113
+
114
+ learner.train(new_data, collector.envstep)
115
+ if collector.envstep >= max_env_step or learner.train_iter >= max_train_iter:
116
+ break
117
+
118
+ learner.call_hook('after_run')
119
+
120
+
121
+ if __name__ == "__main__":
122
+ main([main_config, create_config], seed=0)
DI-sheep/service/test_sheep_env.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ import numpy as np
3
+ from sheep_env import SheepEnv
4
+
5
+
6
+ @pytest.mark.unittest
7
+ def test_naive():
8
+ env = SheepEnv(level=9)
9
+ obs = env.reset()
10
+ print(env.observation_space)
11
+
12
+ while True:
13
+ action_mask = obs['action_mask']
14
+ action = np.random.choice(len(action_mask), p=action_mask / action_mask.sum())
15
+ obs, rew, done, info = env.step(action)
16
+ print(env.bucket, rew, done)
17
+ assert isinstance(obs, dict)
18
+ assert set(obs.keys()) == set(['item_obs', 'bucket_obs', 'global_obs', 'action_mask'])
19
+ assert np.isscalar(rew)
20
+ assert isinstance(done, bool)
21
+ assert isinstance(info, dict)
22
+ if done:
23
+ break
DI-sheep/service/test_sheep_model.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ import torch
3
+ from sheep_model import SheepModel
4
+
5
+
6
+ @pytest.mark.unittest
7
+ def test_naive():
8
+ B, M = 3, 30
9
+ model = SheepModel(item_num=30, item_encoder_type='two_stage_MLP')
10
+ data = {
11
+ 'item_obs': torch.randn(B, M, 60),
12
+ 'bucket_obs': torch.randn(B, 30),
13
+ 'global_obs': torch.randn(B, 17),
14
+ 'action_mask': torch.randint(0, 2, size=(M, )).bool()
15
+ }
16
+
17
+ output = model.forward(data, mode='compute_actor_critic')
18
+ assert output['logit'].shape == (B, M)
19
+ assert output['value'].shape == (B, )
DI-sheep/ui/.commitlintrc.cjs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * commitlint config
3
+ * @ref http://commitlint.js.org/
4
+ * @desc generated at 9/15/2022, 12:52:11 PM by [email protected]
5
+ */
6
+
7
+ module.exports = {
8
+ extends: ['@commitlint/config-conventional'],
9
+ };
DI-sheep/ui/.editorconfig ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://editorconfig.org/
2
+ # generated at 9/15/2022, 12:52:15 PM by [email protected]
3
+ # ่ฏฅ้…็ฝฎๆ–‡ไปถๆ˜ฏ็ป™webstormไฝฟ็”จ็š„
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 4
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+
14
+ [*.md]
15
+ trim_trailing_whitespace = false
DI-sheep/ui/.eslintignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # generated at 9/15/2022, 12:51:49 PM by [email protected]
2
+
3
+ node_modules
4
+ dist
5
+
6
+ !.eslintrc.js
7
+ !.prettierrc.js
8
+ !.commitlintrc.js
9
+ !.lintstagedrc.js
DI-sheep/ui/.eslintrc.cjs ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * eslint config
3
+ * @ref http://eslint.cn/
4
+ * @desc generated at 9/15/2022, 12:51:49 PM by [email protected]
5
+ */
6
+
7
+ module.exports = {
8
+ root: true,
9
+ parser: '@typescript-eslint/parser',
10
+ parserOptions: {
11
+ sourceType: 'module',
12
+ ecmaVersion: 11,
13
+ },
14
+ env: {
15
+ es6: true,
16
+ node: true,
17
+ },
18
+ plugins: ['eslint-plugin-prettier', '@typescript-eslint'],
19
+ extends: [
20
+ 'eslint:recommended',
21
+ 'plugin:react/recommended',
22
+ 'plugin:@typescript-eslint/recommended',
23
+ 'plugin:prettier/recommended',
24
+ ],
25
+ rules: {
26
+ 'prettier/prettier': 'error',
27
+ },
28
+ };
DI-sheep/ui/.gitignore ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ # dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
DI-sheep/ui/.husky/commit-msg ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit
DI-sheep/ui/.husky/pre-commit ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
DI-sheep/ui/.lintstagedrc.cjs ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * lint-staged config
3
+ * @ref https://www.npmjs.com/package/lint-staged
4
+ * @desc generated at 9/15/2022, 12:52:11 PM by [email protected]
5
+ */
6
+
7
+ module.exports = {
8
+ '!(dist/**/*)*.{[tj]s,[tj]sx,[cm]js}': ['eslint --fix'],
9
+ '!(dist/**/*)*.json': ['prettier --write'],
10
+ '!(dist/**/*)*.{css,scss}': ['stylelint --fix'],
11
+ };
DI-sheep/ui/.prettierrc.cjs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * prettier config
3
+ * @ref https://prettier.io/
4
+ * @desc generated at 9/15/2022, 12:51:48 PM by [email protected]
5
+ */
6
+
7
+ module.exports = {
8
+ tabWidth: 4,
9
+ singleQuote: true,
10
+ htmlWhitespaceSensitivity: 'css',
11
+ endOfLine: 'lf'
12
+ }
DI-sheep/ui/.stylelintrc.cjs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * stylelint config
3
+ * @ref https://stylelint.io/
4
+ * @desc generated at 9/15/2022, 12:51:58 PM by [email protected]
5
+ */
6
+
7
+ module.exports = {
8
+ extends: [
9
+ 'stylelint-config-standard-scss',
10
+ 'stylelint-config-prettier-scss',
11
+ ],
12
+ };
DI-sheep/ui/.versionrc.cjs ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ module.exports = {
2
+ scripts: {
3
+ postbump: 'yarn build && git add dist/*',
4
+ },
5
+ };
DI-sheep/ui/LICENSE.md ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
DI-sheep/ui/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # react ็ฝ‘้กตๅ‰็ซฏ
2
+
3
+ ไธป่ฆๅ‚่€ƒ https://github.com/StreakingMan/solvable-sheep-game ๏ผŒ่ฏทๅคงๅฎถไนŸๅคšๅคšๆ”ฏๆŒ่ฟ™ไธช repo
DI-sheep/ui/index.html ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta
8
+ name="description"
9
+ content="DI-sheep"
10
+ />
11
+ <title>DI-sheep</title>
12
+ <script>
13
+ var _hmt = _hmt || [];
14
+ (function () {
15
+ var hm = document.createElement('script');
16
+ hm.src =
17
+ 'https://hm.baidu.com/hm.js?0a5701b62c5da53aa10f9096fccb377c';
18
+ var s = document.getElementsByTagName('script')[0];
19
+ s.parentNode.insertBefore(hm, s);
20
+ })();
21
+ </script>
22
+ </head>
23
+ <body>
24
+ <div id="root"></div>
25
+ <script type="module" src="/src/main.tsx"></script>
26
+ <script
27
+ async
28
+ src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
29
+ ></script>
30
+ </body>
31
+ </html>
DI-sheep/ui/package.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "DI-sheep-ui",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "preview": "vite preview",
10
+ "prepare": "husky install",
11
+ "release:first": "standard-version -- --first-release",
12
+ "release": "standard-version --commit-all"
13
+ },
14
+ "dependencies": {
15
+ "react": "^18.2.0",
16
+ "react-dom": "^18.2.0"
17
+ },
18
+ "devDependencies": {
19
+ "@commitlint/cli": "^17.1.2",
20
+ "@commitlint/config-conventional": "^17.1.0",
21
+ "@types/react": "^18.0.20",
22
+ "@types/react-dom": "^18.0.6",
23
+ "@typescript-eslint/eslint-plugin": "^5.37.0",
24
+ "@typescript-eslint/parser": "^5.37.0",
25
+ "@vitejs/plugin-react": "^2.1.0",
26
+ "eslint": "^8.23.1",
27
+ "eslint-config-prettier": "^8.5.0",
28
+ "eslint-plugin-prettier": "^4.2.1",
29
+ "eslint-plugin-react": "^7.31.8",
30
+ "husky": "^8.0.1",
31
+ "lint-staged": "^13.0.3",
32
+ "prettier": "^2.7.1",
33
+ "standard-version": "^9.5.0",
34
+ "stylelint": "^14.11.0",
35
+ "stylelint-config-prettier-scss": "^0.0.1",
36
+ "stylelint-config-standard-scss": "^5.0.0",
37
+ "typescript": "^4.6.4",
38
+ "vite": "^3.1.0"
39
+ },
40
+ "license": "SEE LICENSE IN LICENSE.md"
41
+ }
DI-sheep/ui/preview.png ADDED
DI-sheep/ui/public/demo.gif ADDED

Git LFS Details

  • SHA256: 08ccf0d041f155cf2cc9c8fbb3712e7cb5982ac886c8e2277289ba78743175e7
  • Pointer size: 132 Bytes
  • Size of remote file: 4.7 MB
DI-sheep/ui/public/favicon.ico ADDED
DI-sheep/ui/public/github.svg ADDED
DI-sheep/ui/public/song_of_kedaya.mp3 ADDED
Binary file (918 kB). View file
 
DI-sheep/ui/public/sound-disco.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62b6f7960a64624890e0c59a9e8a8fb02a95c6449091b98d1fa4817c288f638c
3
+ size 8299694
DI-sheep/ui/qrcode.png ADDED
DI-sheep/ui/src/App.css ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #root {
2
+ text-align: center;
3
+ width: 100%;
4
+ max-width: 500px;
5
+ margin: 0 auto;
6
+ }
7
+
8
+ .app {
9
+ width: 100%;
10
+ margin: 0 auto;
11
+ }
12
+
13
+ .scene-container {
14
+ width: 100%;
15
+ padding-bottom: 100%;
16
+ position: relative;
17
+ margin: 10% 0;
18
+ }
19
+
20
+ .scene-inner {
21
+ position: absolute;
22
+ left: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ top: 0;
26
+ overflow: visible;
27
+ font-size: 28px;
28
+ }
29
+
30
+ .symbol {
31
+ width: 12.5%;
32
+ padding-bottom: 12.5%;
33
+ position: absolute;
34
+ transition: 150ms;
35
+ left: 0;
36
+ top: 0;
37
+ border-radius: 8px;
38
+ }
39
+
40
+ .symbol-inner {
41
+ position: absolute;
42
+ left: 0;
43
+ right: 0;
44
+ bottom: 0;
45
+ top: 0;
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ border-radius: 8px;
50
+ border: 2px solid #444;
51
+ transition: 0.3s;
52
+ overflow: hidden;
53
+ user-select: none;
54
+ }
55
+
56
+ .symbol-inner img {
57
+ width: 100%;
58
+ height: 100%;
59
+ object-fit: contain;
60
+ }
61
+
62
+ .queue-container {
63
+ border-radius: 8px;
64
+ width: 100%;
65
+ padding-bottom: 15%;
66
+ border: 2px solid gray;
67
+ margin-bottom: 16px;
68
+ }
69
+
70
+ .flex-container {
71
+ display: flex;
72
+ gap: 8px;
73
+ }
74
+
75
+ .flex-center {
76
+ justify-content: center;
77
+ align-items: center;
78
+ }
79
+
80
+ .flex-grow {
81
+ flex-grow: 1;
82
+ }
83
+
84
+ .flex-between {
85
+ justify-content: space-between;
86
+ align-items: center;
87
+ }
88
+
89
+ .modal {
90
+ position: fixed;
91
+ width: 100vw;
92
+ height: 100vh;
93
+ display: flex;
94
+ flex-direction: column;
95
+ align-items: center;
96
+ justify-content: center;
97
+ backdrop-filter: blur(10px);
98
+ background-color: rgb(255 255 255 / 40%);
99
+ top: 0;
100
+ left: 0;
101
+ }
102
+
103
+ .bgm-button {
104
+ position: fixed;
105
+ left: 0;
106
+ top: 0;
107
+ padding: 4px;
108
+ width: 36px;
109
+ height: 36px;
110
+ }
DI-sheep/ui/src/App.tsx ADDED
@@ -0,0 +1,449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, {
2
+ FC,
3
+ MouseEventHandler,
4
+ useEffect,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
8
+
9
+ import './App.css';
10
+ import { GithubIcon } from './GithubIcon';
11
+ import { randomString, waitTimeout } from './utils';
12
+ import { defaultTheme } from './themes/default';
13
+ import { Icon, Theme } from './themes/interface';
14
+ import { fishermanTheme } from './themes/fisherman';
15
+ import { diTheme } from './themes/di';
16
+ import { mhlTheme } from './themes/mhl';
17
+ import { yhdTheme } from './themes/yhd';
18
+
19
+ const themes = [defaultTheme, fishermanTheme, diTheme, mhlTheme, yhdTheme];
20
+
21
+ const maxLevel = 10;
22
+ const target_url = 'http://localhost:5002/DI-sheep/';
23
+
24
+ interface MySymbol {
25
+ id: string;
26
+ status: number; // 0->1->2
27
+ isCover: boolean;
28
+ isAgentTarget: boolean;
29
+ x: number;
30
+ y: number;
31
+ icon: Icon;
32
+ }
33
+
34
+ type Scene = MySymbol[];
35
+
36
+ // 8*8 grid with factor 4 (32x32)
37
+ const makeScene: (level: number, icons: Icon[], new_scene_data: string[], agent_action: number) => Scene = (level, icons, new_scene_data, agent_action) => {
38
+ const curLevel = Math.min(maxLevel, level);
39
+ const iconPool = icons.slice(0, 2 * curLevel);
40
+
41
+ const scene: Scene = [];
42
+
43
+ for (const raw_data of new_scene_data) {
44
+ const data = JSON.parse(raw_data);
45
+
46
+ const count = scene.length;
47
+ scene.push({
48
+ isCover: !data.accessible,
49
+ // isCover: !data.visible, // for viz debug
50
+ isAgentTarget: count === agent_action,
51
+ status: 0,
52
+ icon: iconPool[data.icon],
53
+ id: data.uid,
54
+ x: data.x,
55
+ y: data.y,
56
+ });
57
+ }
58
+ return scene;
59
+ };
60
+
61
+
62
+ interface SymbolProps extends MySymbol {
63
+ onClick: MouseEventHandler;
64
+ }
65
+
66
+ const Symbol: FC<SymbolProps> = ({ x, y, icon, isCover, isAgentTarget, status, onClick }) => {
67
+ return (
68
+ <div
69
+ className="symbol"
70
+ style={{
71
+ transform: `translateX(${x}%) translateY(${y}%)`,
72
+ backgroundColor: isAgentTarget ? 'orange' : isCover ? '#999' : 'white',
73
+ opacity: status < 2 ? 1 : 0,
74
+ }}
75
+ onClick={onClick}
76
+ >
77
+ <div
78
+ className="symbol-inner"
79
+ style={{ opacity: isCover ? 0.5 : 1 }}
80
+ >
81
+ {typeof icon.content === 'string' ? (
82
+ <i>{icon.content}</i>
83
+ ) : (
84
+ icon.content
85
+ )}
86
+ </div>
87
+ </div>
88
+ );
89
+ };
90
+
91
+ const uidApp = 'uid' + crypto.randomUUID();
92
+ const App: FC = () => {
93
+ const [curTheme, setCurTheme] = useState<Theme<any>>(diTheme);
94
+ const [level, setLevel] = useState<number>(1);
95
+ const [maxItemNum, setMaxItemNum] = useState<number>(0);
96
+ const [resItemNum, setResItemNum] = useState<number>(0);
97
+
98
+ const [startTime, setStartTime] = useState<number>(0);
99
+ const [now, setNow] = useState<number>(0);
100
+ const [usedTime, setUsedTime] = useState<number>(0);
101
+ const intervalRef = useRef<NodeJS.Timeout | null>(null);
102
+
103
+ const [queue, setQueue] = useState<MySymbol[]>([]);
104
+ const [sortedQueue, setSortedQueue] = useState<
105
+ Record<MySymbol['id'], number>
106
+ >({});
107
+ const [finished, setFinished] = useState<boolean>(false);
108
+ const [tipText, setTipText] = useState<string>('');
109
+ const [animating, setAnimating] = useState<boolean>(false);
110
+ const [expired, setExpired] = useState<boolean>(false);
111
+ const [lastAgentTarget, setLastAgentTarget] = useState<number>(-1);
112
+ const [scene, setScene] = useState<Scene>(makeScene(level, curTheme.icons, [], -1)); // placeholder
113
+
114
+ // audio
115
+ const soundRefMap = useRef<Record<string, HTMLAudioElement>>({});
116
+
117
+ const bgmRef = useRef<HTMLAudioElement>(null);
118
+ const [bgmOn, setBgmOn] = useState<boolean>(false);
119
+ const [once, setOnce] = useState<boolean>(false);
120
+ useEffect(() => {
121
+ if (!bgmRef.current) return;
122
+ if (bgmOn) {
123
+ bgmRef.current.volume = 0.5;
124
+ bgmRef.current.play();
125
+ } else {
126
+ bgmRef.current?.pause();
127
+ }
128
+ }, [bgmOn]);
129
+
130
+ // change themes
131
+ useEffect(() => {
132
+ restart(level);
133
+ }, [curTheme]);
134
+
135
+ useEffect(() => {
136
+ if (finished || queue.length >= 7 || expired) return;
137
+ if (startTime && now) setUsedTime(now - startTime);
138
+ }, [now]);
139
+ const startTimer = () => {
140
+ setStartTime(Date.now() - 0);
141
+ setNow(Date.now());
142
+ intervalRef.current && clearInterval(intervalRef.current);
143
+ intervalRef.current = setInterval(() => {
144
+ setNow(Date.now());
145
+ }, 10);
146
+ };
147
+
148
+ // sort queue
149
+ useEffect(() => {
150
+ const cache: Record<string, MySymbol[]> = {};
151
+ for (const symbol of queue) {
152
+ if (cache[symbol.icon.name]) {
153
+ cache[symbol.icon.name].push(symbol);
154
+ } else {
155
+ cache[symbol.icon.name] = [symbol];
156
+ }
157
+ }
158
+ const temp = [];
159
+ for (const symbols of Object.values(cache)) {
160
+ temp.push(...symbols);
161
+ }
162
+ const updateSortedQueue: typeof sortedQueue = {};
163
+ let x = 50;
164
+ for (const symbol of temp) {
165
+ updateSortedQueue[symbol.id] = x;
166
+ x += 100;
167
+ }
168
+ setSortedQueue(updateSortedQueue);
169
+ }, [queue]);
170
+
171
+ const update = (new_scene_data: string[]) => {
172
+ for (const raw_data of new_scene_data) {
173
+ const data = JSON.parse(raw_data);
174
+ const find = scene.find((s) => s.id === data.uid);
175
+ if (find) {
176
+ if (find.status === 0) {
177
+ find.isCover = !data.accessible;
178
+ }
179
+ }
180
+ }
181
+ if (scene.length > 0) {
182
+ scene.slice()[lastAgentTarget].isAgentTarget = false;
183
+ }
184
+ };
185
+
186
+ // TODO
187
+ const pop = () => {
188
+ if (!queue.length) return;
189
+ const updateQueue = queue.slice();
190
+ const symbol = updateQueue.shift();
191
+ if (!symbol) return;
192
+ const find = scene.find((s) => s.id === symbol.id);
193
+ if (find) {
194
+ setQueue(updateQueue);
195
+ find.status = 0;
196
+ find.x = 100 * Math.floor(8 * Math.random());
197
+ find.y = 700;
198
+ }
199
+ };
200
+
201
+ const levelUp = () => {
202
+ if (level >= maxLevel) {
203
+ return;
204
+ }
205
+ setFinished(false);
206
+ setTipText('');
207
+ setLevel(level + 1);
208
+ setQueue([]);
209
+ fetch(target_url,
210
+ {
211
+ headers: {
212
+ 'Accept': 'application/json',
213
+ 'Content-Type': 'application/json'
214
+ },
215
+ method: 'POST',
216
+ body: JSON.stringify({command: 'reset', argument: level + 1, uid: uidApp})
217
+ })
218
+ .then(response => response.json())
219
+ .then(response => {
220
+ setScene(makeScene(level + 1, curTheme.icons, response.result.scene, response.result.action));
221
+ setLastAgentTarget(response.result.action);
222
+ setMaxItemNum(response.result.max_item_num);
223
+ setResItemNum(response.result.max_item_num);
224
+ setUsedTime(0);
225
+ startTimer();
226
+ });
227
+ };
228
+
229
+ const restart = (level: number) => {
230
+ setFinished(false);
231
+ setExpired(false);
232
+ setTipText('');
233
+ setUsedTime(0); // necessary
234
+ setQueue([]);
235
+ fetch(target_url,
236
+ {
237
+ headers: {
238
+ 'Accept': 'application/json',
239
+ 'Content-Type': 'application/json'
240
+ },
241
+ method: 'POST',
242
+ body: JSON.stringify({command: 'reset', argument: level, uid: uidApp})
243
+ })
244
+ .then(response => response.json())
245
+ .then(response => {
246
+ setScene(makeScene(level, curTheme.icons, response.result.scene, response.result.action));
247
+ setLastAgentTarget(response.result.action);
248
+ setMaxItemNum(response.result.max_item_num);
249
+ setResItemNum(response.result.max_item_num);
250
+ setUsedTime(0);
251
+ startTimer();
252
+ });
253
+ };
254
+
255
+ const clickSymbol = async (idx: number) => {
256
+ // console.time("process");
257
+ if (idx === -1) {
258
+ idx = lastAgentTarget;
259
+ }
260
+ if (finished || animating) return;
261
+ if (queue.length >= 7) {
262
+ setTipText('ๆŒ‘ๆˆ˜ๅคฑ่ดฅ');
263
+ setFinished(true);
264
+ return;
265
+ }
266
+
267
+ if (!once) {
268
+ setBgmOn(true);
269
+ setOnce(true);
270
+ setUsedTime(0);
271
+ startTimer();
272
+ }
273
+
274
+ const updateScene = scene.slice();
275
+ const symbol = updateScene[idx];
276
+ if (symbol.isCover || symbol.status !== 0) return;
277
+ symbol.status = 1;
278
+
279
+ if (soundRefMap.current) {
280
+ soundRefMap.current[symbol.icon.clickSound].currentTime = 0;
281
+ soundRefMap.current[symbol.icon.clickSound].play();
282
+ }
283
+ let status = false;
284
+
285
+ fetch(target_url,
286
+ {
287
+ headers: {
288
+ 'Accept': 'application/json',
289
+ 'Content-Type': 'application/json'
290
+ },
291
+ method: 'POST',
292
+ body: JSON.stringify({command: 'step', argument: idx, uid: uidApp})
293
+ })
294
+ .then(response => response.json())
295
+ .then(response => {
296
+ setFinished(response.statusCode === 501)
297
+ if (response.statusCode != 501) {
298
+ update(response.result.scene);
299
+ setLastAgentTarget(response.result.action);
300
+ updateScene[response.result.action].isAgentTarget = true;
301
+ setResItemNum(resItemNum - 1);
302
+ }
303
+ setExpired(response.statusCode === 501);
304
+ status = (response.statusCode === 501);
305
+ });
306
+
307
+ let updateQueue = queue.slice();
308
+ updateQueue.push(symbol);
309
+
310
+ setQueue(updateQueue);
311
+
312
+ setAnimating(true);
313
+ // console.timeEnd("process");
314
+ await waitTimeout(150);
315
+
316
+ const filterSame = updateQueue.filter((sb) => sb.icon === symbol.icon);
317
+
318
+ if (!status && filterSame.length === 3) {
319
+ updateQueue = updateQueue.filter((sb) => sb.icon !== symbol.icon);
320
+ for (const sb of filterSame) {
321
+ const find = updateScene.find((i) => i.id === sb.id);
322
+ if (find) {
323
+ find.status = 2;
324
+ if (soundRefMap.current) {
325
+ soundRefMap.current[
326
+ symbol.icon.tripleSound
327
+ ].currentTime = 0;
328
+ soundRefMap.current[symbol.icon.tripleSound].play();
329
+ }
330
+ }
331
+ }
332
+ }
333
+
334
+ if (!status && updateQueue.length >= 7) {
335
+ setTipText('ๆŒ‘ๆˆ˜ๅคฑ่ดฅ');
336
+ setFinished(true);
337
+ }
338
+
339
+ if (!status && (!updateScene.find((s) => s.status === 0))) {
340
+ if (level === maxLevel) {
341
+ setTipText('ๅ…จ้ƒจๅ…ณๅกๆŒ‘ๆˆ˜ๆˆๅŠŸ');
342
+ setQueue([]);
343
+ setFinished(true);
344
+ setAnimating(false);
345
+ return;
346
+ }
347
+ setTipText('ๆœฌๅ…ณๆˆๅŠŸ');
348
+ setLevel(level + 1);
349
+ setQueue([]);
350
+ restart(level + 1);
351
+ } else {
352
+ setQueue(updateQueue);
353
+ }
354
+
355
+ setAnimating(false);
356
+ };
357
+
358
+ return (
359
+ <>
360
+ <h2>DI-sheep: ๆทฑๅบฆๅผบๅŒ–ๅญฆไน  + ็พŠไบ†ไธช็พŠ </h2>
361
+ <h6>
362
+ <GithubIcon />
363
+ </h6>
364
+ <h3 className="flex-container flex-center">
365
+ ไธป้ข˜:
366
+ <select
367
+ onChange={(e) =>
368
+ setCurTheme(themes[Number(e.target.value)])
369
+ }
370
+ >
371
+ {themes.map((t, idx) => (
372
+ <option key={t.name} value={idx}>
373
+ {t.name}
374
+ </option>
375
+ ))}
376
+ </select>
377
+ </h3>
378
+ <h3 className="flex-container flex-center">
379
+ ๅ…ณๅก: {level}/{maxLevel} ็”จๆ—ถ: {(usedTime / 1000).toFixed(2)}็ง’ ๆ€ป็‰Œๆ•ฐ: {maxItemNum}
380
+ <br />
381
+ 1-9ๅ…ณๅ…จ้ƒจๅฏๆถˆ๏ผŒ็ฌฌ10ๅ…ณไผš้ขๅค–่ฎพ็ฝฎ2ๅผ ๅ•็‹ฌ็š„็‰Œ
382
+ </h3>
383
+
384
+ <div className="app">
385
+ <div className="scene-container">
386
+ <div className="scene-inner">
387
+ {scene.map((item, idx) => (
388
+ <Symbol
389
+ key={item.id}
390
+ {...item}
391
+ x={
392
+ item.status === 0
393
+ ? item.x
394
+ : item.status === 1
395
+ ? sortedQueue[item.id]
396
+ : -1000
397
+ }
398
+ y={item.status === 0 ? item.y : 895}
399
+ onClick={() => clickSymbol(idx)}
400
+ />
401
+ ))}
402
+ </div>
403
+ </div>
404
+ </div>
405
+ <div className="queue-container flex-container flex-center" />
406
+ <div className="flex-container flex-between">
407
+ <button className="flex-grow" onClick={() => restart(level)}>
408
+ ้‡ๅผ€ๆœฌๅ…ณ
409
+ </button>
410
+ <button className="flex-grow" onClick={levelUp}>
411
+ ไธ‹ไธ€ๅ…ณ
412
+ </button>
413
+ <button className="flex-grow" onClick={() => clickSymbol(-1)}>
414
+ AI ้€Ÿ้€šๆต
415
+ </button>
416
+ {/*<button onClick={test}>ๆต‹่ฏ•</button>*/}
417
+ </div>
418
+ <p style={{ textAlign: 'center' }}>
419
+ ๅฐๆ็คบ๏ผšๅฆ‚ๆžœๅ‡บ็Žฐๆฉ™่‰ฒ่ƒŒๆ™ฏๅ—๏ผŒ่ฟ™ๆ˜ฏ AI ๆ็คบ็š„้€‰ๆ‹ฉๅ“ฆ
420
+ </p>
421
+
422
+ {finished && (
423
+ <div className="modal">
424
+ <h1>{tipText}</h1>
425
+ <button onClick={() => restart(level)}> {expired ? '60sๆธธๆˆ่ฟ‡ๆœŸ๏ผŒ้‡ๆฅไธ€ๅ…ณ' : 'ๅ†่ฏ•่ฏ•ไธŠไธ€ๅ…ณ'} </button>
426
+ </div>
427
+ )}
428
+
429
+ {/*bgm*/}
430
+ <button className="bgm-button" onClick={() => setBgmOn(!bgmOn)}>
431
+ {bgmOn ? '๐Ÿ”Š' : '๐Ÿ”ˆ'}
432
+ <audio ref={bgmRef} loop src="/song_of_kedaya.mp3" />
433
+ </button>
434
+
435
+ {/*้Ÿณๆ•ˆ*/}
436
+ {curTheme.sounds.map((sound) => (
437
+ <audio
438
+ key={sound.name}
439
+ ref={(ref) => {
440
+ if (ref) soundRefMap.current[sound.name] = ref;
441
+ }}
442
+ src={sound.src}
443
+ />
444
+ ))}
445
+ </>
446
+ );
447
+ };
448
+
449
+ export default App;
DI-sheep/ui/src/GithubIcon.tsx ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { FC } from 'react';
2
+
3
+ export const GithubIcon: FC = () => {
4
+ return (
5
+ <a
6
+ href="https://github.com/orgs/opendilab/repositories"
7
+ target="_blank"
8
+ rel="noreferrer"
9
+ >
10
+ ็‚นไธช Star ไธ่ฟท่ทฏ @OpenDILab
11
+ <svg
12
+ height="24"
13
+ aria-hidden="true"
14
+ viewBox="0 0 16 16"
15
+ version="1.1"
16
+ width="24"
17
+ data-view-component="true"
18
+ className="octicon octicon-mark-github v-align-middle"
19
+ fill="currentColor"
20
+ >
21
+ <path
22
+ fillRule="evenodd"
23
+ d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"
24
+ />
25
+ </svg>
26
+ </a>
27
+ );
28
+ };
DI-sheep/ui/src/index.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3
+ font-size: 16px;
4
+ line-height: 24px;
5
+ font-weight: 400;
6
+ color-scheme: light dark;
7
+ color: rgb(255 255 255 / 87%);
8
+ background-color: #242424;
9
+ font-synthesis: none;
10
+ text-rendering: optimizelegibility;
11
+ -webkit-font-smoothing: antialiased;
12
+ -moz-osx-font-smoothing: grayscale;
13
+ text-size-adjust: 100%;
14
+ }
15
+
16
+ a {
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
+ }
21
+
22
+ a:hover {
23
+ color: #535bf2;
24
+ }
25
+
26
+ body {
27
+ margin: 0;
28
+ padding: 0 32px;
29
+ }
30
+
31
+ h1 {
32
+ font-size: 3.2em;
33
+ line-height: 1.1;
34
+ }
35
+
36
+ select {
37
+ border: 2px solid gray;
38
+ border-radius: 4px;
39
+ padding: 4px 8px;
40
+ }
41
+
42
+ button {
43
+ border-radius: 8px;
44
+ border: 1px solid transparent;
45
+ padding: 0.6em 1.2em;
46
+ font-size: 1em;
47
+ font-weight: 500;
48
+ font-family: inherit;
49
+ background-color: #1a1a1a;
50
+ cursor: pointer;
51
+ transition: border-color 0.25s;
52
+ word-break: keep-all;
53
+ outline: none;
54
+ }
55
+
56
+ button:hover {
57
+ border-color: #646cff;
58
+ }
59
+
60
+ button:focus,
61
+ button:focus-visible {
62
+ outline: 4px auto -webkit-focus-ring-color;
63
+ }
64
+
65
+ @media (prefers-color-scheme: light) {
66
+ :root {
67
+ color: #213547;
68
+ background-color: #fff;
69
+ }
70
+
71
+ a:hover {
72
+ color: #747bff;
73
+ }
74
+
75
+ button {
76
+ background-color: #f9f9f9;
77
+ }
78
+ }
DI-sheep/ui/src/main.tsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+ import './index.css';
5
+
6
+ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
DI-sheep/ui/src/themes/default/index.ts ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Theme } from '../interface';
2
+
3
+ const icons = <const>[
4
+ `๐ŸŽจ`,
5
+ `๐ŸŒˆ`,
6
+ `โš™๏ธ`,
7
+ `๐Ÿ’ป`,
8
+ `๐Ÿ“š`,
9
+ `๐Ÿฏ`,
10
+ `๐Ÿค`,
11
+ `๐Ÿผ`,
12
+ `๐Ÿ`,
13
+ `๐Ÿ€`,
14
+ ];
15
+
16
+ export type DefaultSoundNames = 'button-click' | 'triple';
17
+
18
+ import soundButtonClickUrl from './sounds/sound-button-click.mp3';
19
+ import soundTripleUrl from './sounds/sound-triple.mp3';
20
+ export const defaultSounds: Theme<DefaultSoundNames>['sounds'] = [
21
+ {
22
+ name: 'button-click',
23
+ src: soundButtonClickUrl,
24
+ },
25
+ {
26
+ name: 'triple',
27
+ src: soundTripleUrl,
28
+ },
29
+ ];
30
+
31
+ export const defaultTheme: Theme<DefaultSoundNames> = {
32
+ name: '้ป˜่ฎค',
33
+ icons: icons.map((icon) => ({
34
+ name: icon,
35
+ content: icon,
36
+ clickSound: 'button-click',
37
+ tripleSound: 'triple',
38
+ })),
39
+ sounds: defaultSounds,
40
+ };
DI-sheep/ui/src/themes/default/sounds/sound-button-click.mp3 ADDED
Binary file (42.8 kB). View file
 
DI-sheep/ui/src/themes/default/sounds/sound-triple.mp3 ADDED
Binary file (44.9 kB). View file
 
DI-sheep/ui/src/themes/di/images/+1.png ADDED
DI-sheep/ui/src/themes/di/images/emo.png ADDED
DI-sheep/ui/src/themes/di/images//345/206/262/351/270/255.png ADDED
DI-sheep/ui/src/themes/di/images//345/212/240/347/217/255.png ADDED
DI-sheep/ui/src/themes/di/images//345/234/250/347/272/277/346/221/270/351/261/274.png ADDED
DI-sheep/ui/src/themes/di/images//346/203/263/345/210/260/344/272/206.png ADDED