2lambda123 / huawei-noah-xingtian

MIT License
0 stars 0 forks source link

Added Chinese Chess Environment, Utility Functions, and Nash Battle Worker Module #1

Closed 2lambda123 closed 6 months ago

2lambda123 commented 6 months ago

User description

Description

Related Issue

Types of changes

Checklist:


Description


Changes walkthrough 📝

Relevant files
Enhancement
cchess_env.py
Added Chinese Chess Environment and Utility Functions       

examples/chinese_chess/env/cchess_env.py ['Added a new class `CchessEnv` with various methods for Chinese chess environment.', 'Added functions for creating UCI labels and position labels.', 'Added a new class `BaseChessBoard` with methods for initializing, copying, putting pieces, and moving pieces on the board.', 'Added functions for creating position labels and labels for legal moves.', 'Added a new class `Pos` for representing positions on the board.', 'Added a new class `ChessSide` with methods for handling different sides in the game.']
+889/-0 
nash_evaluate_worker.py
Added Nash Battle Worker Module                                                   

examples/chinese_chess/nash_evaluate_worker.py ['Added a new module for Nash battle worker in Chinese chess.', 'Implemented functions for setting up players, playing till the end, and conducting Nash battles.', 'Added a new class `IcyPlayer` for handling player actions and interactions.', 'Implemented functions for getting models to battle and performing Nash battles.']
+358/-0 
__init__.py
Imported Exchanger and Trainer Classes                                     

examples/chinese_chess/server/__init__.py ['Imported `Exchanger` and `Trainer` classes from the `server` module.']
+2/-0     
performance-testing-bot[bot] commented 6 months ago

Unable to locate .performanceTestingBot config file

cr-gpt[bot] commented 6 months ago

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

code-companion-ai[bot] commented 6 months ago

Processing PR updates...

git-greetings[bot] commented 6 months ago

Thanks @2lambda123 for opening this PR!

For COLLABORATOR only :

quine-bot[bot] commented 6 months ago

👋 Figuring out if a PR is useful is hard, hopefully this will help.

  • @2lambda123 has been on GitHub since 2019 and in that time has had 2267 public PRs merged
  • They haven't contributed to this repo before
  • Here's a good example of their work: HeyGenClone
  • From looking at their profile, they seem to be good with Shell and Python.

Their most recently public accepted PR is: https://github.com/2lambda123/-inbarhub-DDPM_inversion/pull/2

codeautopilot[bot] commented 6 months ago

Your organization has reached the subscribed usage limit. You can upgrade your account by purchasing a subscription at Stripe payment link

git-greetings[bot] commented 6 months ago

First PR by @2lambda123

PR Details of @2lambda123 in huawei-noah-xingtian : OPEN CLOSED TOTAL
1 0 1
coderabbitai[bot] commented 6 months ago

[!WARNING]

Rate limit exceeded

@2lambda123 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 32 minutes and 53 seconds before requesting another review.

How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
Commits Files that changed from the base of the PR and between e4ef3a1c92d19d1d08c3ef0e2156b6fecefdbe04 and 5845b8c2941deb47caa9a4de9d5bf0a897123728.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
pep8speaks commented 6 months ago

Hello @2lambda123! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 35:69: W291 trailing whitespace Line 41:80: E501 line too long (83 > 79 characters) Line 53:80: E501 line too long (98 > 79 characters) Line 55:80: E501 line too long (98 > 79 characters) Line 59:80: E501 line too long (101 > 79 characters) Line 134:1: W293 blank line contains whitespace Line 138:1: W293 blank line contains whitespace Line 167:1: W293 blank line contains whitespace Line 173:80: E501 line too long (118 > 79 characters) Line 182:23: W291 trailing whitespace Line 243:80: E501 line too long (90 > 79 characters) Line 262:80: E501 line too long (106 > 79 characters)

Line 41:1: W293 blank line contains whitespace Line 45:1: W293 blank line contains whitespace Line 96:1: W293 blank line contains whitespace Line 104:80: E501 line too long (80 > 79 characters) Line 111:80: E501 line too long (83 > 79 characters) Line 113:80: E501 line too long (111 > 79 characters) Line 120:80: E501 line too long (96 > 79 characters) Line 127:80: E501 line too long (94 > 79 characters) Line 129:80: E501 line too long (96 > 79 characters) Line 153:1: W293 blank line contains whitespace Line 154:80: E501 line too long (100 > 79 characters) Line 156:80: E501 line too long (94 > 79 characters) Line 198:80: E501 line too long (85 > 79 characters) Line 203:1: W293 blank line contains whitespace Line 205:80: E501 line too long (81 > 79 characters)

