Assignment 1
| Due: |
Please add, commit and push at least 4 times, and by the dates below.
|
|---|---|
| Late penalty: | 20% if handed in up to 48 hours late. Not accepted after that. Please notify me by email if you are handing in late. Otherwise we will not check your code out of the repository for marking. |
| Hand in: |
Electronic submit via git, that is, you should have your code checked into your repository by the due date. We will check it out from there.
Make sure to ALSO add the COMMIT ID that you want marked to csc207 which commit. For example, if I wanted the Oct 2 11:50:30 commit marked, I would enter 0af8e118ce4986e42576dbd8794d0ea1a7d549b3 in the a1 Commit ID field in whichCommit.
|
| Marking: | The Marking Scheme for a1. The intent is that it is in line with my 5 mark grading scheme. For programs, I usually use my code marking scheme. |
| Groups: | Groups of size 1. |
Othello
You will implement the two player game Othello. Your implementation will include a whole collection of features, including- Human VS Human play
- Human VS Computer (with both Greedy and Random strategies)
- An investigation into the effectiveness of Greedy and Random strategies.
Test Cases
We have provided some JUnit test cases in your Assignment1 project. To run them in IntelliJ, right click on src/test/java and then run "All Tests". When finished, all testcases should pass.Sample Outputs
This section gives you some sample inputs and outputs to test your code against.- othelloBoardOutput.txt is the result of running the main method of OthelloBoard.
- The following are sample outputs for the main method of Othello. Since the moves are generated randomly,
don't expect your output to match.
- gameOthelloMainA.txt, this is an actual output from Othello.main
- gameOthelloMainB.txt, this is an actual output from Othello.main
-
The following are sample outputs for OthelloControllerHumanVSHuman
- game0.txt resulting from game0moves.txt
- game1.txt resulting from game1moves.txt
- game2.txt resulting from game2moves.txt
- game3.txt resulting from game3moves.txt
Right click on OthelloControllerHumanVsHuman -> More Run/Debug -> Modify Run Configuration... When the Edit Run Configuration: 'OthelloControllerHumanVsHuman' appears Click Modify Options-> Redirect Input and then browse to game0moves.txt. Finally, run OthelloControllerHumanVSHuman, your output should match mine. Alternatively, you can type in the row,column pairs directly in the console by hand, and see if your output matches mine. Finally, if you are running from the command line, you would java OthelloControllerHumanVSHuman < game0moves.txt - The following are sample runs of OthelloControllerHumanVSGreedy. Your output should be identical.
- game4.txt (you can run this via game4moves.txt)
- game5.txt (you can run this via game5moves.txt)
- The output of OthelloControllerHumanVSRandom looks like OthelloControllerHumanVSGreedy except the same Human inputs can result in different Random moves.
Tasks and Submit Schedule
Remember, something will go wrong, it always does! Please add, commit and push according to the following schedule. You should actually add, commit and push more often than suggested below! Being ahead of schedule is great, being behind may be an indication of trouble!- Finish all easy methods in class OthelloBoard
otherPlayer, validCoordinate, getCount, ... - Work on medium methods in class OthelloBoard
alternation, ... - Work on hard methods in class OthelloBoard
flip, hasMove, move, ... - Work on methods in class Othello. The goal is to get the Othello.main running.
- Once Othello.main works, OthelloControllerHumanVSHuman.main should work! Try playing yourself etc.
- Commit and push: 'Completed OthelloControllerHumanVSHuman'
- Implement PlayerGreedy, then OthelloControllerHumanVSGreedy.
- Implement PlayerRandom, then OthelloControllerHumanVSRandom.
- Implement OthelloControllerRandomVSGreedy.
- Implement OthelloControllerRandomVSRandom.
- Commit and push: 'Completed all other Controllers'
- complete
randomVsRandomReport.txt - Commit and push 'Completed randomVsRandomReport.txt'
- Refactor, make sure code is simple, clear, concise, nice, all documentation is great.
- Commit and push 'Completed Assignment1'
Environment
You should build and run your code using IntelliJ, in the lab we have IntelliJ. Code that does not run in this environment, on lab systems, will not be marked! We are using Java 22 for this assignment. Please do not use any other java version.You can clone repo_a1_$USER directly from IntelliJ.
Questions and Answers
- Question:
-
Can I have some examples for the flip method? - Answer:
-
Testing flip method: before 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ 0|O|O|O|O|O|O|O| |0 +-+-+-+-+-+-+-+-+ 1| |O|O|O|O|O|O|O|1 +-+-+-+-+-+-+-+-+ 2| | |O|O|O|O|O|X|2 +-+-+-+-+-+-+-+-+ 3| | | |O|O|O|O|X|3 +-+-+-+-+-+-+-+-+ 4| | | | |X|O|O|X|4 +-+-+-+-+-+-+-+-+ 5| | | | | |O|O|X|5 +-+-+-+-+-+-+-+-+ 6| | | | | | |O|X|6 +-+-+-+-+-+-+-+-+ 7| | | | | | | |X|7 +-+-+-+-+-+-+-+-+ 0 1 2 3 4 5 6 7 flip(0,4,0,1, P1)=-1 flip(1,4,0,1, P1)=-1 flip(2,4,0,1, P1)=3 flip(3,4,0,1, P1)=3 flip(4,4,0,1, P1)=0 flip(5,4,0,1, P1)=-1 flip(6,4,0,1, P1)=-1 flip(7,4,0,1, P1)=-1 Testing flip method: after 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ 0|O|O|O|O|O|O|O| |0 +-+-+-+-+-+-+-+-+ 1| |O|O|O|O|O|O|O|1 +-+-+-+-+-+-+-+-+ 2| | |O|O|X|X|X|X|2 +-+-+-+-+-+-+-+-+ 3| | | |O|X|X|X|X|3 +-+-+-+-+-+-+-+-+ 4| | | | |X|O|O|X|4 +-+-+-+-+-+-+-+-+ 5| | | | | |O|O|X|5 +-+-+-+-+-+-+-+-+ 6| | | | | | |O|X|6 +-+-+-+-+-+-+-+-+ 7| | | | | | | |X|7 +-+-+-+-+-+-+-+-+ 0 1 2 3 4 5 6 7 - Question:
- Can I see an example of OthelloBoard.alternation and OthelloBoard.hasMove?
- Answer:
-
0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ 0|O|O|O|O|O|O|O| |0 +-+-+-+-+-+-+-+-+ 1| |O|O|O|O|O|O|O|1 +-+-+-+-+-+-+-+-+ 2| | |O|O|X|X|X|X|2 +-+-+-+-+-+-+-+-+ 3| | | |O|X|X|X|X|3 +-+-+-+-+-+-+-+-+ 4| | | | |X|O|O|X|4 +-+-+-+-+-+-+-+-+ 5| | | | | |O|O|X|5 +-+-+-+-+-+-+-+-+ 6| | | | | | |O|X|6 +-+-+-+-+-+-+-+-+ 7| | | | | | | |X|7 +-+-+-+-+-+-+-+-+ 0 1 2 3 4 5 6 7 Testing alternation: alternation(0,0,0,1)= alternation(1,1,0,1)= alternation(2,2,0,1)=X alternation(3,3,0,1)=X alternation(4,4,0,1)=O alternation(5,5,0,1)=X alternation(6,6,0,1)=X alternation(7,7,0,1)= alternation(0,-1,0,1)= alternation(1,0,0,1)= alternation(2,1,0,1)= alternation(3,2,0,1)= alternation(4,3,0,1)= alternation(5,4,0,1)= alternation(6,5,0,1)= alternation(7,6,0,1)= Testing hasMove: hasMove(0,0,0,1)= hasMove(1,1,0,1)= hasMove(2,2,0,1)= hasMove(3,3,0,1)= hasMove(4,4,0,1)= hasMove(5,5,0,1)= hasMove(6,6,0,1)= hasMove(7,7,0,1)= hasMove(0,-1,0,1)= hasMove(1,0,0,1)= hasMove(2,1,0,1)=X hasMove(3,2,0,1)=X hasMove(4,3,0,1)=O hasMove(5,4,0,1)=X hasMove(6,5,0,1)=X hasMove(7,6,0,1)= - Question:
- In JUnit5 tests, is the setup method run before each test?
- Answer:
- Yes.
- Question:
- For OthelloBoardTest, what does the setup method do?
- Answer:
- See othelloBoardSetup.txt
- Question:
- About the submit schedule...
- Answer:
-
Your goal should be working code by the intermediate deadlines. If it is not completely working, submit what you have no matter what. You can fix code and submit later as well, up until the final due date. We will be marking your attempt to adhere to the submit schedule separately from the final, working version of the code. We will check that you add, commit and push by the required dates. Some marks for just doing that with serious effort put into the code. More marks if the tests/mains work as described. This is a smaller fraction of the marks for the project. Most marks will be for the final state of the code. - Question:
- How much of the code can I change?
- Answer:
- You should not break any of the tests, not break any of the mains. You should modify the code to make it better, add methods, classes, modify access to methods, change things to/from static as it makes sense. Only do it if it makes the code better, but do it if it makes it better.
- Question:
-
How did you setup JUnit5 tests? - Answer:
-
I added the following to pom.xml
and then Maven->Reload Project to cause the dependencies to download. You can see the extra libraries in External Libraries.org.junit.jupiter junit-jupiter-api 5.10.2 test