-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate agents from game logic #30
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fcacab5
to
6ab9ffb
Compare
jserv
reviewed
Feb 6, 2024
jserv
reviewed
Feb 6, 2024
jserv
reviewed
Feb 6, 2024
jserv
reviewed
Feb 6, 2024
jserv
reviewed
Feb 6, 2024
jserv
requested changes
Feb 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revise the git commit messages to reflect the reasons behind the proposed changes from a third-person perspective.
7470f09
to
e16a491
Compare
jserv
reviewed
Feb 7, 2024
jserv
reviewed
Feb 7, 2024
In this commit, the original `ttt.c` was split to facilitate the addition of new agents. Several changes were implemented to achieve this: 1. `move_t` was introduced to transform `negamax` into a pure function 2. `qsort` was relocated from `available_moves` to incorporate it into the game logic. The readability of the code also increases with the following changes: 1. `table` and `move_record` were declared as static arrays. 2. The condition `is_consecutive(score, -1)` was replaced with `score < 0`, and vice versa.
Thank @paul90317 for contributing. Next time, you should specify the meaningful name for git branch used by pull requests. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this commit, I split the original
ttt.c
, making it easier to add new agents. To achieve this, I also made the following changes:move_t
to makenegamax
a pure function.qsort
out fromavailable_moves
to make it a part of the game logic.Additionally, I declared
table
andmove_record
as static arrays because they are unnecessary to be dynamically allocated.I also noticed #29, and I made some modifications to it without changing its score; specifically, I changed
is_consecutive(score, -1)
toscore < 0
, and vice versa.