Line 5:80: E501 line too long (84 > 79 characters) Line 16:80: E501 line too long (103 > 79 characters) Line 23:80: E501 line too long (83 > 79 characters) Line 34:80: E501 line too long (109 > 79 characters) Line 45:80: E501 line too long (88 > 79 characters) Line 65:80: E501 line too long (95 > 79 characters) Line 68:80: E501 line too long (104 > 79 characters) Line 80:80: E501 line too long (81 > 79 characters) Line 157:80: E501 line too long (96 > 79 characters) Line 158:80: E501 line too long (95 > 79 characters) Line 159:80: E501 line too long (99 > 79 characters) Line 161:80: E501 line too long (93 > 79 characters) Line 172:80: E501 line too long (90 > 79 characters) Line 177:80: E501 line too long (111 > 79 characters) Line 185:80: E501 line too long (82 > 79 characters) Line 195:80: E501 line too long (117 > 79 characters) Line 200:80: E501 line too long (81 > 79 characters) Line 210:80: E501 line too long (113 > 79 characters) Line 211:80: E501 line too long (111 > 79 characters) Line 216:80: E501 line too long (93 > 79 characters) Line 217:80: E501 line too long (80 > 79 characters) Line 218:80: E501 line too long (87 > 79 characters) Line 221:80: E501 line too long (120 > 79 characters) Line 224:80: E501 line too long (82 > 79 characters) Line 226:80: E501 line too long (104 > 79 characters) Line 236:80: E501 line too long (126 > 79 characters) Line 241:80: E501 line too long (97 > 79 characters) Line 245:80: E501 line too long (93 > 79 characters) Line 246:80: E501 line too long (93 > 79 characters) Line 248:80: E501 line too long (102 > 79 characters) Line 249:80: E501 line too long (98 > 79 characters) Line 250:80: E501 line too long (120 > 79 characters) Line 254:80: E501 line too long (95 > 79 characters) Line 255:80: E501 line too long (92 > 79 characters) Line 256:80: E501 line too long (104 > 79 characters) Line 284:80: E501 line too long (109 > 79 characters) Line 285:80: E501 line too long (117 > 79 characters) Line 289:80: E501 line too long (109 > 79 characters) Line 290:80: E501 line too long (91 > 79 characters)

Line 20:80: E501 line too long (82 > 79 characters) Line 30:80: E501 line too long (85 > 79 characters)

Line 16:80: E501 line too long (87 > 79 characters) Line 27:80: E501 line too long (85 > 79 characters) Line 188:80: E501 line too long (85 > 79 characters) Line 189:80: E501 line too long (85 > 79 characters) Line 190:80: E501 line too long (84 > 79 characters) Line 191:80: E501 line too long (84 > 79 characters) Line 192:80: E501 line too long (84 > 79 characters) Line 193:80: E501 line too long (84 > 79 characters) Line 200:80: E501 line too long (108 > 79 characters) Line 203:80: E501 line too long (80 > 79 characters) Line 278:80: E501 line too long (82 > 79 characters) Line 311:80: E501 line too long (90 > 79 characters) Line 472:80: E501 line too long (101 > 79 characters) Line 481:80: E501 line too long (101 > 79 characters) Line 492:80: E501 line too long (101 > 79 characters) Line 501:80: E501 line too long (101 > 79 characters) Line 510:80: E501 line too long (80 > 79 characters) Line 513:80: E501 line too long (101 > 79 characters) Line 522:80: E501 line too long (101 > 79 characters) Line 532:80: E501 line too long (101 > 79 characters) Line 541:80: E501 line too long (101 > 79 characters) Line 550:80: E501 line too long (114 > 79 characters) Line 556:80: E501 line too long (111 > 79 characters) Line 557:80: E501 line too long (88 > 79 characters) Line 558:80: E501 line too long (119 > 79 characters) Line 562:80: E501 line too long (111 > 79 characters) Line 563:80: E501 line too long (88 > 79 characters) Line 564:80: E501 line too long (119 > 79 characters) Line 565:80: E501 line too long (114 > 79 characters) Line 571:80: E501 line too long (110 > 79 characters) Line 572:80: E501 line too long (88 > 79 characters) Line 573:80: E501 line too long (119 > 79 characters) Line 577:80: E501 line too long (110 > 79 characters) Line 578:80: E501 line too long (88 > 79 characters) Line 579:80: E501 line too long (119 > 79 characters) Line 581:80: E501 line too long (114 > 79 characters) Line 586:80: E501 line too long (107 > 79 characters) Line 587:80: E501 line too long (109 > 79 characters) Line 588:80: E501 line too long (115 > 79 characters) Line 593:80: E501 line too long (107 > 79 characters) Line 594:80: E501 line too long (109 > 79 characters) Line 595:80: E501 line too long (115 > 79 characters) Line 596:80: E501 line too long (114 > 79 characters) Line 601:80: E501 line too long (106 > 79 characters) Line 602:80: E501 line too long (109 > 79 characters) Line 603:80: E501 line too long (115 > 79 characters) Line 608:80: E501 line too long (106 > 79 characters) Line 609:80: E501 line too long (109 > 79 characters) Line 610:80: E501 line too long (115 > 79 characters) Line 612:80: E501 line too long (80 > 79 characters) Line 617:80: E501 line too long (107 > 79 characters) Line 619:80: E501 line too long (115 > 79 characters) Line 624:80: E501 line too long (107 > 79 characters) Line 626:80: E501 line too long (115 > 79 characters) Line 627:80: E501 line too long (80 > 79 characters) Line 632:80: E501 line too long (102 > 79 characters) Line 634:80: E501 line too long (115 > 79 characters) Line 639:80: E501 line too long (102 > 79 characters) Line 641:80: E501 line too long (115 > 79 characters) Line 654:80: E501 line too long (111 > 79 characters) Line 657:80: E501 line too long (113 > 79 characters) Line 670:80: E501 line too long (114 > 79 characters) Line 673:80: E501 line too long (113 > 79 characters) Line 676:80: E501 line too long (80 > 79 characters) Line 680:80: E501 line too long (101 > 79 characters) Line 694:80: E501 line too long (101 > 79 characters) Line 709:80: E501 line too long (101 > 79 characters) Line 723:80: E501 line too long (101 > 79 characters) Line 734:80: E501 line too long (80 > 79 characters) Line 738:80: E501 line too long (101 > 79 characters) Line 752:80: E501 line too long (101 > 79 characters) Line 767:80: E501 line too long (101 > 79 characters) Line 781:80: E501 line too long (101 > 79 characters) Line 793:80: E501 line too long (80 > 79 characters) Line 798:80: E501 line too long (99 > 79 characters) Line 799:80: E501 line too long (111 > 79 characters) Line 805:80: E501 line too long (103 > 79 characters) Line 806:80: E501 line too long (115 > 79 characters) Line 810:80: E501 line too long (103 > 79 characters) Line 811:80: E501 line too long (115 > 79 characters) Line 813:80: E501 line too long (80 > 79 characters) Line 818:80: E501 line too long (98 > 79 characters) Line 819:80: E501 line too long (111 > 79 characters) Line 825:80: E501 line too long (102 > 79 characters) Line 826:80: E501 line too long (115 > 79 characters) Line 830:80: E501 line too long (102 > 79 characters) Line 831:80: E501 line too long (115 > 79 characters) Line 841:80: E501 line too long (101 > 79 characters) Line 843:80: E501 line too long (101 > 79 characters) Line 850:80: E501 line too long (84 > 79 characters)

