C# Please This assignment is building the core of a two-player new game called,
ID: 3752627 • Letter: C
Question
C# Please
This assignment is building the core of a two-player new game called, linear domination. The first part (due Sept 24) is you algorithm design/document with data structures and core math for how you will compute the key required methods. No code is due, but pseudo-code is a good/common part of the documentation. This is expected to be 3-4 pages of text with likely a few drawings. Can be ascii, pdf or doc. It should be in your program2 repo as well, with the repo name in what you upload here. If your project is a team, each of you should upload the documntation plus 1 page on who did what for the design.
The rules of the game are as follows:
The game board is a grid of NxN cells and starts empty.
Players alternate turns.
Players play a “line” by choosing a pair of “empty” cells specifying start then end as “sr sc er ec”; both cells must be empty, cannot be in a row or column used as start/end in the past K turns (even if invalid), and the angle of the line formed by the pair must not be parallel to any line already played.
If the player’s line is parallel to an existing line, the line is removed, and the other player plays. If the line is not parallel, then the line connecting the two points is marked with the player’s color including flipping any cells on the line that are another color. Starting at the highest/leftmost point of the line, the line is drawn as the set of cells as one steps to each successive cells (row/column) positions whose value closest to the line path.
In advanced play, all moves are made in advance, visualizing the game in your head, and the resulting file fed into the scoring program as a file.
Play/scoring continues until either both players make an invalid (parallel) play or no free cells remain.
The winner is the person with the most marked cells. Ties are possible.
For the assignment, you will implement the core of the game.
Define an array for the game board, with a method for generating the board of size N and another for printing/display. For this assignment, you should use “printing” to display the board and use X and O for the two players. (This makes grading easier)
Define a method accepting input for play, which needs to allow input from a file at least as described below.
Define a representation for lines played in the game.
Define a method for testing each play for validity (empty end cells and not parallel to previous plays).
Define a method for flipping the cells in the grid.
Define a method for computing/display the current score.
Define a control method that calls the other methods, displaying the game board after each play.
Test your game with the five input files that will be provided (two provided now, three more provided 9/22) as well as 2 test files of your own.
Input format:
N K
sr1 sc1 er1 er1
sr2 sc2 er2 er2
…
srK scK erK erK
This assignment may be done in a pair or by yourself. If done as a pair both must upload a zip that includes the code/documentation, your test files, your output files, and also includes a personal statement of who did what and how the grade should be split. Documentation should include the git repo for the project (which can be from either of the pair).
1.txt:
5 0
1 1 5 5
1 5 5 1
2 1 4 5
1 2 5 4
3 1 3 5
1 3 5 3
4 1 2 5
1 4 5 2
5 3 2 4
4 2 3 5
3 2 4 3
2.txt
5 3
1 1 5 5
3 4 4 3
2 1 4 3
1 2 5 4
2 5 4 5
3 1 2 3
1 2 5 4
2 1 4 5
Explanation / Answer
When a player visits the connection page and puts in a username and email, the browser window will be redirected to the game view.
Let’s write the markup for the game view. Open the play.html file and paste the following code:
The code above defines the layout of the game view but does not contain any interactivity or realtime features. In the scripts section, before the closing body tag, we included the Vue and Pusher libraries because they are required for the game to work.
Let’s include the JavaScript code that will drive the entire game process and define its logic.
In the same file, add the code below in between the script tag that is just before the closing body tag:
Replace the PUSHER_APP_* keys with the keys on your Pusher dashboard.
Above, we create a new instance of Vue and we target the #app selector. We define all the defaults in the dataobject and then in the create() function which is called automatically when the Vue component is created, we check for a user and assign the user to the username if one was supplied.
We also make calls to the subscribe and listeners methods. Let’s define those inside the methods object. Inside the methods object, paste the following functions:
In the subscribe method, we subscribe to our Pusher presence channel, and then subscribe to the private channel for the current user. In the listenersmethod we register the listeners for all the events we are expecting to be triggered on the private channel we subscribed to.
Next, we will add other helper methods to our methods class. Inside the methods class, add the following functions to the bottom after the listenersmethod:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.