| CPSC 329 | Software Development | Fall 2026 |
In this group project, teams of three or four will add network play to the Hedgehogs game along with the hint feature originally slated for project P2.
Teams. You'll work in teams of three or four, starting from one teammate's P2 codebase. Teams: Ainsley, Andrae, Sebastian, William; Anik, Brooke, Henry.
Individual and team work.
The project reflection and peer evaluation (see Project Wrapup) are individual.
Everything else is a team task. The code and team deliverables must be entirely your team's work. Team code is assessed according to ownership.
No AI. Review the course AI policy for details.
Check-in meeting. One short check-in meeting is required by Friday 12/4. By that point, the skeleton (S1–S5) should be merged, a player should be able to join a game on the server (1.1, 1.2), a transcript's game should be able to play out on the client's board (2.1, 2.2), and (for the team of four) computing a hint (3.2) should be complete (using the stub). The check-in meeting isn't graded; its purpose is to make sure your team is on track. At least two team members should attend the meeting; ideally the whole team attends. Drop in during office hours — no appointment is necessary unless you are unable to make any of the scheduled office hours.
Hand-in meeting. A 20-minute individual hand-in meeting is required after handin of the whole project. These meetings will be scheduled before the due date and normally take place within a day or two of it. Be ready to walk through your own code and other deliverables. Also be ready to explain parts of your teammates' work as well as bigger-picture things like design decisions and your team's process. This isn't a quiz about content; it's to confirm that your handin reflects your own understanding and effort.
Due Friday 12/11 at 8am. Late handins are not accepted for projects, but an occasional 1-2 day extension is possible in case of a last-minute time crunch. (Plan ahead to avoid this!) See the late policy for details.
Local and network play. Players have the option to choose local play (everyone at one screen as in P2) or network play (each player at their own computer) when setting up a game. Local play works as it did in P2.
A playable game. Robustness issues and small bugs left over from P2 are OK, but anything large enough to interfere with being able to test a standard rules game with several players should be fixed.
Joining a game. For network play, the player specifies their game preferences (the number of players and the rule variants). The server matches waiting players into games and starts a game when enough players are waiting. While waiting, the player sees how many players have joined and how many are needed, kept up to date as players join and leave.
Team of three: the server hosts one configuration (number of players and rule variants), given on the command line when it is started. A player whose preferences don't match is told what the server hosts.
Team of four: the server keeps a separate waiting list for each configuration and each list starts its own game when it is full.
Simultaneous games. Several games can be in progress at once.
Variants. Network play supports the standard rules and the local game's variants that have the standard structure (sidestep and forward move). Variants that add a different kind of player action, such as Fizzy Lifting's lift, are extra credit in network play.
The server is in charge. The server holds the game, rolls the dice, and checks every move so that a modified or buggy client can't break the rules.
Ending a game. When a game ends, players can join a game to start a new one. The option of playing another game with the same players is extra credit.
Leaving and lost connections. A player can leave at any time. A player who leaves or loses their connection while waiting is removed from the waiting list. If a player leaves or loses their connection during a game, the game ends for everyone.
Robustness. The server should keep running no matter what a client sends or when it disconnects: a bad message gets an error reply and changes nothing. The client doesn't crash if the server sends something unexpected or disappears.
Server shutdown. (team of four; extra credit for the team of three) Typing quit on the server's console shuts the server down cleanly: it stops accepting connections, ends in-progress games, and waits for its threads to finish before exiting.
(required for the team of four; extra credit for the team of three)
Asking for a hint. A player can ask for a suggested move on their own turn: which hedgehog to sidestep, if any, and which hedgehog to move forward. The hint is a whole-turn suggestion based on the player's roll — it doesn't offer suggestions for sidesteps or forward moves separately.
Computed locally. The hint is computed on the player's own computer, using its copy of the game. Asking for a hint doesn't involve the server.
Variants. Hints are supported for every variant except Fizzy Lifting. (The hint generator never suggests a lift.)
Responsiveness and cancelling. The GUI stays responsive while a hint is being computed. A hint in progress can be cancelled and a hint that no longer applies (for example, because the player has already moved or the game has ended) is never shown.
Robustness. The program keeps working even if computing a hint fails.
(extra credit for all teams; requires the hint generator)
Computer player. A computer player that chooses its moves with the hint generator. In network play, the computer player is a separate program (a bot) that connects to the server and joins a game like any other player, using the same protocol. The bot needs no GUI — it can print what it is doing to the console.
Further extensions are possible, such as also offering a computer player in local play (each player is set up as a person or the computer) or having the server fill empty seats with computer players. Describe anything beyond the basic bot, and any protocol changes it needs, in docs/protocol.txt. In a GUI, the same properties apply as for the hint: the GUI stays responsive while the computer is choosing a move and a move that no longer applies is never made.
The parts of the UI that this project adds or changes are held to the same design principles as in P2: appropriate controls, visual hierarchy and grouping, feedback and visible state, preventing and explaining errors, and consistency. Feedback and visible state matter particularly here, since there is often something going on that the player is waiting for: the player should always be able to tell what the program is waiting for (other players to join, an opponent's move, the server's answer to their own move, a hint) and why a control isn't available.
Packages. The code is organized into these top-level packages, with subpackages as appropriate:
server and client may use model, hint, and shared, but they don't import anything from each other, and none of model, hint, or shared imports anything from server or client.
One model, used everywhere. The server and the client use the same model classes. The model has no JavaFX or other UI code and nothing about sockets or messages. Small additions to the P2 model functionality are fine.
Separation of responsibilities. Each class has a single job. In particular:
On the server, accepting connections, talking to one connected client, matching waiting players, and running one game are separate jobs.
On the client, the connection to the server (the socket, sending, and receiving), turning the server's messages into changes to the client's copy of the game, and the GUI's views and controllers are separate jobs.
The protocol's message syntax (building and parsing messages) lives in one place on each side. The classes that know the game's rules, match players, or run a game know nothing about sockets or message formats, so that they can be tested without a network.
MVC on the client. The client's GUI keeps P2's MVC organization. Local and network play differ only in how a player's intentions are carried out — use the same model and views for both. Information that only the client needs, such as which seat is at this screen or whether a request is waiting for an answer, isn't part of the shared model; it belongs with the part of the client that differs between local and network play, and views that show it are notified when it changes, just as they are for the model.
The hint code. The provided classes go in their own package, hint; don't change them. Implement HintableGame with a small adapter class rather than in the model's entry-point class and write your code in terms of the HintGenerator interface so that switching between the stub and the real generator is a one-line change.
Tests. There are JUnit tests for aspects of running a game on the server (a move out of turn or refused by the model is answered to that player only, an accepted move is reported to every player, and a player leaving ends the game for the others) with fake listeners standing in for the clients. The hint adapter (if implemented) passes the provided HintableGameTest. Tests for matching players and additions to the model are optional. The networking code and GUI code don't need automated tests.
The client and the server communicate with a line-based text protocol: each message is one line, made up of words separated by spaces, with the first word saying what kind of message it is. Part of the protocol is given below; your team designs the rest. Record the whole protocol in docs/protocol.txt.
The client replays the server's moves. The server never sends the contents of the board. Instead, it reports each roll and each move it accepts to all of the clients and each client applies them, in order, to its own copy of the game. Since the rolls are the only randomness in the game, every client's copy stays the same as the server's.
Requests and reports. A client only sends requests — it never tells the server what the state of the game is. The server checks each request to verify that it is legal. For any request refused, the server replies with an error and a reason to that client only and no game state changes. If the server accepts a request, it reports the move to every player in the game, including the one who made it; the report is that player's confirmation.
One request at a time. A client doesn't send another request until its last one has been answered (by a report of the move or an error), so it always knows which request an answer belongs to.
Given: joining and session messages. Client to server:
| Message | Meaning |
|---|---|
| JOIN name players rules | join a game; name is one word; rules is a word from your protocol's list of rule names |
| QUIT | leave |
Server to client:
| Message | Meaning |
|---|---|
| HELLO hedgehogs/1 | sent on connecting: the server speaks first |
| WELCOME name | joined; waiting for a game |
| WAITING have need | the number of players waiting for this game and the number needed; sent after WELCOME and whenever it changes |
| START players rules seat name1 name2 ... | the game is starting: the settings used, which seat (position in the turn order) is yours, and the players' names in turn order |
| GAME_OVER name | the game is over and name won; the server then closes the connection |
| ENDED reason | the game ended early (for example, a player left); the server then closes the connection |
| ERROR reason | your message was refused; nothing changed |
After HELLO, the client may send JOIN or QUIT. After WELCOME, the player is waiting and may only QUIT. After START, the game is in progress and the move messages apply. After GAME_OVER or ENDED, the server closes the connection. A message that isn't allowed in the current state gets an ERROR. A client always takes the game's settings from START, not from what it asked for in JOIN.
The tools are available in /classes/cs329/hedgehogs/tools.
These let you test the server and the client separately, before the other side is working. Import them into a separate package, tools. They are for testing only and don't use any of your other code.
LineClient: a general-purpose client for testing a server by hand. Run it with the server's host and port, then type protocol messages, one per line; each line the server sends is printed as it arrives. (It works like RiddleClient but sends whatever you type.) Type a line containing only a period to quit. Use it to test the server before the GUI client works.
ScriptServer: a fake server that plays a transcript file to one client, so you can test the client before the real server works. Run it with the transcript file's name (and optionally a port). When a client connects, it works through the transcript in order:
For example:
# a player joins a 2-player standard game and the other player leaves < HELLO hedgehogs/1 > JOIN alice 2 standard < WELCOME alice < WAITING 1 2 pause 3 < START 2 standard 0 alice bob pause 2 < ENDED bob left
When it reaches the end of the transcript, it closes the connection. Write transcripts from your protocol document, in the same notation as the protocol examples from class, so that they also serve as examples of your protocol.
(team of four; team of three if doing the extra credit)
The hint generator code is available in /classes/cs329/hedgehogs/hint. Import the classes into your project, making sure they end up in the hint package within your project's src folder.
Each class's comments have the details; in brief:
HintableGame: the interface the generator uses to play simulated games. Your adapter implements it. Its methods report the board size, the current player and their roll; check and make sidesteps and forward moves (or apply the rule for when no forward move is possible); end the turn; make a copy of the game; and report whether the game is over and who won. Read its comments carefully, particularly about coordinates, the order of calls in a turn, and what a copy must do.
HintGenerator: the interface for something that suggests a turn. Its one method, suggest, takes a HintableGame and a ProgressListener and returns a Hint. suggest stops early and throws an InterruptedException if the thread running it is interrupted. (This happens when a Task is cancelled, for example.)
MonteCarloHintGenerator: computes real hints. The number of simulated games per hint can be set: more games per hint gives better hints but takes longer; fewer games per hint gives faster, weaker hints (handy for testing). The default setting is intended to take a few seconds (enough to test GUI responsiveness and cancellation features); adjust as needed if things are running too fast or taking too long.
HintGeneratorStub: delivers a fixed hint (ignoring the game) while simulating the time it takes for a real hint to be computed (and reporting progress as it goes). It can also be set to fail partway through, so that you can check how your program handles a hint that fails. Use this instead of the real hint generator to develop the hint task before the adapter is done.
Hint: a suggested turn, which is an optional sidestep and a forward move. A hint may have just a sidestep (or no move at all) when no forward move is possible.
ProgressListener: receives the generator's progress reports, on the generator's thread. In a Task, pass them on to updateProgress or updateMessage.
HintableGameTest: JUnit tests for your adapter. All you need to do to use the tests is write a subclass that implements createGame(), as described in its comments.
How the generator works. For each possible turn, the generator plays many games to the end from the resulting position, making random moves for every player. It then suggests the turn that won most often for the current player. This is called Monte Carlo evaluation. More simulated games give a more accurate estimate, so time trades directly for quality. Assuming that everyone plays randomly for the rest of the game may sound hopelessly naive, but in games driven largely by chance, such as a dice race like Hedgehogs in a Hurry, this technique does surprisingly well. Its weakness is strategy — simulating many games means it plays much better than random, but it won't match a player who deliberately uses their moves to hinder opponents' hedgehogs and advance their own.
Do these tasks in order. The work is a single milestone: setup and kickoff, design and planning, build, wrapup.
Compared to P2, there's less step-by-step direction: each task below has a short description, what "done" means, and notes on things that are easy to get wrong. The rest is up to you.
This is a team task.
Hold your team kickoff meeting. Discuss availability (including known busy periods before the due date), the communication channel and how often each of you checks it, and work habits. Also schedule your team meetings for the whole project now, with dates and times: the lab periods count, plus enough other meetings that the team meets about twice a week. Short meetings are fine. Start the team log with an entry for this meeting.
Decide on a codebase. Pick whose P2 to continue with. Besides how complete and working it is, check the model for the things P3 depends on: a single entry point for changes, refusals with reasons, a way to give a game known dice rolls, and (for the team of four) how hard it would be to make a copy of a game for the hint generator. Record the choice and a sentence or two of reasoning in the team log.
Set up the repository as in P2 (B0): one person creates a new private GitHub repository named hedgehogs-net with everyone on the team and me (sbridgeman) as collaborators, the codebase owner pushes their P2 main to it, and everyone checks it out as a new Eclipse project named hedgehogs-net. Run the game and the tests to make sure everything works.
Copy the kickoff notes and team log into docs/team-kickoff.txt and docs/team-log.txt, and create the labels (size: S, size: M, size: L, joint).
Handin. Create a tag p3-start on main.
This is a team swarming task. Finish it before starting work on the skeleton.
Design the moves protocol.
Start with a sequence diagram. Sketch one turn of a two-player game as a sequence diagram, as in class: show both clients and the server and cover the start of the turn with the roll, one move the server refuses, and one it accepts. Base the steps of the turn on how your model divides one up (for example, a sidestep or skipping it, then a forward move) and use the same message for a request and its report. Each arrow is a message; note which go to one client and which go to both. A photo of a hand drawing is fine (docs/protocol-turn.png or .pdf).
Write it up. Collect the diagram's messages, plus the list of rule names used in JOIN and START. For each message, give its syntax and meaning. For each state of a turn, say which requests are allowed and what everything else gets back and give the order of the messages in a turn. The order must match the order of calls your model expects; in particular, a client must learn of each roll before it applies the step of the turn that uses it. (State diagrams for client and server can be helpful here.) Record the whole protocol, including the given session messages, in docs/protocol.txt.
Write transcripts. Write three short transcripts in the ScriptServer format (see Testing Tools) and put them in docs/transcripts/: a normal turn or two, a refused move, and a player leaving during a game. Each transcript is one client's side of a conversation like the one in your diagram. Writing them out is a good check on the protocol — if a transcript is hard to write, something is probably missing.
Agree on the new screens. Decide what the connect and waiting screens show and how the game screen shows whose turn it is, a move waiting for the server's answer, and (team of four) a hint in progress. A rough sketch or a few notes in the team log is enough.
Plan the work. Create a milestone named "P3", then:
Task issues. Create an issue for each task in the task list below, using the task names as issue titles. This includes the design tasks (D1–D3) — create their issues so that other tasks can depend on them, then close them right away if you've finished the design. Give each issue a size label (the suggested sizes are a starting point; adjust them if your team sees a task differently) and its owner(s), following the ownership rules below.
Review issues. Decide who does each designated review (see Reviews below) and create an issue for each one (for example, "Review 1.3"), assigned to the reviewer, with no size label.
Dependencies. Once all of the issues exist, record the dependencies with GitHub's issue relationships, as in P2: the "requires" from the task list and each review issue blocked by the task it reviews.
Plan summary. Put a short summary in docs/plan.txt: who owns what and each person's point total.
Handin. Create a tag plan-handin on main.
Task list. Tasks marked [T] involve a thread and tasks marked [N] involve a socket.
The dependency diagram shows an overview of the "requires" relationships: arrows point to the tasks a task requires, and dashed boxes are team of four only (extra credit for a team of three).
Design (joint, everyone; done in T0 and T1)
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| D1 | Choose a P2 codebase | S | — | the choice and the reasons for it are in the team log |
| D2 | Design the moves protocol | M | D1 | the sequence diagram, docs/protocol.txt, and the transcripts are in the repository |
| D3 | Agree on the new screens | S | D1 | a rough sketch or notes on the connect and waiting screens and the game screen's new states are in the team log |
Skeleton
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| S1 | Set up the packages and the provided code | S | D1 | the code is in the packages given in the specifications, the provided code is imported, and local play works |
| S2 | Local play through an intentions interface | M | S1 | the game controller carries out the play intentions through an interface with a local implementation; local play works exactly as in P2 |
| S3 | Client skeleton | M | S1 | setup offers local or network play; network play leads to a placeholder connect screen; the client's connection class exists with stub bodies; local play is unaffected |
| S4 | Model additions | S | D2,S1 | whatever the model needs that it doesn't have (known dice rolls; team of four: a copy of a game) is added |
| S5 | Server skeleton [T] [N] | M | S1 | the server accepts connections and handles each on its own thread: it sends HELLO hedgehogs/1, then answers every line with ERROR unknown message until the client disconnects; two LineClients connected at the same time are both answered |
Server
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| 1.1 | Message handling and connection states [N] | M | S5, D2 | each message is checked for form and against the connection's state, and anything malformed or not allowed gets an ERROR; QUIT works; each well-formed JOIN or move message reaches a handleX method, with a TODO where matching (1.2) or the game (1.3) will be called; tested with LineClient |
| 1.2 | Matching players [T] (team of three: one configuration; team of four: a waiting list per configuration) |
M (three) L (four) | 1.1 | whenever a waiting list's count changes (a player joins or leaves), everyone on that list is sent WAITING; when the list is full, everyone on it is sent START instead and the list starts over; a player who leaves while waiting is removed |
| 1.3 | Running a game [T] | L | S4, 1.1 | moves out of turn or refused by the model get an ERROR to that player only, accepted moves are reported to every player, and the game ends properly, including when a player leaves |
| 1.4 | Tests for running a game | S | 1.3 | the tests required by the specifications pass, using fake listeners |
| 1.5 | Server shutdown [T] [N] (team of four) |
M | 1.2,1.3 | quit on the server's console ends the games, closes the connections, and waits for the server's threads before exiting |
Client
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| 2.1 | Connection to the server [T] [N] | M | S3, D2 | the client connects, sends messages, and receives messages on a reading thread, handing each to the JavaFX application thread, and notices a lost connection; tested by playing a transcript with ScriptServer |
| 2.2 | Applying the server's messages | M | 2.1, S4 | the client state exists and every message from the server is handled: START creates the game, each report is applied to the client's model so a transcript's game plays out move by move on the board, the session messages update the client state, and an ERROR is shown to the player |
| 2.3 | Network play | M | S2, 2.2, D3 | the player's moves are sent as requests; the board and controls are enabled only on this player's turn and while no request is waiting for an answer, and the player can tell which |
| 2.4 | Connect and waiting screens [N] | S | S3, 2.2, D3 | the player can enter a name, the server's host, and preferences and join; the waiting screen shows WAITING; the end of a game (normal or early) and a lost connection are explained and lead back to the connect screen |
Hint (team of four; team of three if doing the extra credit)
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| 3.1 | Hint adapter | M | S4 | the adapter passes HintableGameTest |
| 3.2 | Computing a hint [T] | M | S1 | a hint is computed in a background task, can be cancelled, is never shown once it no longer applies, and a failure is reported |
| 3.3 | Hint UI | M | 3.2, D3 | the player can ask for a hint, see its progress, cancel it, and see the suggestion; the hint isn't available when it can't be used (not this player's turn, Fizzy Lifting) |
Integration (joint, everyone)
| # | Task | Size | Requires | Done when |
|---|---|---|---|---|
| I1 | Client and server together | M | the server and client tasks | no stubs or placeholders remain, and complete games play on one computer with several clients |
| I2 | Play-testing and bug fixing | M | I1 (team of four: also the hint tasks) | complete games play on separate computers; local play and (team of four) the hint still work; every bug found has been fixed or recorded |
Ownership.
Each task has one owner, except joint tasks, which are done together from start to finish by two or more people: a skeleton task can be joint if a pair does it and the design tasks and integration are joint for everyone who takes part. Give a joint task the joint label and assign everyone who shares it to its issue. Count S = 1, M = 2, L = 4 points, with a joint task's points split evenly among its owners.
Balance: each person's share is between 25% and 40% of the points for a team of three, and between 20% and 30% for a team of four.
Coverage: each person owns at least one task marked [T] and at least one marked [N] (one task marked both counts for both, and a task shared by a pair counts for both people).
Extra credit work gets its own issues in the milestone and doesn't count toward the balance.
Reviews. See Pull Request Reviews for how to do a review.
Each skeleton pull request is reviewed by someone who didn't write it, before it is merged.
Designated reviews: the pull requests for 1.1, 1.3, and 2.1 (team of three) or 1.2, 1.3, 2.1, and 3.2 (team of four) are each reviewed by someone who doesn't own the task, so that each person does one review. Create an issue for each review when you plan (for example, "Review 1.3"), assigned to the reviewer and blocked by the task it reviews, with no size label.
Other pull requests don't need reviews.
This is a team task. Follow the Team Process throughout; each issue is done on its own branch and merged through a pull request.
Build the skeleton. S2–S5 don't depend on each other, so they can be done at the same time once S1 is merged. Merge each as soon as it is reviewed — everything else builds on them.
Work through the task list. Until the other side is working, test the server with LineClient and the client with ScriptServer and your transcripts.
Check-in meeting. The check-in meeting (as described in Logistics) is required by Friday 12/4.
Integrate (I1, I2) together. Plan to play on separate computers in the last lab period. For each bug found, open an issue in the milestone and fix it on its own branch.
Task details and notes:
Packages (S1). Use Eclipse's Move refactoring to move P2's view, controller, and app packages under client, as in P2.
Local play through an intentions interface (S2). This is what makes "local and network play differ only in how a player's intentions are carried out" (see MVC on the client) true in the code. The game controller hands each move to an interface with a method for each intention (a sidestep, a forward move, and so on) instead of changing the model itself. The local implementation carries the move out on the model, as the controller did in P2; the network implementation (2.3) sends a request to the server instead, the way the auction client's controller hands a bid to AuctionProtocol rather than deciding it itself. Either way, the model notifies the views. Only intentions that change the game go through the interface; checking what's legal or what's on the board still reads the model.
Two things to address now so that the network version doesn't require another change:
Don't assume a move has happened when the call returns. If code in the controller or a view's event handler runs right after making a move and relies on its result, move it: something updating the display belongs in the views' response to the model's notifications and something changing the game belongs in the model.
In network play, the answer to a move comes later, from the server, so the interface's methods can't return it. Instead, each implementation reports a refusal itself: the local one as soon as the model refuses, the network one when the server's ERROR arrives.
Client skeleton (S3). This sets up the places the client tasks (2.1–2.4) fill in: a choice of local or network play in the setup screen, a placeholder connect screen for network play, and the class for the connection to the server (the auction client's ServerConnection) with stub methods. Have the send stub print the message to the console, so that requests can be checked before the connection is done. A label saying "connect screen goes here" is fine for the placeholder screen. Mark the stub methods with TODO, as in P2.
Model additions (S4). The server and every client use the same model code so the model has to do everything both sides need: the server uses it to check and make moves and each client uses it to replay the moves the server reports. This task fills in whatever your P2 model is missing for that. If it's missing nothing, S4 is just checking that (and saying so in the issue).
To work out what's missing, go through your protocol (D2) and for each message, consider which model method the server would call to check and make the move and which a client would call to apply the server's report. Things to look for:
Known rolls. Can you give a game a die whose next roll you set from outside? If the die is created inside the model, add a way to pass one in. A P1 or P2 test die may already do this.
Other randomness. Rolls must be the only random thing. If anything else is chosen randomly (such as who goes first), either make it fixed or add it to what the server reports.
Players by seat. The server needs to ask the model whose turn it is in terms of seats (positions in the turn order).
A copy of a game (if doing the hint). Changing the copy must not change the original.
Server skeleton (S5). This captures the structure of the main server class and the client handler, similar to AuctionServer and BidderHandler for the auction example or RoomServer and ClientHandler in lab 11. At this point the functionality of the handler is minimal: it sends the HELLO message and reads messages but responds to every one with ERROR. Also add (and use) a synchronized send method now rather than writing directly to the output stream — other threads will call it later to report other players' moves.
Message handling and connection states (1.1). This covers the incoming part of the handler's half of the conversation: it reads messages sent by the client and does the error handling for the protocol, checking that each message is valid (proper syntax and a known command) and allowed at this point in the conversation; anything with bad syntax, an unknown command, or not allowed in the current state gets an ERROR.
The code structure is that of the run and handleX methods in the auction's BidderHandler and lab 11's ClientHandler, except that for now the handleX methods do only the error handling — put a TODO comment in place of the actual work of handling each message. Be sure to cover leaving, both by QUIT and a lost connection — end the conversation and close the connection, with a TODO placeholder for additional handling needed in 1.2 and 1.3.
For the connection states, define an enum similar to Phase.
Matching players (1.2). The work of keeping track of the waiting players and handling players joining and leaving while waiting should be done by a lobby class similar to Room in lab 11. Replace the corresponding TODOs in the handler with calls to the lobby. Also define a listener interface (similar to AuctionListener and RoomListener in the auction and lab 11, respectively) for what the lobby needs to report to a connection; the handler implements it, sending the message and updating the conversation state accordingly.
Running a game (1.3). The work of keeping track of the current game — the model and whatever else is needed that the model can't know, such as which connection corresponds to which seat — and handling move messages and players leaving during the game should be done by a game class similar to Auction in the auction example. Replace the corresponding TODOs in the handler with calls to the game. Also define a listener interface (similar to AuctionListener and RoomListener in the auction and lab 11, respectively) for what the game needs to report to a connection; the handler implements it, sending the message and updating the conversation state accordingly.
Starting a game (1.2, 1.3). The lobby creates the game when the waiting list fills and each handler needs to know which game it is in so its move handling can call it. If 1.2 and 1.3 are worked on at the same time, agree on the game class constructor and how a handler is given its game first and record the decision in both issues.
Outcomes and listeners (1.2, 1.3). A refusal goes only to the player who asked and changes nothing, so the lobby or the game can return it (as Room.answer returns INCORRECT or Auction.bid returns its reason) and the handler sends the ERROR. Everything else changes something other players hear about, so the lobby or game tells each connection affected through its listener interface, while holding its lock, so that everyone hears about changes in the same order. That includes welcoming a player who joins even though that goes only to the player themselves: if the handler sent WELCOME after the lobby returned, the joiner could get WAITING or START before it.
Tests for running a game (1.4). Because the game class knows connections only through its listener interface, it can be tested without a network: give each seat a fake listener that records what it's told and check who was told what. A refused move shows up in the outcome the game returns (the handler sends the ERROR), with nothing told to anyone. Give the game known rolls (S4) so the tests are predictable.
Server shutdown (1.5). Note that the console needs a thread of its own to read quit, since the main thread is waiting in accept. Stop all of the server's threads (the accepting thread and every connection's thread) safely. This is similar to BidderHandler's sold, which ends a bidder's conversation and its thread.
Connection to the server (2.1). This is the auction client's ServerConnection: it owns the socket, sends lines, and runs a reading thread that hands each line it receives to one place on the JavaFX application thread, and reports a lost connection. It doesn't know what any message means. (Lab 11's ServerConnection is the same idea for a console client.)
To test it before 2.2 is done, the listener can just print each line; playing a transcript with ScriptServer should print the transcript's lines in order.
Applying the server's messages (2.2). This is the receiving part of the client's side of the protocol. The code structure is similar to the "reports" section of the auction's AuctionProtocol: a messageReceived method to parse the message, handleX methods to do the work of handling each message, and a handler for a lost connection.
Handling messages involves updating the client's state — the things other than the game itself that the client needs to keep track of, such as which seat is this client's. Since the views also need to see this information, it should go into a separate class similar to AuctionState. Define an enum for the client's conversation states (similar to Phase) there too. As in AuctionState, updating the state should notify the listeners (the views).
The protocol class keeps the client's game, creating it when START arrives and replaying the server's reports on it. Hand the new game to whatever starts a game in local play, so that the views are connected to it the same way as in P2.
Be sure to give the model each roll before applying the step of the turn that uses it.
Network play (2.3). This is the sending part of the client's side of the protocol. The code structure is similar to the "requests" section of the auction's AuctionProtocol with a request method for each move. Each request method checks the client state before sending (so it never sends a request out of turn or two at a time) and records that a request is waiting for an answer. The network implementation of the intentions interface (S2) just calls these methods, the way AuctionController calls AuctionProtocol.
Views that show the client-only state (whose turn it is at this screen, a request waiting for an answer) need to be notified when it changes, as for the model. In local play, the client state says every seat is at this screen and nothing is ever waiting for an answer, so the views can ask it the same question ("can the player at this screen act now?") in both modes.
Connect and waiting screens (2.4). This covers the parts of the GUI related to the session: joining a game, waiting for it to start, and the end of a game or of the connection, shown from the client state. Connecting can take a while, so don't do it on the JavaFX application thread; closing the window should leave (QUIT) and close the connection. Connecting and closing will be similar to AuctionApp.
Hint adapter (3.1). Create a small class to implement HintableGame rather than having the model's entry-point class implement the interface directly. Read HintableGame's comments about coordinates, the order of calls in a turn, and what a copy must do before writing any code.
The adapter handles any differences between your model and the interface, such as how tracks and columns are numbered or when the roll happens. (If it turns out that the adapter does nothing but call model methods with the same names, you can drop it and have the model implement HintableGame directly.) Like the rest of the model, the adapter has no JavaFX imports.
Computing a hint (3.2). A hint controller, with methods to start a hint and to cancel one. Handling the hint is similar to handling the solver in lab 9: starting a hint runs the hint generator in a background task on a copy of the game and a hint stops applying as soon as the game changes — a move by anyone, a new turn, the game ending. The controller passes the hint's progress, and then its result or its failure, to view methods, which are defined in this task as placeholders and implemented in 3.3.
Until 3.3, test by starting a hint whenever a turn begins at this screen and have the placeholder view methods print to the console. Moving before the hint finishes checks that a hint that no longer applies is cancelled. Mark this TODO, as in P2; 3.3 replaces it. Use HintGeneratorStub to check that a failed hint is reported, since the real generator can't be made to fail on demand.
Hint UI (3.3). The hint's views: controls for asking for a hint and cancelling it (which call 3.2's controller methods and are available only when a hint can be used) and the real bodies of 3.2's view methods, showing the hint's progress, the suggestion (on the board), or that it failed. This replaces 3.2's placeholders, and will be similar to the handling in lab 9.
This is a team task.
Check the protocol document. Make sure docs/protocol.txt describes the protocol as it was built, including anything added for extra credit.
Check the records. Make sure the team log is up to date and every completed issue in the milestone is closed. Remove any issue that is still open (a bug recorded but not fixed, unfinished extra credit) from the milestone, then close the milestone.
Handin. Create a tag p3-handin on main.
Each person also does the individual project wrapup (the reflection and peer evaluation).
This is an individual task.
Project reflection. Reflect on the design and process elements in this project, addressing the points below. Roughly 1–2 pages total; a paragraph per question is enough. Hand in a hardcopy of your reflection.
Peer evaluation. Complete the peer evaluation on Canvas.
Points to address in the reflection:
Tracing a move across the network. Pick one move, such as a forward move, and trace it through your code from the moment the player who makes it acts on their screen to when it appears on an opponent's screen. At each step, name the class and method and the thread that runs it (the JavaFX application thread, a client's reading thread, or a connection's thread on the server).
Threads. Pick one place in your code where something is protected because more than one thread uses it. What is that protection and what could go wrong without it? Describe a specific sequence of events.
The protocol. Which parts of designing the moves protocol (the sequence diagram, the write-up, the transcripts) were most useful and why? Did any of them (or building and testing) turn up something the initial design had missed or gotten wrong? If so, what was it and how did you find it? If not, what about your design process do you think helped you get it right the first time?
Process.
How did building the server and the client separately against the protocol (testing with LineClient and ScriptServer) work out? Did any issues come up when the client and the server were first used together?
Did the designated reviews that you did (and received, if any) turn up anything? Was this a useful part of the process?
Teamwork. How has working in a larger team changed things? What worked well in how your team coordinated (meetings, the log, issues and dependencies) and what would you change?
Be honest and thoughtful — whether you found something useful or not won't affect your grade. What matters is what the experience taught you about software development.
These are the end results your work is assessed against (see Assessment). Team code is assessed according to ownership.
A playable game, locally and over the network. Local play works as it did in P2. Complete network games can be played with the supported variants, with several games going at once. Bugs left over from P2 are OK if they don't get in the way of testing.
Network play. Players can join, play, and leave network games and see the outcome, as described in Network Play. The server runs each game and the clients follow it, as described in Protocol. Neither side crashes because of what the other sends or a lost connection. (Team of four) The server shuts down cleanly.
Hints (team of four). A player can get a hint on their turn without the GUI freezing and a hint that is cancelled, no longer applies, or fails causes no trouble (see Hints).
UI design. The new screens and states follow the UI Design Requirements so the player is never left wondering what is going on.
Extra credit (team of three): server shutdown and hints. Extra credit (all teams): network play for variants with a different kind of player action (such as Fizzy Lifting), playing another game with the same players, and a computer player (and extensions of it), with any protocol changes described in docs/protocol.txt.
Coding standards followed — autoformatted with the course's Eclipse formatter settings, standard Java naming conventions (a trailing underscore on instance variables is allowed, but must be used consistently), meaningful names, and Javadoc for every public class and method.
Design and code organization as described in Design and Code Organization.
Protocol documented. docs/protocol.txt describes the whole protocol as built, as laid out in T1, including anything added for extra credit.
Thread safety. Anything that more than one thread uses is protected, on the server and on the client, and the client changes the model and the GUI only on the JavaFX application thread.
Tests. The JUnit tests described in Design and Code Organization are there, and all tests pass on main.
Clean up done. No stubs or placeholders remain.
Follow the steps in each task and the practices in the Process section.
Protocol design. The sequence diagram, the write-up in docs/protocol.txt, and the three transcripts are done as described in T1. The protocol document is brought up to date in T3.
GitHub flow. All code changes are made on branches and merged through pull requests after main has been merged into the branch, main always passes all tests, and commits are incremental with meaningful messages, crediting partners when pair programming.
Planning and ownership. Each task in the task list is an issue in the milestone with a size label and owner(s), each designated review has an issue assigned to the reviewer, and the dependencies are recorded. Ownership meets the balance and coverage rules in T1, the plan summary is complete, and any change of owner is recorded.
Reviews. Each skeleton pull request is reviewed before it is merged. Each designated review is done, covering the threads as well as the usual categories, and its issue is closed. Anything a review finds is fixed or answered.
Team meetings and records. Meetings happen as your team scheduled them and the team log is kept up to date (with date, attendees, decisions, and open questions for each meeting). Decisions affecting the project are recorded in the log or in issues.
The team process is generally the same as in P2, with changes noted below.
Team kickoff and log. The kickoff is described in T0. Keep the team log as before, with an entry for each meeting (date, who attended, decisions, and open questions).
Planning. The tasks and suggested sizes are given in the T1 task list, so there are no independent estimates, and you don't need to record actual sizes in pull requests. Size labels are for balancing the work (use the ownership rules in T1).
Ownership. If a task changes owners, update the issue's assignees and docs/plan.txt, and note the change and the reason in the team log. Balance and coverage still apply.
Testing. Separate test plans aren't required. Write the JUnit tests required by the specifications as part of the tasks they belong to.
Version control. Follow GitHub flow as in P1 and P2: each issue on its own branch; before opening a pull request, merge main into the branch and make sure all tests pass; include Closes #n in the pull request description. Files in docs/ can be committed directly to main.
Reviews work as in P1 (see P1 Pull Request Reviews for the steps on GitHub and in Eclipse), with two kinds of review in this project (see Reviews in T1 for which pull requests are reviewed):
Skeleton reviews happen before the merge. Select the reviewer under "Reviewers" when you open the pull request. Since everything else builds on the skeleton, review these quickly — within a day.
Designated reviews don't hold up the merge. The author merges as usual; the reviewer reviews the pull request when they can, even if it has already been merged, and closes the review issue once the review is submitted. If the review finds something to fix, the author fixes it in a new issue and pull request (or replies to the comment with the reason for not changing it).
Besides the usual categories (correctness, standards, tests, readability), check the threads in a designated review: Which threads run each part of the code? Is everything that more than one thread uses protected? On the client, does everything that changes the model or the GUI happen on the JavaFX application thread?
Your final code is only part of what is assessed. Each item below is created at the point given in the task steps, and together they record your process as well as the end result. Commit history and handin tags provide the timestamps.
On Canvas:
In the team repository:
Hardcopy:
Most of the handin happens along the way, through the tags listed in Deliverables. To finish:
When the whole project is complete, create the tag p3-handin on main (T3).
Make sure that I (sbridgeman) have collaborator access to the repository (hedgehogs-net). (This should have been set up in T0.)
Complete the peer evaluation on Canvas and hand in a hardcopy of your project reflection (see Project Wrapup).
The course projects together account for 50% of your final grade in this course. There are two distinct components to the project grade:
Program and deliverable quality. (15%) Does the program correctly implement the specification and are the other deliverables complete and done properly (not just present)? This is assessed individually (on your own work for individual tasks and on your owned tasks for team code, with joint tasks counting for each owner and team deliverables counting for everyone on the team) and is graded against the stated program, code, and process requirements — a program missing functionality or crashing on bad input, documentation that's missing or incomplete, or process steps that weren't followed fall short here.
Skills standards. (35%) Your work also provides evidence towards the following skills standards. These are assessed directly from your deliverables, and some may be followed up on briefly in the handin meeting, where you may be asked to explain a specific choice you made. Skills standards are assessed individually; evidence comes from your own work (your individual tasks, the team tasks you own, and the reviews you do) and from team deliverables, which count for everyone on the team.
Client-server protocol design — design a protocol that specifies each message's syntax and meaning, the order of the messages, and how errors are handled. [sequence diagram, docs/protocol.txt, transcripts; reflection]
Reasonable class decomposition — divide the server and the client into classes with clear, separate jobs. [S5, 1.1–1.3, 2.1–2.3]
Server-side sockets and client-side sockets — implement each side of a working client-server exchange. [S5, 1.1; 2.1, 2.4]
Multi-client server with threads — handle each connection on its own thread, with the data the connections share protected. [S5, 1.2, 1.3]
Client reading thread — receive the server's messages on a separate thread and hand each to the JavaFX application thread. [2.1, 2.2]
Using Thread and using Runnable . [S5, 2.1, 1.5]
Diagnosing a race condition and applying synchronization — recognize what more than one thread uses and protect it. [S5, 1.2, 1.3, designated reviews, reflection]
Implementing a background task and progress feedback — keep the GUI responsive while work runs on another thread, and show its progress. [2.4 (connecting); team of four: 3.2, 3.3]
Waiting for and stopping threads (team of four) — stop threads safely and wait for them to finish. [1.5]
MVC separation — keep the client's MVC organization, with local and network play differing only in how intentions are carried out. [S2, 2.2, 2.3, reflection]
Observer-based notification — the client state notifies the views, and the server's lobby and game report to connections through listener interfaces. [1.2, 1.3, 2.2, 2.3]
Task-centered UI design and building with controls and layout managers — design and build the new screens and states so that the player can always tell what the program is waiting for. [D3 notes; 2.3, 2.4, 3.3]
Defensive programming and exception handling — check every message and move, and handle bad input, lost connections, and failures without crashing. [1.1, 1.3, 2.1, 2.2, 3.2]
Identifying real issues in review and communicating review feedback — review a pull request for correctness, standards, tests, and threads, and give constructive feedback. [skeleton and designated reviews you do]
Branching and merging and pull requests — do each task on its own branch and merge it through a pull request, with incremental, meaningful commits. [commit history and pull requests]
Merge conflict resolution. [commit history]
Project planning — use task sizes and dependencies to divide and plan the work. [issues and milestone, docs/plan.txt]
Applying a coding standard. [code]
Writing Javadoc — document each public class and method clearly enough that someone could use it without reading its code. [code]
Writing JUnit tests and identifying and testing edge cases . [1.4]
Test doubles — use a test double to test code independently of a collaborator. [fake listeners and known rolls in 1.4]
In addition, teamwork is part of the course engagement grade. Teamwork conduct is assessed through a structured peer evaluation at the end of the project (see Project Wrapup) with your team log and GitHub activity as supporting evidence.