Line 17:80: E501 line too long (87 > 79 characters)

Line 8:80: E501 line too long (85 > 79 characters) Line 36:80: E501 line too long (82 > 79 characters) Line 53:80: E501 line too long (82 > 79 characters) Line 65:80: E501 line too long (81 > 79 characters) Line 71:80: E501 line too long (81 > 79 characters) Line 72:80: E501 line too long (81 > 79 characters)

Line 39:80: E501 line too long (82 > 79 characters) Line 59:80: E501 line too long (106 > 79 characters) Line 62:80: E501 line too long (98 > 79 characters)

Line 29:1: W293 blank line contains whitespace Line 38:43: E231 missing whitespace after ',' Line 42:80: E501 line too long (110 > 79 characters) Line 64:80: E501 line too long (80 > 79 characters) Line 66:80: E501 line too long (80 > 79 characters) Line 69:80: E501 line too long (80 > 79 characters) Line 71:80: E501 line too long (80 > 79 characters)

Line 36:80: E501 line too long (84 > 79 characters) Line 43:80: E501 line too long (94 > 79 characters) Line 55:9: E722 do not use bare 'except' Line 74:80: E501 line too long (93 > 79 characters) Line 129:80: E501 line too long (116 > 79 characters) Line 164:80: E501 line too long (101 > 79 characters) Line 168:80: E501 line too long (95 > 79 characters) Line 169:80: E501 line too long (90 > 79 characters) Line 212:80: E501 line too long (89 > 79 characters) Line 215:80: E501 line too long (108 > 79 characters) Line 224:80: E501 line too long (107 > 79 characters) Line 229:80: E501 line too long (80 > 79 characters) Line 230:80: E501 line too long (83 > 79 characters)

Line 91:80: E501 line too long (119 > 79 characters) Line 93:80: E501 line too long (117 > 79 characters) Line 94:80: E501 line too long (94 > 79 characters) Line 96:80: E501 line too long (117 > 79 characters) Line 97:80: E501 line too long (94 > 79 characters) Line 110:80: E501 line too long (91 > 79 characters) Line 119:80: E501 line too long (97 > 79 characters) Line 136:80: E501 line too long (83 > 79 characters) Line 142:80: E501 line too long (91 > 79 characters) Line 154:80: E501 line too long (97 > 79 characters) Line 162:80: E501 line too long (90 > 79 characters) Line 220:80: E501 line too long (87 > 79 characters) Line 228:80: E501 line too long (97 > 79 characters) Line 254:80: E501 line too long (83 > 79 characters) Line 255:80: E501 line too long (82 > 79 characters) Line 256:80: E501 line too long (83 > 79 characters) Line 257:80: E501 line too long (86 > 79 characters) Line 258:80: E501 line too long (86 > 79 characters) Line 261:80: E501 line too long (106 > 79 characters) Line 269:80: E501 line too long (95 > 79 characters) Line 270:80: E501 line too long (82 > 79 characters) Line 278:80: E501 line too long (104 > 79 characters)

