update,
This commit is contained in:
15
task1/.editorconfig
Normal file
15
task1/.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
2
task1/.gitignore
vendored
Normal file
2
task1/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*~*
|
||||
**/_backup/*
|
BIN
task1/_docs.zip
(Stored with Git LFS)
Normal file
BIN
task1/_docs.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
64
task1/_docs/change_password.drawio
Normal file
64
task1/_docs/change_password.drawio
Normal file
@@ -0,0 +1,64 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="3712" dy="2324" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="32" value="" style="edgeStyle=none;html=1;" parent="1" source="2" target="31" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="36" value="" style="edgeStyle=none;html=1;" parent="1" source="31" target="35" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="31" value="open password file<br>ac.txt" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="38" value="" style="edgeStyle=none;html=1;" parent="1" source="35" target="37" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="35" value="Read Password" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="380" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="37" target="39" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="No" style="edgeStyle=none;html=1;" parent="1" source="37" target="48" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value="Current user found ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="510" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="" style="edgeStyle=none;html=1;" parent="1" source="39" target="44" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="Change Password" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="680" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="" style="edgeStyle=none;html=1;" parent="1" source="44" target="46" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="Save to file" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="820" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="End" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="950" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="Display Error message" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="520" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="48" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="370" y="700" as="sourcePoint"/>
|
||||
<mxPoint x="200" y="920" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="360" y="920"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
52
task1/_docs/create_player.drawio
Normal file
52
task1/_docs/create_player.drawio
Normal file
@@ -0,0 +1,52 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="2651" dy="1660" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="19" value="" style="edgeStyle=none;html=1;" parent="1" source="2" target="18" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="23" value="" style="edgeStyle=none;html=1;" parent="1" source="18" target="22" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="18" value="Get userame and password from user" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="25" value="No" style="edgeStyle=none;html=1;" parent="1" source="22" target="24" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="29" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="22" target="28" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="22" value="Username or password is empty ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="85" y="380" width="230" height="150" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="27" value="" style="edgeStyle=none;html=1;" parent="1" source="24" target="26" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="24" value="Write new account to file" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="655" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="26" value="end" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="785" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="28" value="show missing field to user" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="450" y="425" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="30" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="28" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="450" y="650" as="sourcePoint"/>
|
||||
<mxPoint x="200" y="750" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="510" y="750"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
64
task1/_docs/delete_player.drawio
Normal file
64
task1/_docs/delete_player.drawio
Normal file
@@ -0,0 +1,64 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="436" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="3">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="6" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="3" target="5">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="3" value="open password file ac.txt" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="8" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="5" target="7">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="5" value="read userame" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="380" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="10" value="Yes" style="edgeStyle=none;html=1;" edge="1" parent="1" source="7" target="9">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="16" value="No" style="edgeStyle=none;html=1;" edge="1" parent="1" source="7" target="15">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="7" value="username found in file ?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="510" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="12" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="9" target="11">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="9" value="delete user" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="680" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="14" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="11" target="13">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="11" value="write changes to file" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="820" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="13" value="end" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="950" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="15" value="Display error message" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="300" y="520" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="17" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="15">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="370" y="710" as="sourcePoint"/>
|
||||
<mxPoint x="200" y="920" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="360" y="920"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
124
task1/_docs/draft.md
Normal file
124
task1/_docs/draft.md
Normal file
@@ -0,0 +1,124 @@
|
||||
### Player VS Computer
|
||||
|
||||
1. game mode select
|
||||
2. player vs computer
|
||||
3. player login (username and password)
|
||||
4. Game run (player vs computer)
|
||||
5. Game finish
|
||||
6. Show ranking
|
||||
7. Back to start
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Game Mode Select] --> B[Player vs Computer];
|
||||
B --> C["Player Login (Username and Password)"];
|
||||
C --> D["Game Run (Player vs Computer)"];
|
||||
D --> E[Game Finish];
|
||||
E --> F[Show Ranking?];
|
||||
F --> H[show ranking to user];
|
||||
H --> G[Back to Start];
|
||||
F --> G[Back to Start];
|
||||
```
|
||||
|
||||
### Player VS Player
|
||||
|
||||
1. game mode select
|
||||
2. player vs computer
|
||||
3. player1 login (username and password)
|
||||
3. player2 login (username and password)
|
||||
4. Game run (player vs computer)
|
||||
5. Game finish
|
||||
6. Show ranking
|
||||
7. Back to start
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Start] --> B[Game Mode Select];
|
||||
B --> C[Player VS Computer];
|
||||
C --> D["Player1 Login (username and password)"];
|
||||
D --> E["Player2 Login (username and password)"];
|
||||
E --> F["Game Run (Player VS Computer)"];
|
||||
F --> G[Game Finish];
|
||||
G --> H[Show Ranking?];
|
||||
H --> J[show ranking to user];
|
||||
H --> I[Back to Start];
|
||||
J --> I;
|
||||
I --> A;
|
||||
```
|
||||
|
||||
### show ranking
|
||||
|
||||
1. read ranking
|
||||
2. show to user
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Start] --> B[Read Ranking];
|
||||
B --> C[Show Ranking to User];
|
||||
C --> D[End];
|
||||
```
|
||||
|
||||
### change password
|
||||
|
||||
1. open password file `ac.txt`
|
||||
2. read passwords
|
||||
3. find current user
|
||||
4. change password when username match
|
||||
5. save to file
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Start] --> B["Open Password File ac.txt"];
|
||||
B --> C[Read Passwords];
|
||||
C --> D[Find Current User];
|
||||
D -->|Username Match| E[Change Password];
|
||||
D -->|Username Not Found| F[Display Error Message];
|
||||
E --> G[Save to File];
|
||||
G --> H[End];
|
||||
F --> H[End];
|
||||
```
|
||||
|
||||
|
||||
### create player
|
||||
|
||||
1. get username and password from user
|
||||
2. check if username or password is empty
|
||||
3. show missing to user if empty
|
||||
4. username and password ok
|
||||
5. write to account file
|
||||
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Start] --> B[Get Username and Password from User];
|
||||
B --> C[Check if Username or Password is Empty];
|
||||
C -->|Username or Password is Empty| D[Show Missing Fields to User];
|
||||
C -->|Username and Password are Not Empty| E[Write to Account File];
|
||||
D --> F[End];
|
||||
E --> F[End];
|
||||
```
|
||||
|
||||
|
||||
### delete player
|
||||
|
||||
1. open password file `ac.txt`
|
||||
2. read username
|
||||
3. if username found in file
|
||||
4. delete user
|
||||
5. write change to file
|
||||
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
A[Start] --> B["Open Password File ac.txt"];
|
||||
B --> C[Read Username];
|
||||
C --> D[Username Found in File?];
|
||||
D -->|Yes| E[Delete User];
|
||||
D -->|No| F[Display Error Message];
|
||||
E --> G[Write Changes to File];
|
||||
G --> H[End];
|
||||
F --> H[End];
|
||||
A@{ shape: circle}
|
||||
H@{ shape: circle}
|
||||
D@{ shape: diamond }
|
||||
```
|
65
task1/_docs/player_vs_computer.drawio
Normal file
65
task1/_docs/player_vs_computer.drawio
Normal file
@@ -0,0 +1,65 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="1968" dy="2324" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="31" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="30">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="33" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="30" target="32">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="30" value="Player cs Computer" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="35" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="32" target="34">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="32" value="Player1 Login<br>(username and password)" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="380" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="34" target="36">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="34" value="Game run&nbsp;<br>(player vs computer)" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="520" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="36" target="40">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="36" value="Game Finish" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="660" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="Yes" style="edgeStyle=none;html=1;" edge="1" parent="1" source="40" target="42">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="Show<br>Ranking<br>?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="790" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="42" target="44">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="Show ranking to user" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="960" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="End" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="1090" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="No" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="40">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="340" y="910" as="sourcePoint"/>
|
||||
<mxPoint x="200" y="1060" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="360" y="830"/>
|
||||
<mxPoint x="360" y="1060"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
77
task1/_docs/player_vs_player.drawio
Normal file
77
task1/_docs/player_vs_player.drawio
Normal file
@@ -0,0 +1,77 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="3093" dy="1937" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="31" value="" style="edgeStyle=none;html=1;" parent="1" source="2" target="30" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="33" value="" style="edgeStyle=none;html=1;" parent="1" source="30" target="32" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="30" value="Game Mode Select" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="35" value="" style="edgeStyle=none;html=1;" parent="1" source="32" target="34" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="32" value="Player vs Computer" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="380" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="38" value="" style="edgeStyle=none;html=1;" parent="1" source="34" target="37" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="34" value="Player 1 Login<br>(username and password)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="520" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="" style="edgeStyle=none;html=1;" parent="1" source="37" target="39" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value=" <span style="color: rgb(240, 240, 240); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(42, 37, 47); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Player2 Login (username and password)</span> " style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="660" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="" style="edgeStyle=none;html=1;" parent="1" source="39" target="41" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="Game run<br>(Player vs computer)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="800" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="" style="edgeStyle=none;html=1;" parent="1" source="41" target="43" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="Game Finish" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="940" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="43" target="45" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="Show<br>Ranking<br>?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="1070" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="" style="edgeStyle=none;html=1;" parent="1" source="45" target="47" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="Show ranking to user" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="1240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="End" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="1370" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="No" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="43" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="330" y="1090" as="sourcePoint"/>
|
||||
<mxPoint x="200" y="1340" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="340" y="1110"/>
|
||||
<mxPoint x="340" y="1340"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
31
task1/_docs/show_ranking.drawio
Normal file
31
task1/_docs/show_ranking.drawio
Normal file
@@ -0,0 +1,31 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="s-rzDiBvBLxu23ZU9ywy" name="Page-1">
|
||||
<mxGraphModel dx="2651" dy="1660" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="32" value="" style="edgeStyle=none;html=1;" parent="1" source="2" target="31" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="start" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="70" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="38" value="" style="edgeStyle=none;html=1;" parent="1" source="31" target="37" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="31" value="Read Ranking<br>ranking.csv" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="240" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="" style="edgeStyle=none;html=1;" parent="1" source="37" target="39" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value="Show Ranking to user" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="380" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="End" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="160" y="510" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
BIN
task1/_from_client/Doc1.docx
Normal file
BIN
task1/_from_client/Doc1.docx
Normal file
Binary file not shown.
BIN
task1/_from_client/Sba ict check (2).docx
Normal file
BIN
task1/_from_client/Sba ict check (2).docx
Normal file
Binary file not shown.
BIN
task1/_from_client/_src/2023-24_S5_SBA_v2.docx.pdf
Normal file
BIN
task1/_from_client/_src/2023-24_S5_SBA_v2.docx.pdf
Normal file
Binary file not shown.
138
task1/_from_client/_src/tic tac toe haman vs pc.py
Normal file
138
task1/_from_client/_src/tic tac toe haman vs pc.py
Normal file
@@ -0,0 +1,138 @@
|
||||
import tkinter
|
||||
import random
|
||||
import time
|
||||
|
||||
masu = [
|
||||
[0, 0, 0],
|
||||
[0, 0, 0],
|
||||
[0, 0, 0]
|
||||
]
|
||||
shirushi = 0
|
||||
kachi = 0
|
||||
FNT = ("Times New Roman", 60)
|
||||
|
||||
def masume():
|
||||
cvs.delete("all")
|
||||
for i in range(1, 3):
|
||||
cvs.create_line(200*i, 0, 200*i, 600, fill="gray", width=8)
|
||||
cvs.create_line(0, i*200, 600, i*200, fill="gray", width=8)
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
X = x * 200
|
||||
Y = y * 200
|
||||
if masu[y][x] == 1:
|
||||
cvs.create_oval(X+20, Y+20, X+180, Y+180, outline="blue", width=12)
|
||||
if masu[y][x] == 2:
|
||||
cvs.create_line(X+20, Y+20, X+180, Y+180, fill="red", width=12)
|
||||
cvs.create_line(X+180, Y+20, X+20, Y+180, fill="red", width=12)
|
||||
if shirushi == 0:
|
||||
cvs.create_text(300, 300, text="遊戲開始!", fill="navy", font=FNT)
|
||||
cvs.update()
|
||||
|
||||
def click(e):
|
||||
global shirushi
|
||||
if shirushi == 9:
|
||||
replay()
|
||||
return
|
||||
if shirushi==1 or shirushi==3 or shirushi==5 or shirushi==7:
|
||||
return
|
||||
mx = int(e.x/200)
|
||||
my = int(e.y/200)
|
||||
if mx>2: mx = 2
|
||||
if my>2: my = 2
|
||||
if masu[my][mx] == 0:
|
||||
masu[my][mx] = 1
|
||||
shirushi = shirushi + 1
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
if shirushi < 9:
|
||||
computer()
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
|
||||
def computer():
|
||||
global shirushi
|
||||
#有沒有連成一線的符號
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 2
|
||||
hantei()
|
||||
if kachi==2:
|
||||
shirushi = shirushi + 1
|
||||
return
|
||||
masu[y][x] = 0
|
||||
#阻止玩家連成一線
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 1
|
||||
hantei()
|
||||
if kachi==1:
|
||||
masu[y][x] = 2
|
||||
shirushi = shirushi + 1
|
||||
return
|
||||
masu[y][x] = 0
|
||||
while True:
|
||||
x = random.randint(0, 2)
|
||||
y = random.randint(0, 2)
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 2
|
||||
shirushi = shirushi + 1
|
||||
break
|
||||
|
||||
def hantei():
|
||||
global kachi
|
||||
kachi = 0
|
||||
for n in range(1, 3):
|
||||
#判斷垂直方向是否連成一線
|
||||
if masu[0][0]==n and masu[1][0]==n and masu[2][0]==n:
|
||||
kachi = n
|
||||
if masu[0][1]==n and masu[1][1]==n and masu[2][1]==n:
|
||||
kachi = n
|
||||
if masu[0][2]==n and masu[1][2]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
#判斷水平方向是否連成一線
|
||||
if masu[0][0]==n and masu[0][1]==n and masu[0][2]==n:
|
||||
kachi = n
|
||||
if masu[1][0]==n and masu[1][1]==n and masu[1][2]==n:
|
||||
kachi = n
|
||||
if masu[2][0]==n and masu[2][1]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
#判斷傾斜方向是否連成一線
|
||||
if masu[0][0]==n and masu[1][1]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
if masu[0][2]==n and masu[1][1]==n and masu[2][0]==n:
|
||||
kachi = n
|
||||
|
||||
def syouhai():
|
||||
global shirushi
|
||||
if kachi == 1:
|
||||
cvs.create_text(300, 300, text="玩家獲勝!", font=FNT, fill="cyan")
|
||||
shirushi = 9
|
||||
if kachi == 2:
|
||||
cvs.create_text(300, 300, text="電腦\n獲勝!", font=FNT, fill="gold")
|
||||
shirushi = 9
|
||||
if kachi == 0 and shirushi == 9:
|
||||
cvs.create_text(300, 300, text="平手", font=FNT, fill="lime")
|
||||
|
||||
def replay():
|
||||
global shirushi
|
||||
shirushi = 0
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
masu[y][x] = 0
|
||||
masume()
|
||||
|
||||
root = tkinter.Tk()
|
||||
root.title("井字遊戲")
|
||||
root.resizable(False, False)
|
||||
root.bind("<Button>", click)
|
||||
cvs = tkinter.Canvas(width=600, height=600, bg="white")
|
||||
cvs.pack()
|
||||
masume()
|
||||
root.mainloop()
|
110
task1/_from_client/_src/user vs user final.py
Normal file
110
task1/_from_client/_src/user vs user final.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import tkinter
|
||||
|
||||
player1 = 1
|
||||
player2 = 2
|
||||
current_player = player1
|
||||
shirushi = 0
|
||||
|
||||
masu = [
|
||||
[0, 0, 0],
|
||||
[0, 0, 0],
|
||||
[0, 0, 0]
|
||||
]
|
||||
|
||||
def masume():
|
||||
global cvs
|
||||
cvs.delete("all")
|
||||
cvs.create_line(200, 0, 200, 600, fill="black", width=8)
|
||||
cvs.create_line(400, 0, 400, 600, fill="black", width=8)
|
||||
cvs.create_line(0, 200, 600, 200, fill="black", width=8)
|
||||
cvs.create_line(0, 400, 600, 400, fill="black", width=8)
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
X = x * 200
|
||||
Y = y * 200
|
||||
if masu[y][x] == 1:
|
||||
cvs.create_oval(X + 20, Y + 20, X + 180, Y + 180, outline="blue", width=12)
|
||||
if masu[y][x] == 2:
|
||||
cvs.create_line(X + 20, Y + 20, X + 180, Y + 180, fill="red", width=12)
|
||||
cvs.create_line(X + 180, Y + 20, X + 20, Y + 180, fill="red", width=12)
|
||||
cvs.update()
|
||||
|
||||
def click(e):
|
||||
global current_player, shirushi
|
||||
if shirushi == 9:
|
||||
replay()
|
||||
return
|
||||
if shirushi == 1 or shirushi == 3 or shirushi == 5 or shirushi == 7:
|
||||
return
|
||||
mx = int(e.x / 200)
|
||||
my = int(e.y / 200)
|
||||
if mx > 2:
|
||||
mx = 2
|
||||
if my > 2:
|
||||
my = 2
|
||||
if masu[my][mx] == 0:
|
||||
masu[my][mx] = current_player
|
||||
winner = check_winner()
|
||||
if winner != 0 or shirushi == 8:
|
||||
shirushi = 9
|
||||
else:
|
||||
# Switch players
|
||||
if current_player == player1:
|
||||
current_player = player2
|
||||
else:
|
||||
current_player = player1
|
||||
masume()
|
||||
syouhai()
|
||||
|
||||
def check_winner():
|
||||
# Check rows
|
||||
for row in masu:
|
||||
if row[0] == row[1] == row[2] != 0:
|
||||
return row[0]
|
||||
|
||||
# Check columns
|
||||
for col in range(3):
|
||||
if masu[0][col] == masu[1][col] == masu[2][col] != 0:
|
||||
return masu[0][col]
|
||||
|
||||
# Check diagonals
|
||||
if masu[0][0] == masu[1][1] == masu[2][2] != 0:
|
||||
return masu[0][0]
|
||||
if masu[0][2] == masu[1][1] == masu[2][0] != 0:
|
||||
return masu[0][2]
|
||||
|
||||
# Check if all cells are filled (tie)
|
||||
if all(row.count(0) == 0 for row in masu):
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def syouhai():
|
||||
global shirushi
|
||||
winner = check_winner()
|
||||
if winner == player1:
|
||||
cvs.create_text(300, 300, text="Player 1 wins!", font=("Arial", 36), fill="cyan")
|
||||
shirushi = 9
|
||||
elif winner == player2:
|
||||
cvs.create_text(300, 300, text="Player 2 wins!", font=("Arial", 36), fill="gold")
|
||||
shirushi = 9
|
||||
elif winner == -1:
|
||||
cvs.create_text(300, 300, text="Tie", font=("Arial", 36), fill="lime")
|
||||
shirushi = 9
|
||||
|
||||
def replay():
|
||||
global shirushi
|
||||
shirushi = 0
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
masu[y][x] = 0
|
||||
masume()
|
||||
|
||||
def User_UserMode():
|
||||
root_UserUser = tkinter.Toplevel(root)
|
||||
root_UserUser.title("sba tac tae toe user vs user")
|
||||
root_UserUser.resizable(False, False)
|
||||
root_UserUser.bind("<Button>", click)
|
||||
cvs = tkinter.Canvas(width=600, height=600, bg="white")
|
||||
cvs.pack()
|
||||
masume()
|
||||
root_UserUser.mainloop()
|
BIN
task1/_from_client/notes/Ch2_ProgramTesting.pptx
Normal file
BIN
task1/_from_client/notes/Ch2_ProgramTesting.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch2_ProgramTesting_2.pptx
Normal file
BIN
task1/_from_client/notes/Ch2_ProgramTesting_2.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch3_nested-loop.pptx
Normal file
BIN
task1/_from_client/notes/Ch3_nested-loop.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch3_nested-loop2.pptx
Normal file
BIN
task1/_from_client/notes/Ch3_nested-loop2.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch6_Bubble.pptx
Normal file
BIN
task1/_from_client/notes/Ch6_Bubble.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch6_EffectSorting.pptx
Normal file
BIN
task1/_from_client/notes/Ch6_EffectSorting.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch6_InsertionSort.pptx
Normal file
BIN
task1/_from_client/notes/Ch6_InsertionSort.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch6_SelectionInsertion.pptx
Normal file
BIN
task1/_from_client/notes/Ch6_SelectionInsertion.pptx
Normal file
Binary file not shown.
BIN
task1/_from_client/notes/Ch6_Swap_Selection.pptx
Normal file
BIN
task1/_from_client/notes/Ch6_Swap_Selection.pptx
Normal file
Binary file not shown.
5
task1/_from_client/reports/convert.sh
Executable file
5
task1/_from_client/reports/convert.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
markitdown sba_ict_word_final.docx > document.md
|
1025
task1/_from_client/reports/document.md
Normal file
1025
task1/_from_client/reports/document.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
task1/_from_client/reports/sba_ict_word_final.docx
Normal file
BIN
task1/_from_client/reports/sba_ict_word_final.docx
Normal file
Binary file not shown.
BIN
task1/_from_client/sba ict code explain.pptx
Normal file
BIN
task1/_from_client/sba ict code explain.pptx
Normal file
Binary file not shown.
BIN
task1/_ref/5a3bc7429d5c8d3006543defeb9a60f9.pdf
Normal file
BIN
task1/_ref/5a3bc7429d5c8d3006543defeb9a60f9.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/ICT_C&A_Guide_e_final.pdf
Normal file
BIN
task1/_ref/ICT_C&A_Guide_e_final.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/SBA student handbook 2023-2025_FINALIZED.pdf
Normal file
BIN
task1/_ref/SBA student handbook 2023-2025_FINALIZED.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/SBA_booklet_eng.pdf
Normal file
BIN
task1/_ref/SBA_booklet_eng.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/SBA_pamphlet_C_web.pdf
Normal file
BIN
task1/_ref/SBA_pamphlet_C_web.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/SBAhandbook-2025-ICT-C_Aug2023.pdf
Normal file
BIN
task1/_ref/SBAhandbook-2025-ICT-C_Aug2023.pdf
Normal file
Binary file not shown.
BIN
task1/_ref/WhatsApp Image 2024-08-17 at 10.41.42 AM.jpeg
Normal file
BIN
task1/_ref/WhatsApp Image 2024-08-17 at 10.41.42 AM.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
0
task1/_ref/notes.md
Normal file
0
task1/_ref/notes.md
Normal file
41
task1/_ref/py_original_GUI-main/Basic/button.py
Normal file
41
task1/_ref/py_original_GUI-main/Basic/button.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import tkinter
|
||||
|
||||
# ウィンドウの作成
|
||||
root = tkinter.Tk()
|
||||
root.title("Button practice")
|
||||
root.iconbitmap('icon.ico')
|
||||
root.geometry('550×550')
|
||||
root.resizable(0, 0) #サイズの変更禁止
|
||||
root.config(bg='red') #背景色
|
||||
|
||||
# ボタンの作成
|
||||
button_1 = tkinter.Button(root, text='ボタン1')
|
||||
button_1.grid(row=0, column=0)
|
||||
|
||||
button_2 = tkinter.Button(root, text='ボタン2')
|
||||
button_2.grid(row=0, column=1)
|
||||
|
||||
button_3 = tkinter.Button(root, text='ボタン3', bg='pink', activebackground='yellow')
|
||||
button_3.grid(row=0, column=2, padx=10, pady=10, ipadx=10, ipady=10)
|
||||
|
||||
button_4 = tkinter.Button(root, text='ボタン4', borderwidth=5)
|
||||
button_4.grid(row=1, column=0, columnspan=0, sticky='WE')
|
||||
|
||||
button_5 = tkinter.Button(root, text='テスト')
|
||||
button_6 = tkinter.Button(root, text='テスト')
|
||||
button_7 = tkinter.Button(root, text='テスト')
|
||||
button_8 = tkinter.Button(root, text='テスト')
|
||||
button_9 = tkinter.Button(root, text='テスト')
|
||||
button_10 = tkinter.Button(root, text='テスト')
|
||||
|
||||
button_5.grid(row=2, column=0, padx=5, pady=5)
|
||||
button_6.grid(row=2, column=1, padx=5, pady=5)
|
||||
button_7.grid(row=2, column=2, padx=5, pady=5, sticky='w')
|
||||
button_8.grid(row=3, column=0, padx=5, pady=5)
|
||||
button_9.grid(row=3, column=1, padx=5, pady=5)
|
||||
button_10.grid(row=3, column=2, padx=5, pady=5, sticky='w')
|
||||
|
||||
|
||||
|
||||
# ウィンドウのループ処理
|
||||
root.mainloop()
|
34
task1/_ref/py_original_GUI-main/Basic/frame.py
Normal file
34
task1/_ref/py_original_GUI-main/Basic/frame.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import tkinter
|
||||
|
||||
# ウィンドウの作成
|
||||
root = tkinter.Tk()
|
||||
root.title("Frame practice")
|
||||
root.iconbitmap('icon.ico')
|
||||
root.geometry('550×550')
|
||||
root.resizable(0, 0) #サイズの変更禁止
|
||||
|
||||
# なぜframeを使うのか?
|
||||
# tkinter.Label(root, text='test').pack()
|
||||
# tkinter.Button(root, text='test').grid(row=0, column=0)
|
||||
|
||||
# frameの作成
|
||||
frame_1 = tkinter.Frame(root, bg='yellow')
|
||||
frame_2 = tkinter.Frame(root, bg='green')
|
||||
frame_3 = tkinter.Label(root, text='ラベルフレームです', borderwidth=5)
|
||||
|
||||
# frameをroot上に配置
|
||||
frame_1.pack(fill='both', expand=True)
|
||||
frame_2.pack(fill='both', expand=True)
|
||||
frame_3.pack(fill='both', expand=True)
|
||||
|
||||
# ウィジェットの配置
|
||||
tkinter.Label(frame_1, text='test').pack()
|
||||
tkinter.Label(frame_1, text='test').pack()
|
||||
tkinter.Label(frame_1, text='test').pack()
|
||||
|
||||
tkinter.Label(frame_2, text='test').grid(row=0, column=0)
|
||||
tkinter.Label(frame_2, text='test').grid(row=1, column=1)
|
||||
tkinter.Label(frame_2, text='test').grid(row=2, column=2)
|
||||
|
||||
# ウィンドウのループ処理
|
||||
root.mainloop()
|
37
task1/_ref/py_original_GUI-main/Basic/label.py
Normal file
37
task1/_ref/py_original_GUI-main/Basic/label.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import tkinter
|
||||
import tkinter.font as font
|
||||
|
||||
# ウィンドウの作成
|
||||
root = tkinter.Tk()
|
||||
root.title("Label practice!")
|
||||
root.iconbitmap('icon.ico')
|
||||
root.geometry('550×550')
|
||||
root.resizable(0, 0) #サイズの変更禁止
|
||||
root.config(bg='red') #背景色
|
||||
|
||||
# ラベルの作成
|
||||
label_1 = tkinter.Label(root, text='宜しくお願いします')
|
||||
label_1.pack()
|
||||
|
||||
label_2 = tkinter.Label(root, text='宜しくお願いします', font=('Arial',10,'bold'))
|
||||
label_2.pack()
|
||||
|
||||
label_3 = tkinter.Label(root, text='宜しくお願いします', font=('Arial',10,'bold'), bg='gray')
|
||||
label_3.pack(padx=10, pady=10)
|
||||
|
||||
label_4 = tkinter.Label(root)
|
||||
label_4.config(text='宜しくお願いします')
|
||||
label_4.config(bg='gray')
|
||||
label_4.pack(padx=10, pady=10)
|
||||
|
||||
label_5 = tkinter.Label(root, text='宜しくお願いします', font=('Arial',10,'bold'), bg='gray', fg='green')
|
||||
label_5.pack(padx=10, pady=(0, 10), ipadx=10, ipady=10, anchor='w')
|
||||
|
||||
label_6 = tkinter.Label(root, text='宜しくお願いします', font=('Arial',10,'bold'), bg='gray', fg='green')
|
||||
label_6.pack(padx=10, pady=(0, 10), fill='w', expand=True)
|
||||
|
||||
#フォントの確認
|
||||
print(font.families())
|
||||
|
||||
# ウィンドウのループ処理
|
||||
root.mainloop()
|
18
task1/_ref/py_original_GUI-main/Basic/window.py
Normal file
18
task1/_ref/py_original_GUI-main/Basic/window.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import tkinter
|
||||
|
||||
# ウィンドウの作成
|
||||
root = tkinter.Tk()
|
||||
root.title('Window practice')
|
||||
root.iconbitmap('icon.ico')
|
||||
root.geometry('300×800')
|
||||
root.resizable(0, 0) #サイズの変更禁止
|
||||
root.config(bg='red') #背景色
|
||||
|
||||
# サブウィンドウの作成
|
||||
sub_window = tkinter.Toplevel()
|
||||
sub_window.title('Second Window')
|
||||
sub_window.config(bg='#123123')
|
||||
sub_window.geometry('200×300+500+500')
|
||||
|
||||
# ウィンドウのループ処理
|
||||
root.mainloop()
|
132
task1/_ref/py_original_GUI-main/sanmokunarabe/sanmoku.py
Normal file
132
task1/_ref/py_original_GUI-main/sanmokunarabe/sanmoku.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import tkinter
|
||||
import random
|
||||
import time
|
||||
|
||||
masu=[
|
||||
[0,0,0],
|
||||
[0,0,0],
|
||||
[0,0,0]
|
||||
]
|
||||
shirushi=0
|
||||
kachi=0
|
||||
FNT=("Times New Roman",60)
|
||||
def masume():
|
||||
# cvs.create_line(200,0,200,600,fill="gray", width=8) # 左の縦線
|
||||
# cvs.create_line(400,0,400,600,fill="gray", width=8) # 右の縦線
|
||||
# cvs.create_line(0,200,600,200,fill="gray", width=8) # 上の横線
|
||||
# cvs.create_line(0,400,600,400,fill="gray", width=8) # 下の横線
|
||||
|
||||
cvs.delete("all")
|
||||
# for文でマスを作成する
|
||||
for i in range(1,3):
|
||||
cvs.create_line(200*i,0,200*i,600,fill="gray",width=8)
|
||||
cvs.create_line(0,i*200,600,i*200,fill="gray",width=8)
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
X=x*200
|
||||
Y=y*200
|
||||
if masu[y][x]==1:
|
||||
cvs.create_oval(X+20,Y+20,X+180,Y+180,outline="blue",
|
||||
width=12)
|
||||
if masu[y][x]==2:
|
||||
cvs.create_line(X+20,Y+20,X+180,Y+180,fill="red",width=12)
|
||||
cvs.create_line(X+180,Y+20,X+20,Y+180,fill="red",width=12)
|
||||
if shirushi==0:
|
||||
cvs.create_text(300,300,text="スタート",fill="navy",font=FNT)
|
||||
cvs.update()
|
||||
|
||||
def click(e):
|
||||
global shirushi
|
||||
if shirushi==9:
|
||||
replay()
|
||||
return
|
||||
if shirushi==1 or shirushi==3 or shirushi==5 or shirushi==7:
|
||||
return
|
||||
|
||||
mx=int(e.x/200)
|
||||
my=int(e.y/200)
|
||||
if mx>2:mx=2
|
||||
if my>2:my=2
|
||||
if masu[my][mx]==0:
|
||||
masu[my][mx]=1
|
||||
shirushi=shirushi+1
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
if shirushi<9:
|
||||
computer()
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
|
||||
def computer():
|
||||
global shirushi
|
||||
# 3つ揃うマスがあるか
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
if masu[y][x]==0:
|
||||
masu[y][x]=2
|
||||
hantei()
|
||||
if kachi==2:
|
||||
shirushi=shirushi+1
|
||||
return
|
||||
masu[y][x]=0
|
||||
|
||||
def hantei():
|
||||
global kachi
|
||||
kachi = 0
|
||||
for n in range(1,3):
|
||||
# 縦に並んだかを判定する
|
||||
if masu[0][0]==n and masu[1][0]==n and masu[2][0]==n:
|
||||
kachi = n
|
||||
if masu[0][1]==n and masu[1][1]==n and masu[2][1]==n:
|
||||
kachi = n
|
||||
if masu[0][2]==n and masu[1][2]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
# 横に並んだかを判定する
|
||||
if masu[0][0]==n and masu[0][1]==n and masu[0][2]==n:
|
||||
kachi = n
|
||||
if masu[1][0]==n and masu[1][1]==n and masu[1][2]==n:
|
||||
kachi = n
|
||||
if masu[2][0]==n and masu[2][1]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
# 斜めに並んだかを判定する
|
||||
if masu[0][0]==n and masu[1][1]==n and masu[2][2]==n:
|
||||
kachi = n
|
||||
if masu[0][2]==n and masu[1][1]==n and masu[2][0]==n:
|
||||
kachi = n
|
||||
if kachi == 1:
|
||||
root.title(" ○ が3つ揃いました")
|
||||
if kachi == 2:
|
||||
root.title(" ✖️ が3つ揃いました")
|
||||
|
||||
def syouhai():
|
||||
global shirushi
|
||||
if kachi==1:
|
||||
cvs.create_text(300,300,text="あなたの勝ち",font=FNT,fill="cyan")
|
||||
shirushi=9
|
||||
if kachi==2:
|
||||
cvs.create_text(300,300,text="CPの勝ち",font=FNT,fill="gold")
|
||||
shirushi=9
|
||||
if kachi==0 and shirushi==9:
|
||||
cvs.create_text(300,300,text="引き分け",font=FNT,fill="lime")
|
||||
|
||||
def replay():
|
||||
global shirushi
|
||||
shirushi=0
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
masu[y][x]=0
|
||||
masume()
|
||||
|
||||
|
||||
root=tkinter.Tk()
|
||||
root.title("三目並べ")
|
||||
root.resizable(False, False) #サイズの変更禁止
|
||||
root.bind("<Button>",click)
|
||||
cvs=tkinter.Canvas(width=600,height=600,bg="white")
|
||||
cvs.pack()
|
||||
masume()
|
||||
root.mainloop()
|
BIN
task1/_ref/校本評核簡介.pdf
Normal file
BIN
task1/_ref/校本評核簡介.pdf
Normal file
Binary file not shown.
63
task1/backup.js
Normal file
63
task1/backup.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const execSync = require('child_process').execSync;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
// const chalk = require('chalk');
|
||||
|
||||
// Function to get all subdirectories of a given directory
|
||||
function getDirectories(srcPath, excludeDirs) {
|
||||
return fs
|
||||
.readdirSync(srcPath)
|
||||
.filter(file => !excludeDirs.includes(file) && fs.lstatSync(path.join(srcPath, file)).isDirectory())
|
||||
.map(name => path.join(srcPath, name));
|
||||
}
|
||||
|
||||
// Get current working directory
|
||||
const cwd = process.cwd();
|
||||
const backup_dir = path.join(cwd, '_backup');
|
||||
|
||||
// Path to app-head directory
|
||||
const appHeadDir = path.join(cwd, 'src');
|
||||
|
||||
// Check if app-head exists
|
||||
if (!fs.existsSync(appHeadDir)) {
|
||||
console.error(`Error: ${appHeadDir} does not exist.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Execute reset.bat scripts
|
||||
try {
|
||||
// execSync(`cmd /c "cd ${appHeadDir} && scripts\\reset.bat"`, { stdio: 'inherit' });
|
||||
} catch (err) {
|
||||
console.error(`Error executing reset.bat script: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Define excluded directories
|
||||
const excludedDirs = ['.next', 'node_modules', '.git', 'volumes', '_mp4'];
|
||||
|
||||
// Copy app-head directory and its contents to a new directory with an increasing number suffix
|
||||
let maxNum = 0;
|
||||
const directories = getDirectories(backup_dir, excludedDirs);
|
||||
for (const dir of directories) {
|
||||
const match = dir.match(/^.+draft-(\d+).*$/);
|
||||
if (match) {
|
||||
const num = parseInt(match[1], 10);
|
||||
if (num > maxNum) {
|
||||
maxNum = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var zerofilled = ('0000' + (maxNum + 1)).slice(-4);
|
||||
const targetDir = path.join(backup_dir, `draft-${zerofilled}`);
|
||||
fs.mkdirSync(targetDir);
|
||||
|
||||
// Copy app-head directory and its contents to targetDir, excluding specified directories
|
||||
fs.cpSync(appHeadDir, targetDir, {
|
||||
filter: src => !excludedDirs.includes(path.basename(src)),
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
console.log(' DONE DONE DONE \n' + ' DONE DONE DONE \n' + ' DONE DONE DONE \n');
|
||||
|
||||
console.log(`Successfully backup to ${targetDir}.`);
|
6
task1/check_todo.sh
Executable file
6
task1/check_todo.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
grep -ri todo src
|
||||
grep -ri llaw src
|
10
task1/gitUpdate.sh
Executable file
10
task1/gitUpdate.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
git add .
|
||||
git commit -m"update jktjoeaj703,"
|
||||
|
||||
# git push
|
||||
|
||||
echo "done"
|
39
task1/notes.md
Normal file
39
task1/notes.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
tags: sba, hkdse, python,
|
||||
---
|
||||
|
||||
- Player I vs Player 2
|
||||
- Player I vs Computer
|
||||
- The program can check who wins the game
|
||||
你已經做左 ?
|
||||
|
||||
- handling old code +2
|
||||
- Players can enter/edit/delete their names in the game +2
|
||||
- The player record can be saved in a txt/csv file +2 (save record in txt/csv file)
|
||||
- The game displays the records of all players +2
|
||||
你想我幫手 ?
|
||||
|
||||
- 想要有 username password 嘅 login, +0.5
|
||||
- logout (included in login)
|
||||
- 同埋佢哋係可以改 Password, +0.5
|
||||
- 有個掣可以 display record
|
||||
|
||||
### dev environment ?
|
||||
|
||||
it should be windows + python
|
||||
|
||||
```bash
|
||||
pyenv deactivate
|
||||
pyenv uninstall -f jktjoeaj703
|
||||
pyenv virtualenv 3.9 jktjoeaj703
|
||||
pyenv activate jktjoeaj703
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
# references
|
||||
|
||||
https://github.com/kitou88C39/py_original_GUI/tree/main
|
||||
https://www.hkeaa.edu.hk/en/hkdse/assessment/assessment_framework/
|
||||
|
||||
|
BIN
task1/notes_1_i want to delete this line.png
(Stored with Git LFS)
Normal file
BIN
task1/notes_1_i want to delete this line.png
(Stored with Git LFS)
Normal file
Binary file not shown.
557
task1/pylintrc
Normal file
557
task1/pylintrc
Normal file
@@ -0,0 +1,557 @@
|
||||
[MAIN]
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
#init-hook=
|
||||
|
||||
# Files or directories to be skipped. They should be base names, not
|
||||
# paths.
|
||||
ignore=CVS
|
||||
|
||||
# Add files or directories matching the regex patterns to the ignore-list. The
|
||||
# regex matches against paths and can be in Posix or Windows format.
|
||||
ignore-paths=
|
||||
|
||||
# Files or directories matching the regex patterns are skipped. The regex
|
||||
# matches against base names, not paths.
|
||||
ignore-patterns=^\.#
|
||||
|
||||
# Pickle collected data for later comparisons.
|
||||
persistent=yes
|
||||
|
||||
# List of plugins (as comma separated values of python modules names) to load,
|
||||
# usually to register additional checkers.
|
||||
load-plugins=
|
||||
pylint.extensions.check_elif,
|
||||
pylint.extensions.bad_builtin,
|
||||
pylint.extensions.docparams,
|
||||
pylint.extensions.for_any_all,
|
||||
pylint.extensions.set_membership,
|
||||
pylint.extensions.code_style,
|
||||
pylint.extensions.overlapping_exceptions,
|
||||
pylint.extensions.typing,
|
||||
pylint.extensions.redefined_variable_type,
|
||||
pylint.extensions.comparison_placement,
|
||||
pylint.extensions.broad_try_clause,
|
||||
pylint.extensions.dict_init_mutate,
|
||||
pylint.extensions.consider_refactoring_into_while_condition,
|
||||
|
||||
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
|
||||
# number of processors available to use.
|
||||
jobs=6
|
||||
|
||||
# When enabled, pylint would attempt to guess common misconfiguration and emit
|
||||
# user-friendly hints instead of false-positive error messages.
|
||||
suggestion-mode=yes
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
unsafe-load-any-extension=no
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code
|
||||
extension-pkg-allow-list=
|
||||
|
||||
# Minimum supported python version
|
||||
py-version = 3.9.0
|
||||
|
||||
# Control the amount of potential inferred values when inferring a single
|
||||
# object. This can help the performance when dealing with large functions or
|
||||
# complex, nested conditions.
|
||||
limit-inference-results=100
|
||||
|
||||
# Specify a score threshold under which the program will exit with error.
|
||||
fail-under=10.0
|
||||
|
||||
# Return non-zero exit code if any of these messages/categories are detected,
|
||||
# even if score is above --fail-under value. Syntax same as enable. Messages
|
||||
# specified are enabled, while categories only check already-enabled messages.
|
||||
fail-on=
|
||||
|
||||
# Clear in-memory caches upon conclusion of linting. Useful if running pylint in
|
||||
# a server-like mode.
|
||||
clear-cache-post-run=no
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
# confidence=
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
# multiple time (only on the command line, not in the configuration file where
|
||||
# it should appear only once). See also the "--disable" option for examples.
|
||||
enable=
|
||||
use-symbolic-message-instead,
|
||||
useless-suppression,
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s). You
|
||||
# can either give multiple identifiers separated by comma (,) or put this
|
||||
# option multiple times (only on the command line, not in the configuration
|
||||
# file where it should appear only once).You can also use "--disable=all" to
|
||||
# disable everything first and then re-enable specific checks. For example, if
|
||||
# you want to run only the similarities checker, you can use "--disable=all
|
||||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
|
||||
disable=
|
||||
attribute-defined-outside-init,
|
||||
invalid-name,
|
||||
missing-docstring,
|
||||
protected-access,
|
||||
too-few-public-methods,
|
||||
# handled by black
|
||||
format,
|
||||
# We anticipate #3512 where it will become optional
|
||||
fixme,
|
||||
consider-using-assignment-expr,
|
||||
E0015,
|
||||
E0307,
|
||||
W0401,
|
||||
W0718,
|
||||
W0717,
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Set the output format. Available formats are text, parseable, colorized, msvs
|
||||
# (visual studio) and html. You can also give a reporter class, eg
|
||||
# mypackage.mymodule.MyReporterClass.
|
||||
output-format=text
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=no
|
||||
|
||||
# Python expression which should return a note less than 10 (10 is the highest
|
||||
# note). You have access to the variables 'fatal', 'error', 'warning', 'refactor', 'convention'
|
||||
# and 'info', which contain the number of messages in each category, as
|
||||
# well as 'statement', which is the total number of statements analyzed. This
|
||||
# score is used by the global evaluation report (RP0004).
|
||||
evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))
|
||||
|
||||
# Template used to display messages. This is a python new-style format string
|
||||
# used to format the message information. See doc for all details
|
||||
#msg-template=
|
||||
|
||||
# Activate the evaluation score.
|
||||
score=yes
|
||||
|
||||
|
||||
[LOGGING]
|
||||
|
||||
# Logging modules to check that the string format arguments are in logging
|
||||
# function parameter format
|
||||
logging-modules=logging
|
||||
|
||||
# The type of string formatting that logging methods do. `old` means using %
|
||||
# formatting, `new` is for `{}` formatting.
|
||||
logging-format-style=old
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
|
||||
# Regular expression of note tags to take in consideration.
|
||||
#notes-rgx=
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=6
|
||||
|
||||
# Ignore comments when computing similarities.
|
||||
ignore-comments=yes
|
||||
|
||||
# Ignore docstrings when computing similarities.
|
||||
ignore-docstrings=yes
|
||||
|
||||
# Ignore imports when computing similarities.
|
||||
ignore-imports=yes
|
||||
|
||||
# Signatures are removed from the similarity computation
|
||||
ignore-signatures=yes
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid defining new builtins when possible.
|
||||
additional-builtins=
|
||||
|
||||
# List of strings which can identify a callback function by name. A callback
|
||||
# name must start or end with one of those strings.
|
||||
callbacks=cb_,_cb
|
||||
|
||||
# Tells whether unused global variables should be treated as a violation.
|
||||
allow-global-unused-variables=yes
|
||||
|
||||
# List of names allowed to shadow builtins
|
||||
allowed-redefined-builtins=
|
||||
|
||||
# List of qualified module names which can have objects that can redefine
|
||||
# builtins.
|
||||
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=100
|
||||
|
||||
# Regexp for a line that is allowed to be longer than the limit.
|
||||
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||
|
||||
# Allow the body of an if to be on the same line as the test if there is no
|
||||
# else.
|
||||
single-line-if-stmt=no
|
||||
|
||||
# Allow the body of a class to be on the same line as the declaration if body
|
||||
# contains single statement.
|
||||
single-line-class-stmt=no
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=2000
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
indent-string=' '
|
||||
|
||||
# Number of spaces of indent required inside a hanging or continued line.
|
||||
indent-after-paren=4
|
||||
|
||||
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||
expected-line-ending-format=
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names=i,j,k,ex,Run,_
|
||||
|
||||
# Good variable names regexes, separated by a comma. If names match any regex,
|
||||
# they will always be accepted
|
||||
good-names-rgxs=
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
||||
# Bad variable names regexes, separated by a comma. If names match any regex,
|
||||
# they will always be refused
|
||||
bad-names-rgxs=
|
||||
|
||||
# Colon-delimited sets of names that determine each other's naming style when
|
||||
# the name regexes allow several styles.
|
||||
name-group=
|
||||
|
||||
# Include a hint for the correct naming format with invalid-name
|
||||
include-naming-hint=no
|
||||
|
||||
# Naming style matching correct function names.
|
||||
function-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct function names
|
||||
function-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming style matching correct variable names.
|
||||
variable-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct variable names
|
||||
variable-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming style matching correct constant names.
|
||||
const-naming-style=UPPER_CASE
|
||||
|
||||
# Regular expression matching correct constant names
|
||||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Naming style matching correct attribute names.
|
||||
attr-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct attribute names
|
||||
attr-rgx=[a-z_][a-z0-9_]{2,}$
|
||||
|
||||
# Naming style matching correct argument names.
|
||||
argument-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct argument names
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming style matching correct class attribute names.
|
||||
class-attribute-naming-style=any
|
||||
|
||||
# Regular expression matching correct class attribute names
|
||||
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Naming style matching correct class constant names.
|
||||
class-const-naming-style=UPPER_CASE
|
||||
|
||||
# Regular expression matching correct class constant names. Overrides class-
|
||||
# const-naming-style.
|
||||
#class-const-rgx=
|
||||
|
||||
# Naming style matching correct inline iteration names.
|
||||
inlinevar-naming-style=any
|
||||
|
||||
# Regular expression matching correct inline iteration names
|
||||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Naming style matching correct class names.
|
||||
class-naming-style=PascalCase
|
||||
|
||||
# Regular expression matching correct class names
|
||||
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
|
||||
# Naming style matching correct module names.
|
||||
module-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct module names
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
|
||||
# Naming style matching correct method names.
|
||||
method-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct method names
|
||||
method-rgx=[a-z_][a-z0-9_]{2,}$
|
||||
|
||||
# Regular expression matching correct type variable names
|
||||
#typevar-rgx=
|
||||
|
||||
# Regular expression which should only match function or class names that do
|
||||
# not require a docstring. Use ^(?!__init__$)_ to also check __init__.
|
||||
no-docstring-rgx=__.*__
|
||||
|
||||
# Minimum line length for functions/classes that require docstrings, shorter
|
||||
# ones are exempt.
|
||||
docstring-min-length=-1
|
||||
|
||||
# List of decorators that define properties, such as abc.abstractproperty.
|
||||
property-classes=abc.abstractproperty
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# Regex pattern to define which classes are considered mixins if ignore-mixin-
|
||||
# members is set to 'yes'
|
||||
mixin-class-rgx=.*MixIn
|
||||
|
||||
# List of module names for which member attributes should not be checked and
|
||||
# will not be imported (useful for modules/projects where namespaces are
|
||||
# manipulated during runtime and thus existing member attributes cannot be
|
||||
# deduced by static analysis). It supports qualified module names, as well
|
||||
# as Unix pattern matching.
|
||||
ignored-modules=
|
||||
|
||||
# List of class names for which member attributes should not be checked (useful
|
||||
# for classes with dynamically set attributes). This supports the use of
|
||||
# qualified names.
|
||||
ignored-classes=SQLObject, optparse.Values, thread._local, _thread._local
|
||||
|
||||
# List of members which are set dynamically and missed by pylint inference
|
||||
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||
# expressions are accepted.
|
||||
generated-members=REQUEST,acl_users,aq_parent,argparse.Namespace,Question,Album,Song,Choice,Musicmanageruser,album,song
|
||||
|
||||
# List of decorators that create context managers from functions, such as
|
||||
# contextlib.contextmanager.
|
||||
contextmanager-decorators=contextlib.contextmanager
|
||||
|
||||
# Tells whether to warn about missing members when the owner of the attribute
|
||||
# is inferred to be None.
|
||||
ignore-none=yes
|
||||
|
||||
# This flag controls whether pylint should warn about no-member and similar
|
||||
# checks whenever an opaque object is returned when inferring. The inference
|
||||
# can return multiple potential results while evaluating a Python object, but
|
||||
# some branches might not be evaluated, which results in partial inference. In
|
||||
# that case, it might be useful to still emit no-member and other checks for
|
||||
# the rest of the inferred objects.
|
||||
ignore-on-opaque-inference=yes
|
||||
|
||||
# Show a hint with possible names when a member name was not found. The aspect
|
||||
# of finding the hint is based on edit distance.
|
||||
missing-member-hint=yes
|
||||
|
||||
# The minimum edit distance a name should have in order to be considered a
|
||||
# similar match for a missing member name.
|
||||
missing-member-hint-distance=1
|
||||
|
||||
# The total number of similar names that should be taken in consideration when
|
||||
# showing a hint for a missing member.
|
||||
missing-member-max-choices=1
|
||||
|
||||
[SPELLING]
|
||||
|
||||
# Spelling dictionary name. Available dictionaries: none. To make it working
|
||||
# install python-enchant package.
|
||||
spelling-dict=
|
||||
|
||||
# List of comma separated words that should not be checked.
|
||||
spelling-ignore-words=
|
||||
|
||||
# List of comma separated words that should be considered directives if they
|
||||
# appear and the beginning of a comment and should not be checked.
|
||||
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:,pragma:,# noinspection
|
||||
|
||||
# A path to a file that contains private dictionary; one word per line.
|
||||
spelling-private-dict-file=custom_dict.txt
|
||||
|
||||
# Tells whether to store unknown words to indicated private dictionary in
|
||||
# --spelling-private-dict-file option instead of raising a message.
|
||||
spelling-store-unknown-words=no
|
||||
|
||||
# Limits count of emitted suggestions for spelling mistakes.
|
||||
max-spelling-suggestions=2
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args = 9
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals = 19
|
||||
|
||||
# Maximum number of return / yield for function / method body
|
||||
max-returns=11
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches = 20
|
||||
|
||||
# Maximum number of statements in function / method body
|
||||
max-statements = 50
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
max-attributes=11
|
||||
|
||||
# Maximum number of statements in a try-block
|
||||
max-try-statements = 7
|
||||
|
||||
# Maximum number of positional arguments (see R0917).
|
||||
max-positional-arguments = 12
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,__new__,setUp,__post_init__
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
# List of valid names for the first argument in a metaclass class method.
|
||||
valid-metaclass-classmethod-first-arg=mcs
|
||||
|
||||
# List of member names, which should be excluded from the protected access
|
||||
# warning.
|
||||
exclude-protected=_asdict,_fields,_replace,_source,_make
|
||||
|
||||
# Warn about protected attribute access inside special methods
|
||||
check-protected-access-in-special-methods=no
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# List of modules that can be imported at any level, not just the top level
|
||||
# one.
|
||||
allow-any-import-level=
|
||||
|
||||
# Allow wildcard imports from modules that define __all__.
|
||||
allow-wildcard-with-all=no
|
||||
|
||||
# Allow explicit reexports by alias from a package __init__.
|
||||
allow-reexport-from-package=no
|
||||
|
||||
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||
# 3 compatible code, which means that the block might have code that exists
|
||||
# only in one or another interpreter, leading to false positives when analysed.
|
||||
analyse-fallback-blocks=no
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=regsub,TERMIOS,Bastion,rexec
|
||||
|
||||
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||
# given file (report RP0402 must not be disabled)
|
||||
import-graph=
|
||||
|
||||
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
ext-import-graph=
|
||||
|
||||
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
int-import-graph=
|
||||
|
||||
# Force import order to recognize a module as part of the standard
|
||||
# compatibility libraries.
|
||||
known-standard-library=_string
|
||||
|
||||
# Force import order to recognize a module as part of a third party library.
|
||||
known-third-party=enchant
|
||||
|
||||
# Couples of modules and preferred modules, separated by a comma.
|
||||
preferred-modules=
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "Exception"
|
||||
overgeneral-exceptions=builtins.Exception
|
||||
|
||||
|
||||
[TYPING]
|
||||
|
||||
# Set to ``no`` if the app / library does **NOT** need to support runtime
|
||||
# introspection of type annotations. If you use type annotations
|
||||
# **exclusively** for type checking of an application, you're probably fine.
|
||||
# For libraries, evaluate if some users what to access the type hints at
|
||||
# runtime first, e.g., through ``typing.get_type_hints``. Applies to Python
|
||||
# versions 3.7 - 3.9
|
||||
runtime-typing = no
|
||||
|
||||
|
||||
[DEPRECATED_BUILTINS]
|
||||
|
||||
# List of builtins function names that should not be used, separated by a comma
|
||||
bad-functions=map,input
|
||||
|
||||
|
||||
[REFACTORING]
|
||||
|
||||
# Maximum number of nested blocks for function / method body
|
||||
max-nested-blocks=5
|
||||
|
||||
# Complete name of functions that never returns. When checking for
|
||||
# inconsistent-return-statements if a never returning function is called then
|
||||
# it will be considered as an explicit return statement and no message will be
|
||||
# printed.
|
||||
never-returning-functions=sys.exit,argparse.parse_error
|
||||
|
||||
|
||||
[STRING]
|
||||
|
||||
# This flag controls whether inconsistent-quotes generates a warning when the
|
||||
# character used as a quote delimiter is used inconsistently within a module.
|
||||
check-quote-consistency=no
|
||||
|
||||
# This flag controls whether the implicit-str-concat should generate a warning
|
||||
# on implicit string concatenation in sequences defined over several lines.
|
||||
check-str-concat-over-line-jumps=no
|
||||
|
||||
|
||||
[CODE_STYLE]
|
||||
|
||||
# Max line length for which to sill emit suggestions. Used to prevent optional
|
||||
# suggestions which would get split by a code formatter (e.g., black). Will
|
||||
# default to the setting for ``max-line-length``.
|
||||
#max-line-length-suggestions=
|
10
task1/src/db/ac.txt
Normal file
10
task1/src/db/ac.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Peter:Aa1234567
|
||||
Mary:Aa1234567
|
||||
David:Aa1234567
|
||||
s:2
|
||||
Tom:Aa1234567
|
||||
Susan:Aa1234567
|
||||
a:3
|
||||
b:1
|
||||
ttt:111
|
||||
d:4
|
10
task1/src/db/ranking.csv
Normal file
10
task1/src/db/ranking.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
player_name,win,lose,tie
|
||||
June,1,345,999
|
||||
Tom,3,3,5
|
||||
Susan,999,6,4
|
||||
Peter,4,4,6
|
||||
Sam,999,6,4
|
||||
t,8,6,23
|
||||
s,1,6,2
|
||||
a,2,1,1
|
||||
Mary,0,1,0
|
|
7
task1/src/journal.md
Normal file
7
task1/src/journal.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# 外部 code/日文 code:
|
||||
|
||||
- tic_tac_toe_haman_vs_pc.py
|
||||
- user_vs_user_final.py
|
||||
|
||||
應該講成為參考其他人 code.
|
||||
到最後如果唔想咁做,我可以幫你改 variable 名
|
1222
task1/src/main.py
Normal file
1222
task1/src/main.py
Normal file
File diff suppressed because it is too large
Load Diff
5
task1/src/run.sh
Executable file
5
task1/src/run.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
python ./main.py
|
158
task1/src/tic_tac_toe_haman_vs_pc.py
Normal file
158
task1/src/tic_tac_toe_haman_vs_pc.py
Normal file
@@ -0,0 +1,158 @@
|
||||
"""Hello World application for Tkinter"""
|
||||
|
||||
import tkinter
|
||||
import random
|
||||
import time
|
||||
from tkinter.ttk import *
|
||||
|
||||
masu = [
|
||||
[0, 0, 0],
|
||||
[0, 0, 0],
|
||||
[0, 0, 0]
|
||||
]
|
||||
shirushi = 0
|
||||
kachi = 0
|
||||
FNT = ("Times New Roman", 60)
|
||||
|
||||
|
||||
def masume():
|
||||
cvs.delete("all")
|
||||
for i in range(1, 3):
|
||||
cvs.create_line(200*i, 0, 200*i, 600, fill="gray", width=8)
|
||||
cvs.create_line(0, i*200, 600, i*200, fill="gray", width=8)
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
X = x * 200
|
||||
Y = y * 200
|
||||
if masu[y][x] == 1:
|
||||
cvs.create_oval(X+20, Y+20, X+180, Y+180,
|
||||
outline="blue", width=12)
|
||||
if masu[y][x] == 2:
|
||||
cvs.create_line(X+20, Y+20, X+180, Y+180, fill="red", width=12)
|
||||
cvs.create_line(X+180, Y+20, X+20, Y+180, fill="red", width=12)
|
||||
if shirushi == 0:
|
||||
cvs.create_text(300, 300, text="遊戲開始!", fill="navy", font=FNT)
|
||||
cvs.update()
|
||||
|
||||
|
||||
def click(e):
|
||||
global shirushi
|
||||
if shirushi == 9:
|
||||
replay()
|
||||
return
|
||||
if shirushi == 1 or shirushi == 3 or shirushi == 5 or shirushi == 7:
|
||||
return
|
||||
mx = int(e.x/200)
|
||||
my = int(e.y/200)
|
||||
if mx > 2:
|
||||
mx = 2
|
||||
if my > 2:
|
||||
my = 2
|
||||
if masu[my][mx] == 0:
|
||||
masu[my][mx] = 1
|
||||
shirushi = shirushi + 1
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
if shirushi < 9:
|
||||
computer()
|
||||
masume()
|
||||
time.sleep(0.5)
|
||||
hantei()
|
||||
syouhai()
|
||||
|
||||
|
||||
def computer():
|
||||
global shirushi
|
||||
# 有沒有連成一線的符號
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 2
|
||||
hantei()
|
||||
if kachi == 2:
|
||||
shirushi = shirushi + 1
|
||||
return
|
||||
masu[y][x] = 0
|
||||
# 阻止玩家連成一線
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 1
|
||||
hantei()
|
||||
if kachi == 1:
|
||||
masu[y][x] = 2
|
||||
shirushi = shirushi + 1
|
||||
return
|
||||
masu[y][x] = 0
|
||||
while True:
|
||||
x = random.randint(0, 2)
|
||||
y = random.randint(0, 2)
|
||||
if masu[y][x] == 0:
|
||||
masu[y][x] = 2
|
||||
shirushi = shirushi + 1
|
||||
break
|
||||
|
||||
|
||||
def hantei():
|
||||
global kachi
|
||||
kachi = 0
|
||||
for n in range(1, 3):
|
||||
# 判斷垂直方向是否連成一線
|
||||
if masu[0][0] == n and masu[1][0] == n and masu[2][0] == n:
|
||||
kachi = n
|
||||
if masu[0][1] == n and masu[1][1] == n and masu[2][1] == n:
|
||||
kachi = n
|
||||
if masu[0][2] == n and masu[1][2] == n and masu[2][2] == n:
|
||||
kachi = n
|
||||
# 判斷水平方向是否連成一線
|
||||
if masu[0][0] == n and masu[0][1] == n and masu[0][2] == n:
|
||||
kachi = n
|
||||
if masu[1][0] == n and masu[1][1] == n and masu[1][2] == n:
|
||||
kachi = n
|
||||
if masu[2][0] == n and masu[2][1] == n and masu[2][2] == n:
|
||||
kachi = n
|
||||
# 判斷傾斜方向是否連成一線
|
||||
if masu[0][0] == n and masu[1][1] == n and masu[2][2] == n:
|
||||
kachi = n
|
||||
if masu[0][2] == n and masu[1][1] == n and masu[2][0] == n:
|
||||
kachi = n
|
||||
|
||||
|
||||
def syouhai():
|
||||
global shirushi
|
||||
if kachi == 1:
|
||||
cvs.create_text(300, 300, text="玩家獲勝!", font=FNT, fill="cyan")
|
||||
shirushi = 9
|
||||
if kachi == 2:
|
||||
cvs.create_text(300, 300, text="電腦\n獲勝!", font=FNT, fill="gold")
|
||||
shirushi = 9
|
||||
if kachi == 0 and shirushi == 9:
|
||||
cvs.create_text(300, 300, text="平手", font=FNT, fill="lime")
|
||||
|
||||
|
||||
def replay():
|
||||
global shirushi
|
||||
shirushi = 0
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
masu[y][x] = 0
|
||||
masume()
|
||||
|
||||
|
||||
root = tkinter.Tk()
|
||||
|
||||
root.title("井字遊戲")
|
||||
# label = Label(root, text="井字遊戲")
|
||||
# label.pack()
|
||||
|
||||
root.resizable(False, False)
|
||||
root.bind("<Button>", click)
|
||||
cvs = tkinter.Canvas(width=600, height=600, bg="white")
|
||||
cvs.pack()
|
||||
masume()
|
||||
|
||||
root.mainloop()
|
||||
|
||||
print("helloworl1d")
|
124
task1/src/user_vs_user_final.py
Normal file
124
task1/src/user_vs_user_final.py
Normal file
@@ -0,0 +1,124 @@
|
||||
import tkinter
|
||||
|
||||
from tkinter import *
|
||||
from tkinter.ttk import *
|
||||
|
||||
player1 = 1
|
||||
player2 = 2
|
||||
current_player = player1
|
||||
shirushi = 0
|
||||
|
||||
masu = [
|
||||
[0, 0, 0],
|
||||
[0, 0, 0],
|
||||
[0, 0, 0]
|
||||
]
|
||||
|
||||
|
||||
|
||||
def masume():
|
||||
global cvs
|
||||
cvs.delete("all")
|
||||
cvs.create_line(200, 0, 200, 600, fill="black", width=8)
|
||||
cvs.create_line(400, 0, 400, 600, fill="black", width=8)
|
||||
cvs.create_line(0, 200, 600, 200, fill="black", width=8)
|
||||
cvs.create_line(0, 400, 600, 400, fill="black", width=8)
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
X = x * 200
|
||||
Y = y * 200
|
||||
if masu[y][x] == 1:
|
||||
cvs.create_oval(X + 20, Y + 20, X + 180, Y + 180, outline="blue", width=12)
|
||||
if masu[y][x] == 2:
|
||||
cvs.create_line(X + 20, Y + 20, X + 180, Y + 180, fill="red", width=12)
|
||||
cvs.create_line(X + 180, Y + 20, X + 20, Y + 180, fill="red", width=12)
|
||||
cvs.update()
|
||||
|
||||
def click(e):
|
||||
global current_player, shirushi
|
||||
if shirushi == 9:
|
||||
replay()
|
||||
return
|
||||
if shirushi == 1 or shirushi == 3 or shirushi == 5 or shirushi == 7:
|
||||
return
|
||||
mx = int(e.x / 200)
|
||||
my = int(e.y / 200)
|
||||
if mx > 2:
|
||||
mx = 2
|
||||
if my > 2:
|
||||
my = 2
|
||||
if masu[my][mx] == 0:
|
||||
masu[my][mx] = current_player
|
||||
winner = check_winner()
|
||||
if winner != 0 or shirushi == 8:
|
||||
shirushi = 9
|
||||
else:
|
||||
# Switch players
|
||||
if current_player == player1:
|
||||
current_player = player2
|
||||
else:
|
||||
current_player = player1
|
||||
masume()
|
||||
syouhai()
|
||||
|
||||
|
||||
def check_winner():
|
||||
# Check rows
|
||||
for row in masu:
|
||||
if row[0] == row[1] == row[2] != 0:
|
||||
return row[0]
|
||||
|
||||
# Check columns
|
||||
for col in range(3):
|
||||
if masu[0][col] == masu[1][col] == masu[2][col] != 0:
|
||||
return masu[0][col]
|
||||
|
||||
# Check diagonals
|
||||
if masu[0][0] == masu[1][1] == masu[2][2] != 0:
|
||||
return masu[0][0]
|
||||
if masu[0][2] == masu[1][1] == masu[2][0] != 0:
|
||||
return masu[0][2]
|
||||
|
||||
# Check if all cells are filled (tie)
|
||||
if all(row.count(0) == 0 for row in masu):
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def syouhai():
|
||||
global shirushi
|
||||
winner = check_winner()
|
||||
if winner == player1:
|
||||
cvs.create_text(300, 300, text="Player 1 wins!", font=("Arial", 36), fill="cyan")
|
||||
shirushi = 9
|
||||
elif winner == player2:
|
||||
cvs.create_text(300, 300, text="Player 2 wins!", font=("Arial", 36), fill="gold")
|
||||
shirushi = 9
|
||||
elif winner == -1:
|
||||
cvs.create_text(300, 300, text="Tie", font=("Arial", 36), fill="lime")
|
||||
shirushi = 9
|
||||
|
||||
def replay():
|
||||
global shirushi
|
||||
shirushi = 0
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
masu[y][x] = 0
|
||||
masume()
|
||||
|
||||
root = Tk()
|
||||
|
||||
label = Label(root, text="Hello World")
|
||||
label.pack()
|
||||
|
||||
root.title("井字遊戲")
|
||||
# label = Label(root, text="井字遊戲")
|
||||
# label.pack()
|
||||
|
||||
root.resizable(False, False)
|
||||
root.bind("<Button>", click)
|
||||
cvs = tkinter.Canvas(width=600, height=600, bg="white")
|
||||
cvs.pack()
|
||||
masume()
|
||||
|
||||
|
||||
root.mainloop()
|
Reference in New Issue
Block a user