-
Notifications
You must be signed in to change notification settings - Fork 12
Final Changes with Dr. J notes #22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a432b91
Code from homework assignment
Kahjax f0a2179
Peters notes
Kahjax 7629c2a
Added Peters changes
Kahjax ab938a6
Dr Jones notes to change
Kahjax 8f200d2
Made Dr. Jones changes
Kahjax 40da39d
Merge branch 'KJ1124_git' into Dr._Jones_notes
Kahjax cdfce0b
Made some minor changes and added image
Kahjax 35f9333
Final changes with Dr. J comments
Kahjax b4da550
More small edits
Kahjax 5fe33ab
Added new pictures and a few comments
Kahjax 4ebcf0d
Deleted picture and made final changes
Kahjax cd7e7e2
Added new images and final push changes
Kahjax 0a6f070
Final changes revitalized
Kahjax 848e503
Final changes revitalized again
Kahjax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // ******************* | ||
| // **Power of Thor** | ||
| // ******************* | ||
| /* | ||
| Use `this link <https://www.codingame.com/ide/puzzle/power-of-thor-episode-1>`_ to access the coding game. | ||
|
|
||
|
|
||
| General Instructions | ||
| -------------------- | ||
|
|
||
| **Objective** | ||
|
|
||
| Write a program that will guide Thor to reach the light of power in the most efficient manner. | ||
|
|
||
| **Game Rules** | ||
|
|
||
| Thor will move on this map that has the coordinates of 40 wide by 18 high. As the light of power changes locations your goal is change the direction of Thor's movements based on the coordinate placement of the light of power. | ||
|
|
||
|
|
||
| *Note: You can utilize any coding language that you are most comfortable with to write this code by changing this option in the code tab. I chose to use C++* | ||
|
|
||
| */ | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <vector> | ||
| #include <algorithm> | ||
|
|
||
| using namespace std; | ||
|
|
||
| /* | ||
| Provided Code | ||
| -------------- | ||
| These are the functions and variables that are also provided to the developer when you begin the coding game. | ||
| */ | ||
| int main() | ||
| // **beginning bracket** | ||
| { | ||
| // the X coordinate position of the light of power | ||
| int light_x; | ||
| // the Y coordinate position of the light of power | ||
| int light_y; | ||
| // Thor's starting position at X | ||
| int initial_thor_x; | ||
| // Thor's starting position at Y | ||
| int initial_thor_y; | ||
| // The cin.ignore() function is used to ignore characters that may not belong in your input buffer | ||
| cin >> light_x >> light_y >> initial_thor_x >> initial_thor_y; cin.ignore(); | ||
|
|
||
| // This while statement is the beginning of the beginning of the game loop and it allows causes all of your test cases to run | ||
| while (1) { | ||
| int remaining_turns; | ||
| // This is the remaining amount of turns Thor can move. Do not remove this line. | ||
| cin >> remaining_turns; cin.ignore(); | ||
|
|
||
| /* | ||
| Diagrams | ||
| --------- | ||
|
|
||
| .. image:: ThorPwr.jpg | ||
|
|
||
| **This a diagram of Thor at his starting postion. The red arrows are pointing at the XY plane and the compass below so that you can have a clear orientation of Thor as he moves within the boundary conditions.** | ||
|
|
||
| .. image:: GameInfo.jpg | ||
|
|
||
| **This is the games console output and is located underneath the image of Thor moving as he moves with each test case. It shows Thor's position and the light position as he moves across the board. This also shows the amount of energy consumption is being utilized to get to where you are making Thor travel. Both of your X and Y coordinates should either increment or decrement based on the postion of Thor in relation to the light of power.** | ||
|
|
||
| Variables | ||
| ---------- | ||
| The directions below are the variables used to output the direction in which you want Thor to go at the end of each game turn.Each movement makes Thor move by 1 cell the direction chosen | ||
|
|
||
| * N (North) | ||
| * NE (North East) | ||
| * E (East) | ||
| * SE (South East) | ||
| * S (South) | ||
| * SW (South West) | ||
| * W (West) | ||
| * NW (North West) | ||
|
|
||
| Thor's Movement | ||
| ---------------- | ||
| .. image:: XYgraph.jpg | ||
|
|
||
| **This image shows the XY cooridinate graph as it is represented in this program. The arrows show how the coordinates with either increase or decrease based on the direction Thor is moving towards in.** | ||
| */ | ||
| /* | ||
| In this case the light of power at the X and Y coordinates are greater than Thor's initial condition so, two if condition statements must to be implemented. Futhermore, the Y coordinate values increase as you go South and the X coordinates vale increase as you go further East. Thor's initial X and Y conditions must be incremented so he can move in the South East without going pass the MAX boundary for both the X and Y parameters. | ||
|
|
||
| */ | ||
| if ((light_y > initial_thor_y) && (light_x > initial_thor_x)) | ||
| { | ||
| cout << "SE" << endl; | ||
| initial_thor_x++; | ||
| initial_thor_y++; | ||
| } | ||
| /* | ||
| Based on the compass it can be determined that Thor will travel E (East).The light_x is the position of the light of power and initial_thor_x is Thor's starting position in the X-coordinate plane. The postion of the light of power is is going in the positive direction and it greater than Thor's starting postion so a condition statement is created that if this is the case travel East. | ||
| */ | ||
| else if (light_x > initial_thor_x) { | ||
| cout << "E" << endl; | ||
| initial_thor_x++; | ||
| } | ||
| /* | ||
| Thor will travel N (North) since the light of power is above his location and it is in the positive direction .The light_y is the position of the light of power and initial_thor_y is Thor's starting position in the Y-coordinate plane. X does not change here because thor is moving in the Y direction. | ||
| */ | ||
| else if (light_y < initial_thor_y) { | ||
| cout << "N" << endl; | ||
| initial_thor_y--; | ||
| } | ||
| /* | ||
| Based on the if statement for the South East direction, a comparison is made testing whether my y-value and x-value of the light power is greater than Thor's position, based on that outcome the code will go through the else-if statements.If both conditions apply, then SW would be the direction that Thor will move and this is the reason for the one variable increment.He will travel diagional because of the increment then straight. | ||
| */ | ||
| else if (light_y > initial_thor_y) { | ||
| cout << "SW" << endl; | ||
| initial_thor_y++; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does x not change here? |
||
| // *Positive increment here so that Thor does not run out of bounds.* | ||
| } | ||
| // This else if statement is so that Thor will travel West after incrementing to the point where the light of power is equal to Thor's initial position. Thor will not travel in any other directions because he is only moving towards the light of power. | ||
| else if (light_x < initial_thor_x) { | ||
| cout << "W" << endl; | ||
| } | ||
| } | ||
| } | ||
| // **ending bracket** | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the other directions (NW, S, etc)? |
||
|
|
||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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.
Starting here, indent your comments so they align with your code below.