Line 19:80: E501 line too long (118 > 79 characters) Line 42:80: E501 line too long (115 > 79 characters) Line 43:80: E501 line too long (92 > 79 characters) Line 68:80: E501 line too long (107 > 79 characters) Line 70:80: E501 line too long (85 > 79 characters) Line 74:80: E501 line too long (85 > 79 characters) Line 78:80: E501 line too long (85 > 79 characters) Line 82:80: E501 line too long (85 > 79 characters) Line 83:80: E501 line too long (84 > 79 characters) Line 86:80: E501 line too long (85 > 79 characters) Line 87:80: E501 line too long (84 > 79 characters) Line 90:80: E501 line too long (85 > 79 characters) Line 91:80: E501 line too long (84 > 79 characters) Line 94:80: E501 line too long (83 > 79 characters) Line 105:80: E501 line too long (115 > 79 characters) Line 106:80: E501 line too long (92 > 79 characters) Line 131:80: E501 line too long (107 > 79 characters) Line 133:80: E501 line too long (85 > 79 characters) Line 137:80: E501 line too long (85 > 79 characters) Line 141:80: E501 line too long (85 > 79 characters) Line 145:80: E501 line too long (83 > 79 characters) Line 154:80: E501 line too long (82 > 79 characters) Line 155:80: E501 line too long (99 > 79 characters) Line 157:80: E501 line too long (83 > 79 characters) Line 158:80: E501 line too long (117 > 79 characters) Line 159:5: E722 do not use bare 'except' Line 165:80: E501 line too long (102 > 79 characters) Line 168:80: E501 line too long (82 > 79 characters) Line 185:80: E501 line too long (112 > 79 characters) Line 187:80: E501 line too long (120 > 79 characters) Line 196:80: E501 line too long (94 > 79 characters) Line 197:80: E501 line too long (110 > 79 characters) Line 201:80: E501 line too long (96 > 79 characters) Line 202:80: E501 line too long (110 > 79 characters) Line 209:80: E501 line too long (108 > 79 characters) Line 242:80: E501 line too long (81 > 79 characters) Line 259:80: E501 line too long (120 > 79 characters) Line 330:80: E501 line too long (90 > 79 characters) Line 352:80: E501 line too long (111 > 79 characters) Line 399:80: E501 line too long (102 > 79 characters) Line 406:80: E501 line too long (106 > 79 characters) Line 413:80: E501 line too long (95 > 79 characters) Line 421:80: E501 line too long (83 > 79 characters) Line 446:80: E501 line too long (114 > 79 characters) Line 468:80: E501 line too long (100 > 79 characters) Line 469:80: E501 line too long (102 > 79 characters) Line 479:80: E501 line too long (93 > 79 characters) Line 481:80: E501 line too long (92 > 79 characters) Line 483:9: E722 do not use bare 'except' Line 490:80: E501 line too long (94 > 79 characters) Line 492:80: E501 line too long (93 > 79 characters) Line 494:9: E722 do not use bare 'except' Line 500:80: E501 line too long (102 > 79 characters) Line 507:80: E501 line too long (117 > 79 characters) Line 522:9: E722 do not use bare 'except' Line 548:80: E501 line too long (90 > 79 characters)

Line 25:80: E501 line too long (108 > 79 characters) Line 44:80: E501 line too long (81 > 79 characters) Line 46:80: E501 line too long (123 > 79 characters) Line 48:80: E501 line too long (86 > 79 characters) Line 54:80: E501 line too long (98 > 79 characters) Line 58:80: E501 line too long (93 > 79 characters) Line 65:80: E501 line too long (93 > 79 characters) Line 78:80: E501 line too long (108 > 79 characters) Line 82:80: E501 line too long (82 > 79 characters) Line 149:80: E501 line too long (98 > 79 characters) Line 161:80: E501 line too long (91 > 79 characters) Line 241:80: E501 line too long (86 > 79 characters) Line 247:80: E501 line too long (116 > 79 characters) Line 260:80: E501 line too long (90 > 79 characters) Line 266:80: E501 line too long (117 > 79 characters) Line 274:80: E501 line too long (95 > 79 characters) Line 280:80: E501 line too long (94 > 79 characters) Line 282:80: E501 line too long (107 > 79 characters) Line 296:80: E501 line too long (115 > 79 characters) Line 299:80: E501 line too long (113 > 79 characters) Line 302:80: E501 line too long (113 > 79 characters) Line 305:80: E501 line too long (95 > 79 characters) Line 307:80: E501 line too long (87 > 79 characters) Line 324:80: E501 line too long (93 > 79 characters) Line 329:80: E501 line too long (101 > 79 characters) Line 330:9: E722 do not use bare 'except' Line 355:80: E501 line too long (107 > 79 characters)

Line 31:9: E722 do not use bare 'except' Line 35:80: E501 line too long (84 > 79 characters) Line 36:80: E501 line too long (85 > 79 characters)

Line 31:80: E501 line too long (80 > 79 characters) Line 32:80: E501 line too long (98 > 79 characters) Line 33:80: E501 line too long (126 > 79 characters) Line 44:80: E501 line too long (94 > 79 characters) Line 49:80: E501 line too long (94 > 79 characters) Line 53:80: E501 line too long (87 > 79 characters) Line 57:80: E501 line too long (87 > 79 characters) Line 73:80: E501 line too long (94 > 79 characters) Line 125:9: E722 do not use bare 'except' Line 137:80: E501 line too long (85 > 79 characters) Line 179:9: E722 do not use bare 'except' Line 193:80: E501 line too long (94 > 79 characters) Line 196:80: E501 line too long (90 > 79 characters) Line 205:80: E501 line too long (81 > 79 characters) Line 206:1: W293 blank line contains whitespace Line 207:80: E501 line too long (110 > 79 characters) Line 216:9: E722 do not use bare 'except'

Line 49:80: E501 line too long (83 > 79 characters) Line 85:80: E501 line too long (81 > 79 characters) Line 86:80: E501 line too long (112 > 79 characters) Line 89:80: E501 line too long (99 > 79 characters) Line 110:80: E501 line too long (92 > 79 characters) Line 111:80: E501 line too long (89 > 79 characters) Line 150:80: E501 line too long (88 > 79 characters) Line 192:80: E501 line too long (87 > 79 characters) Line 193:80: E501 line too long (91 > 79 characters) Line 195:80: E501 line too long (134 > 79 characters) Line 195:87: E231 missing whitespace after ',' Line 198:80: E501 line too long (91 > 79 characters) Line 199:80: E501 line too long (81 > 79 characters) Line 215:80: E501 line too long (83 > 79 characters) Line 228:80: E501 line too long (88 > 79 characters) Line 260:80: E501 line too long (112 > 79 characters) Line 267:80: E501 line too long (116 > 79 characters) Line 275:80: E501 line too long (87 > 79 characters) Line 280:80: E501 line too long (101 > 79 characters) Line 285:80: E501 line too long (88 > 79 characters) Line 297:80: E501 line too long (94 > 79 characters)

Line 44:80: E501 line too long (96 > 79 characters) Line 57:16: E127 continuation line over-indented for visual indent Line 57:80: E501 line too long (94 > 79 characters) Line 64:80: E501 line too long (85 > 79 characters)

Line 19:80: E501 line too long (92 > 79 characters) Line 24:80: E501 line too long (87 > 79 characters) Line 26:80: E501 line too long (93 > 79 characters) Line 32:80: E501 line too long (108 > 79 characters) Line 33:80: E501 line too long (107 > 79 characters) Line 34:80: E501 line too long (80 > 79 characters) Line 35:80: E501 line too long (85 > 79 characters) Line 37:80: E501 line too long (89 > 79 characters) Line 38:80: E501 line too long (90 > 79 characters) Line 39:13: E722 do not use bare 'except' Line 48:80: E501 line too long (86 > 79 characters) Line 50:80: E501 line too long (107 > 79 characters) Line 53:80: E501 line too long (105 > 79 characters) Line 56:80: E501 line too long (81 > 79 characters) Line 63:80: E501 line too long (84 > 79 characters) Line 65:13: E722 do not use bare 'except' Line 75:80: E501 line too long (109 > 79 characters) Line 76:13: E722 do not use bare 'except' Line 82:80: E501 line too long (89 > 79 characters)

Line 39:80: E501 line too long (122 > 79 characters) Line 40:80: E501 line too long (104 > 79 characters) Line 50:80: E501 line too long (90 > 79 characters) Line 52:80: E501 line too long (80 > 79 characters) Line 54:80: E501 line too long (93 > 79 characters) Line 57:25: E117 over-indented Line 59:80: E501 line too long (104 > 79 characters) Line 64:80: E501 line too long (82 > 79 characters) Line 68:80: E501 line too long (109 > 79 characters) Line 73:80: E501 line too long (139 > 79 characters) Line 75:80: E501 line too long (118 > 79 characters) Line 91:80: E501 line too long (95 > 79 characters) Line 94:80: E501 line too long (86 > 79 characters) Line 95:80: E501 line too long (106 > 79 characters) Line 96:80: E501 line too long (89 > 79 characters)

Line 7:1: E402 module level import not at top of file Line 8:1: E402 module level import not at top of file Line 9:1: E402 module level import not at top of file Line 12:80: E501 line too long (89 > 79 characters) Line 23:1: W293 blank line contains whitespace Line 27:80: E501 line too long (80 > 79 characters)

Line 43:80: E501 line too long (83 > 79 characters) Line 54:1: W293 blank line contains whitespace Line 73:1: W293 blank line contains whitespace Line 87:80: E501 line too long (89 > 79 characters) Line 88:80: E501 line too long (87 > 79 characters) Line 101:1: W293 blank line contains whitespace Line 146:1: W293 blank line contains whitespace Line 149:1: W293 blank line contains whitespace Line 152:1: W293 blank line contains whitespace Line 161:80: E501 line too long (83 > 79 characters) Line 162:1: W293 blank line contains whitespace Line 163:80: E501 line too long (93 > 79 characters) Line 165:1: W293 blank line contains whitespace Line 166:80: E501 line too long (83 > 79 characters) Line 180:1: W293 blank line contains whitespace Line 193:80: E501 line too long (87 > 79 characters) Line 228:80: E501 line too long (90 > 79 characters) Line 235:80: E501 line too long (80 > 79 characters) Line 236:80: E501 line too long (95 > 79 characters)

Line 8:1: E402 module level import not at top of file Line 10:1: E402 module level import not at top of file Line 11:1: E402 module level import not at top of file Line 12:1: E402 module level import not at top of file

codesyncapp[bot] commented 6 months ago

Check out the playback for this Pull Request here.

penify-dev[bot] commented 6 months ago

PR Review 🔍

⏱️ Estimated effort to review [1-5] 4, due to the significant amount of new code added, including multiple classes, methods, and functions. Understanding the Chinese Chess environment, utility functions, and Nash battle worker module requires careful examination.
🧪 Relevant tests No
⚡ Possible issues Possible Bug: - In the `BaseChessBoard` class, the `move` method modifies the `pos_from` and `pos_to` objects directly, which might lead to unexpected behavior. Consider creating new `Pos` objects instead of modifying the existing ones.
Code Duplication: - There is some code duplication in the `create_uci_labels` and `create_position_labels` functions. Consider refactoring to reduce redundancy and improve maintainability.
Performance Concern: - The `get_legal_moves` method in the `CchessEnv` class performs a large number of nested loops and conditional checks, which could impact performance for large datasets. Consider optimizing the algorithm for better efficiency.
🔒 Security concerns No
penify-dev[bot] commented 6 months ago

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Score
Maintainability
Break down the cal_nash function into smaller functions for improved maintainability ___ **Consider breaking down the cal_nash function into smaller, more focused functions for
better maintainability.** [examples/chinese_chess/nash_evaluate.py [337-450]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-5d365731269c4acfc9ddecf11b21809c7d48b1364b9284e76ef06366e4a82633R337-R450) ```diff def cal_nash(): """ - cal nash and rpp - upload all res files + Calculate Nash equilibrium and RPP, and upload all result files. """ model_stamps = get_sorted_weight_list() + model_pool_list = get_model_pool_list() + latest_model_stamp = get_latest_weight_path() + nash_res, rate_table_pd, nash_res_with_bot, rate_table_bot_pd = nash.build_rate_table(model_pool_list, latest_model_stamp, conf.ResourceConfig.nash_battle_local_dir) + model_pool = maintain_pool_model(nash_res, model_stamps) + save_model_pool(model_pool, latest_model_stamp) + save_nash_res(nash_res, latest_model_stamp) + save_nash_res_with_bot(nash_res_with_bot, latest_model_stamp) + save_rate_tables(rate_table_pd, rate_table_bot_pd, latest_model_stamp) ... ```
Suggestion importance[1-10]: 8 Why: Breaking down the `cal_nash` function into smaller, focused functions will significantly enhance maintainability by improving code organization and clarity.
8
Refactor the download_latest_model function to enhance readability and maintainability ___ **Consider refactoring the download_latest_model function to improve readability and
maintainability.** [examples/chinese_chess/nash_evaluate.py [30-97]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-5d365731269c4acfc9ddecf11b21809c7d48b1364b9284e76ef06366e4a82633R30-R97) ```diff def download_latest_model(args): """ - download latest weight + Download the latest weight if `nash_index` is 0. """ - if args.nash_index == 0: - while True: + while True: + done = False + new_weight_names = [] + local_weights = os.listdir(conf.ResourceConfig.model_dir) + local_weights.sort() + latest_weight_stamp = get_latest_weight_path() ... ```
Suggestion importance[1-10]: 7 Why: Refactoring the `download_latest_model` function will enhance code readability and maintainability, making the logic clearer.
7
Refactor the get_model_to_battle function to improve readability and maintainability by extracting start and end index calculations ___ **Consider refactoring the get_model_to_battle function for better readability and
maintainability.** [examples/chinese_chess/nash_evaluate_worker.py [37-48]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-f5259c60cc9ecaac9d5c84c5abab4d7f328041a96335ad49b96ba2908c1b46c9R37-R48) ```diff def get_model_to_battle(model_pool_list, args): -""" -""" -if not model_pool_list: -return [], [] -len_pre_node = int(len(model_pool_list) / conf.EvaluateConfig.nash_nodes_num) -if args.nash_index < conf.EvaluateConfig.nash_nodes_num - 1: -model_pool_this_nash_worker = model_pool_list[args.nash_index * len_pre_node: (args.nash_index + 1) * len_pre_node] -else: -model_pool_this_nash_worker = model_pool_list[args.nash_index * len_pre_node:] + if not model_pool_list: + return [], [] + + len_pre_node = int(len(model_pool_list) / conf.EvaluateConfig.nash_nodes_num) + start_index = args.nash_index * len_pre_node + end_index = (args.nash_index + 1) * len_pre_node if args.nash_index < conf.EvaluateConfig.nash_nodes_num - 1 else None + model_pool_this_nash_worker = model_pool_list[start_index:end_index] ```
Suggestion importance[1-10]: 7 Why: The suggestion improves the readability and maintainability by extracting start and end index calculations in the `get_model_to_battle` function.
7
Refactor variable names in a method for clarity and maintainability ___ **Consider refactoring the `cal_rate` method for improved readability and maintainability.** [examples/chinese_chess/nash/cal_nash_eq.py [49]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0132e74a04acb916c62f2405e43f50d8f5e02e0747c51c8fda3d787b2056cfeaR49-R49) ```diff -for one_play in chess_plays: +for play_file in chess_plays: ```
Suggestion importance[1-10]: 7 Why: The suggestion improves code readability and maintainability by using a more descriptive variable name 'play_file' instead of 'one_play'.
7
Refactor the add_grad_to_list function for improved readability and maintainability ___ **Consider refactoring the add_grad_to_list function to improve readability and
maintainability.** [examples/chinese_chess/agent/resnet.py [116-119]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0a8bba383181412f524780c90e1dc331f1a3d09573cba6cae65535a1bbf5b46aR116-R119) ```diff -def add_grad_to_list(opt, train_param, loss, tower_grad): - grads = opt.compute_gradients(loss, var_list=train_param) - grads = [i[0] for i in grads] - tower_grad.append(zip(grads, train_param)) +def add_grad_to_list(optimizer, trainable_params, loss, tower_grad): + gradients = optimizer.compute_gradients(loss, var_list=trainable_params) + gradients = [grad[0] for grad in gradients] + tower_grad.append(zip(gradients, trainable_params)) ```
Suggestion importance[1-10]: 7 Why: The suggestion addresses maintainability by refactoring the function for better readability.
7
Break down the get_model function into smaller, more focused functions to enhance readability and maintainability ___ **Consider breaking down the get_model function into smaller, more focused functions to
improve readability and maintainability.** [examples/chinese_chess/agent/resnet.py [136-291]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0a8bba383181412f524780c90e1dc331f1a3d09573cba6cae65535a1bbf5b46aR136-R291) ```diff -136 +def get_model( -... -291 + return (sess, graph), ((x_input, training), (net_softmax, value_head)) +# Split the get_model function into smaller, more focused functions +def build_graph(): + # Build the TensorFlow graph + ... +def initialize_session(): + # Initialize the TensorFlow session + ... + +def restore_model(): + # Restore the model if provided + ... + +def train_model(): + # Train the model + ... + +def return_results(): + # Return the results + ... + +return build_graph(), initialize_session(), restore_model(), train_model(), return_results() + ```
Suggestion importance[1-10]: 7 Why: Breaking down the function into smaller, focused functions enhances readability and maintainability.
7
Improve error handling in the nash_battle function by catching specific exceptions and providing more detailed error messages ___ **Consider handling potential exceptions more specifically in the nash_battle function for
better error management.** [examples/chinese_chess/nash_evaluate_worker.py [330]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-f5259c60cc9ecaac9d5c84c5abab4d7f328041a96335ad49b96ba2908c1b46c9R330-R330) ```diff -except: - logging.error('battle model {} error'.format(model)) +except Exception as e: + logging.error(f'Error occurred while battling model {model}: {e}') ```
Suggestion importance[1-10]: 6 Why: Improving error handling in the `nash_battle` function by catching specific exceptions and providing more detailed error messages enhances maintainability.
6
Improve handling of division by zero in a calculation ___ **Consider handling the case where the sum of row_play_counts is zero more explicitly.** [examples/chinese_chess/nash/cal_nash_eq.py [93]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0132e74a04acb916c62f2405e43f50d8f5e02e0747c51c8fda3d787b2056cfeaR93-R93) ```diff -row_play_counts / np.sum(row_play_counts) if np.sum(row_play_counts) != 0 else row_play_counts + 1 / len(row_play_counts) +if np.sum(row_play_counts) == 0: + row_play_counts = [1 / len(row_play_counts) for _ in row_play_counts] +else: + row_play_counts = row_play_counts / np.sum(row_play_counts) ```
Suggestion importance[1-10]: 6 Why: The suggestion suggests a more explicit way to handle the case where the sum of 'row_play_counts' is zero, enhancing code maintainability.
6
Encapsulate complex logic in a separate method for improved maintainability ___ **Consider extracting the complex logic in the rpp method into smaller, more focused
functions for better maintainability.** [examples/chinese_chess/nash/cal_nash_eq.py [158]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0132e74a04acb916c62f2405e43f50d8f5e02e0747c51c8fda3d787b2056cfeaR158-R158) ```diff -rpp = np.matmul(row_nash_q.T, rate_tables) +rpp = self.calculate_relative_population_performance(row_nash_q, rate_tables) ```
Suggestion importance[1-10]: 6 Why: The suggestion recommends extracting complex logic into a separate method 'calculate_relative_population_performance' for better maintainability.
6
Consolidate the logic for creating convolutional layers to reduce duplication ___ **Consider consolidating the repeated logic for creating convolutional layers in the
res_block and conv_block functions to reduce duplication.** [examples/chinese_chess/agent/resnet.py [5-35]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0a8bba383181412f524780c90e1dc331f1a3d09573cba6cae65535a1bbf5b46aR5-R35) ```diff -5 +def res_block(inputx, name, training, block_num=2, filters=256, kernel_size=(3, 3)): -... -23 +def conv_block(inputx, name, training, block_num=1, filters=2, kernel_size=(1, 1)): -... +def create_conv_layer(inputx, name, training, block_num, filters, kernel_size): + net = inputx + for i in range(block_num): + net = tf.layers.conv2d( + net, + filters=filters, + kernel_size=kernel_size, + activation=None, + name="{}_conv_conv{}".format(name, i), + padding='same' + ) + net = tf.layers.batch_normalization(net, training=training, name="{}_conv_bn{}".format(name, i)) + net = tf.nn.elu(net, name="{}_conv_elu{}".format(name, i)) + return net ```
Suggestion importance[1-10]: 6 Why: The suggestion aims to reduce duplication and improve maintainability by consolidating the logic for creating convolutional layers.
6
Enhance the get_nash_battle_list function by consolidating the logic for shuffling and extending lists ___ **Consider consolidating the repeated logic for shuffling and extending lists in the
get_nash_battle_list function.** [examples/chinese_chess/nash_evaluate_worker.py [109-112]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-f5259c60cc9ecaac9d5c84c5abab4d7f328041a96335ad49b96ba2908c1b46c9R109-R112) ```diff np.random.shuffle(models_to_battle_other_workers) -models_to_battle.extend(models_to_battle_other_workers) np.random.shuffle(models_to_battle_other_node) -models_to_battle.extend(models_to_battle_other_node) +models_to_battle.extend(models_to_battle_other_workers + models_to_battle_other_node) ```
Suggestion importance[1-10]: 5 Why: The suggestion enhances the `get_nash_battle_list` function by consolidating the logic for shuffling and extending lists, improving maintainability.
5
Replace magic numbers with named constants for clarity in calculations ___ **Avoid using magic numbers directly in calculations for better code understanding.** [examples/chinese_chess/nash/cal_nash_eq.py [142]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0132e74a04acb916c62f2405e43f50d8f5e02e0747c51c8fda3d787b2056cfeaR142-R142) ```diff -rate_tables = [[0 for _ in range(model_pool_size)] for _ in range(model_pool_size)] +initial_value = 0 +rate_tables = [[initial_value for _ in range(model_pool_size)] for _ in range(model_pool_size)] ```
Suggestion importance[1-10]: 5 Why: The suggestion enhances code understanding by introducing a named constant 'initial_value' instead of a magic number directly in calculations.
5
Modularity
Extract the logic for creating policy and value heads into separate functions for better modularity ___ **Consider extracting the logic for creating the policy and value heads into separate
functions for better modularity.** [examples/chinese_chess/agent/resnet.py [184-211]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-0a8bba383181412f524780c90e1dc331f1a3d09573cba6cae65535a1bbf5b46aR184-R211) ```diff -184 + with tf.variable_scope("policy_head"): -... -199 + with tf.variable_scope("value_head"): -... +def create_policy_head(body): + policy_head = tf.layers.conv2d(body, 2, 1, padding='SAME') + policy_head = tf.contrib.layers.batch_norm( + policy_head, + center=False, + epsilon=1e-5, + fused=True, + is_training=training, + activation_fn=tf.nn.relu + ) + policy_head = tf.reshape(policy_head, [-1, 9 * 10 * 2]) + policy_head = tf.contrib.layers.fully_connected(policy_head, len(labels), activation_fn=None) + return policy_head +def create_value_head(body): + value_head = tf.layers.conv2d(body, 1, 1, padding='SAME') + value_head = tf.contrib.layers.batch_norm( + value_head, + center=False, + epsilon=1e-5, + fused=True, + is_training=training, + activation_fn=tf.nn.relu + ) + value_head = tf.reshape(value_head, [-1, 9 * 10 * 1]) + value_head = tf.contrib.layers.fully_connected(value_head, 256, activation_fn=tf.nn.relu) + value_head = tf.contrib.layers.fully_connected(value_head, 1, activation_fn=tf.nn.tanh) + return value_head + ```
Suggestion importance[1-10]: 8 Why: Extracting the logic into separate functions enhances modularity and improves code organization.
8
Extract the logic from nash_battle_process into a separate function for improved modularity ___ **Consider extracting the logic inside the nash_battle_process function into a separate
helper function for better modularity.** [examples/chinese_chess/nash_evaluate.py [150-161]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-5d365731269c4acfc9ddecf11b21809c7d48b1364b9284e76ef06366e4a82633R150-R161) ```diff -def nash_battle_process(gpu_num, worker_index, nash_index): +def execute_nash_battle(gpu_num, worker_index, nash_index): try: logging.info('nash battle gpu_num {}'.format(gpu_num)) worker_nash_battle = os.path.join(project_path, 'nash_evaluate_worker.py') - logging.info('excute command python {} -gpu_num {} -worker_index {} -nash_index {}'.format( + logging.info('execute command python {} -gpu_num {} -worker_index {} -nash_index {}'.format( worker_nash_battle, gpu_num, worker_index, nash_index)) subprocess.run('{} {} -gpu_num {} -worker_index {} -nash_index {}'.format( conf.ResourceConfig.python_executor, worker_nash_battle, gpu_num, worker_index, nash_index), shell=False) except: - logging.error('nahs battle error') + logging.error('nash battle error') ```
Suggestion importance[1-10]: 6 Why: Extracting the logic from `nash_battle_process` into a separate function can improve modularity and make the code more organized.
6
Readability, maintainability
Refactor the nash_eva function by splitting the logic into smaller, focused functions for improved readability and maintainability ___ **Consider refactoring the nash_eva function to separate the logic into smaller, more
focused functions for better readability and maintainability.** [examples/chinese_chess/nash_evaluate.py [512-541]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-5d365731269c4acfc9ddecf11b21809c7d48b1364b9284e76ef06366e4a82633R512-R541) ```diff +def nash_eva(args): + init_nash(args) + nash_battle(args) + if args.nash_index == 0: + try: + cal_nash() + except: + logging.error('cal nash error') + upload_all_res() + while True: + download_latest_model(args) + download_model_pool_list(args) + nash_battle(args) + if args.nash_index == 0: + try: + cal_nash() + except BaseException: + logging.error('cal nash error') + upload_all_res() - ```
Suggestion importance[1-10]: 8 Why: Refactoring the `nash_eva` function by splitting the logic into smaller, focused functions will greatly improve code readability and maintainability.
8
Readability
Enhance string formatting in the nash_battle function using f-strings for better readability ___ **Consider using f-strings for string formatting in the nash_battle function for improved
readability.** [examples/chinese_chess/nash_evaluate_worker.py [329]](https://github.com/2lambda123/huawei-noah-xingtian/pull/1/files#diff-f5259c60cc9ecaac9d5c84c5abab4d7f328041a96335ad49b96ba2908c1b46c9R329-R329) ```diff -logging.info('{} vs {} battle {} games'.format(latest_model_name, model, battle_num) +logging.info(f'{latest_model_name} vs {model} battle {battle_num} games') ```
Suggestion importance[1-10]: 4 Why: The suggestion enhances string formatting in the `nash_battle` function using f-strings for better readability.
4
secure-code-warrior-for-github[bot] commented 6 months ago

Micro-Learning Topic: Buffer overflow (Detected by phrase)

Matched on "buffer overflow"

What is this? (2min video)

A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold or when a program attempts to put data in a memory area past a buffer.

Try a challenge in Secure Code Warrior