1. Homepage
  2. Programming
  3. CPS506 Comparative Programming Languages - Project: Simulate a game of War

CPS506 Comparative Programming Languages - Project: Simulate a game of War

Engage in a Conversation
CanadaRyerson UniversityCPS506Comparative Programming Languages Simulate a game of WarSmalltakHaskhellRust

Preamble CourseNana.COM

CPS506 Project Description CourseNana.COM

Suddenly, there was War! CourseNana.COM

In this project, you will simulate a game of War. War is a simple card game between two players. A description of the game and its rules can be found here: CourseNana.COM

https://bicyclecards.com/how-to-play/war CourseNana.COM

Given the above description, there are still some situations that are ambiguous. They will be clarified in the game description below. CourseNana.COM


CourseNana.COM

CourseNana.COM

You will complete this project in three of the four languages we study in this course. The languages chosen are up to you. In addition to the general requirements of the project, each language comes with its own language-specific constraints. These specify the format of the input and output, as well as submission instructions for each language. CourseNana.COM

Aside from these requirements, anything you do inside your program is up to you. Use as many helper functions or methods as you want, use any syntax you find useful whether we covered it in class or not. There is one exception to this: you may not use any functionality that is not part of the base installation of each language. No 3rd party libraries. Your submission will be tested using out-of-the-box installations of each language. CourseNana.COM


CourseNana.COM

CourseNana.COM

Game description CourseNana.COM

The game starts with a shuffled deck of cards. The deck will be passed into your program already shuffled (details below). The cards are dealt in an alternating fashion to each player, so that each player has 26 cards. CourseNana.COM


CourseNana.COM

CourseNana.COM

In each round, both players reveal the top card of their pile. The player with the higher card (by rank) wins both cards, placing them at the bottom of their pile. Aces are considered high, meaning the card ranks in ascending order are 2-10, Jack, Queen, King, Ace. CourseNana.COM


CourseNana.COM

CourseNana.COM

If the revealed cards are tied, there is war! Each player turns up one card face down followed by one card face up. The player with the higher face-up card takes both piles (six cards – the two original cards that were tied, plus the four cards from the war). If the turned-up cards are again the same rank, each player places another card face down and turns another card face up. The player with the higher card takes all 10 cards, and so on. CourseNana.COM


CourseNana.COM

CourseNana.COM

When one player runs out of cards, they are the loser, and the other the winner. If, during a war, a player runs out of cards, this counts as a loss as well. CourseNana.COM


CourseNana.COM


CourseNana.COM

Technical details CourseNana.COM

Input: The input to your program, representing a shuffled deck of cards, will be a permutation of 52 integers, where each integer between 1-13 occurs four times. The integers in this permutation correspond to cards according to the following table (four kings, four tens, four threes, and so on). Notice that we don’t bother representing the suit because the game of War doesn’t require it. CourseNana.COM

1 CourseNana.COM

2 CourseNana.COM

3 CourseNana.COM

4 CourseNana.COM

5 CourseNana.COM

6 CourseNana.COM

7 CourseNana.COM

8 CourseNana.COM

9 CourseNana.COM

10 CourseNana.COM

11 CourseNana.COM

12 CourseNana.COM

13 CourseNana.COM

Ace CourseNana.COM

2 CourseNana.COM

3 CourseNana.COM

4 CourseNana.COM

5 CourseNana.COM

6 CourseNana.COM

7 CourseNana.COM

8 CourseNana.COM

9 CourseNana.COM

10 CourseNana.COM

Jack CourseNana.COM

Queen CourseNana.COM

King CourseNana.COM

The game: Your program will deal two piles from the input permutation. How you represent your piles is completely up to you. Once the piles are dealt, “play” the game in your program until one player runs out of cards. Once again, how you manage your piles during the game is completely up to you. Keep going until one player runs out of cards. CourseNana.COM

When cards are added to the bottom of a player’s pile, they should be added in decreasing order by rank. That is, first place the highest ranked card on the bottom, then place the next highest ranked card beneath that. This is true of wars as well. If a player wins six cards as a result of a war, those cards should be added to the bottom starting with the highest rank and ending with the smallest. Ace has the highest rank, Two has the lowest. CourseNana.COM

Output: Your program will return the pile of the winning player. This pile should contain all 52 integers from the original input permutation and be in the correct order according to how the game played out. CourseNana.COM


CourseNana.COM

CourseNana.COM

Testing & Evaluation CourseNana.COM

Your code will be evaluated using an automated tester written by me. Therefore, it is of utmost importance that your code compile properly, handle input properly, and return results in the indicated format for each language. Do not deviate from the requirements or your code will fail the tester outright. Your code must compile and run as a baseline. Half- finished code that doesn’t compile or is riddled with syntax errors will not be accepted. CourseNana.COM

To help you achieve the baseline of “code that works”, you are provided with mix/cabal/cargo projects with a handful of simple test cases for Elixir/Haskell/Rust. For Smalltalk, I will provide a simple script you can paste into your Playground. The simple tests are to help you get started, but when I evaluate your final submission, I will be using a more sophisticated tester with more tests and more interesting shufflings. CourseNana.COM

Your grade for each project submission will be based primarily on the fraction of the tests for which your program returns the correct result. There are minor marks for code style, documentation, etc. The full rubric is below. CourseNana.COM

Marking Rubric
2 marks - Code style
CourseNana.COM

Your code is clean like this: CourseNana.COM

#include <stdio.h> int main()
{
CourseNana.COM

         printf(“Hello world!\n”); CourseNana.COM

} CourseNana.COM

3 marks - Documentation CourseNana.COM

Not messy like this: CourseNana.COM

#include <stdio.h>
int main() {
CourseNana.COM

printf(“Hello, World!\n”);;;; /* lol */ } CourseNana.COM

Document functions, control structures, and scope blocks. Do not document every line. Documentation should be meaningful. Don’t just say “This function deals the cards”. CourseNana.COM

5 marks – Code runs, does something CourseNana.COM

Your code compiles, without warnings! Compile warnings will cost you marks here. Your code runs and does something. At the very least, must accept the input correctly and return a proper permutation of the input. CourseNana.COM

5 marks – Created your own test cases CourseNana.COM

The simple tester provided for each language comes with five test cases. You must create five more, for a total of 10 cases in your submission. One mark per test case. CourseNana.COM

25 marks – Code passes tests CourseNana.COM

The remaining 25 marks are awarded to your code for passing all the tests my automated tester can throw at it. These marks are awarded proportionally. If your code passes 80% of the tests, you’ll get 20/25, and so on. CourseNana.COM

40 marks total Language requirements CourseNana.COM

The requirements of each language are evident from the code provided, but in brief, the input/output requirements are as follows: CourseNana.COM

Smalltalk: Create a class named War that implements a class method called deal. This method should accept and return an Array of 52 integers. CourseNana.COM

Elixir/Haskell: Implement a function called deal that accepts and returns a list of integers Rust: Implement a function called deal that accepts an immutable reference to an array of CourseNana.COM

u8, and returns ownership of a new array of u8. CourseNana.COM

If your code adheres to these constraints, it should play nice with my tester. Additionally, these constraints are already provided via function skeleton in the code provided for each language. All you must do is fill in the function, and not modify the parameters. CourseNana.COM

Submission CourseNana.COM

Projects must be submitted individually. CourseNana.COM

Smalltalk submission: To submit your Smalltalk assignment, you will submit the entire Pharo image directory as an archive (zip/rar/7z/whatever). To find your Pharo image directory, select the image in the launcher that contains your assignment, and look at the bottom of the launcher screen to see the “Location” directory. Zip up everything in this folder – not just the image. CourseNana.COM

Elixir/Haskell/Rust submissions: Submit your war.ex, war.hs, or main.rs file on D2L. You do not need to submit the entire mix/cabal/cargo project. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Canada代写,Ryerson University代写,CPS506代写,Comparative Programming Languages代写, Simulate a game of War代写,Smalltak代写,Haskhell代写,Rust代写,Canada代编,Ryerson University代编,CPS506代编,Comparative Programming Languages代编, Simulate a game of War代编,Smalltak代编,Haskhell代编,Rust代编,Canada代考,Ryerson University代考,CPS506代考,Comparative Programming Languages代考, Simulate a game of War代考,Smalltak代考,Haskhell代考,Rust代考,Canadahelp,Ryerson Universityhelp,CPS506help,Comparative Programming Languageshelp, Simulate a game of Warhelp,Smalltakhelp,Haskhellhelp,Rusthelp,Canada作业代写,Ryerson University作业代写,CPS506作业代写,Comparative Programming Languages作业代写, Simulate a game of War作业代写,Smalltak作业代写,Haskhell作业代写,Rust作业代写,Canada编程代写,Ryerson University编程代写,CPS506编程代写,Comparative Programming Languages编程代写, Simulate a game of War编程代写,Smalltak编程代写,Haskhell编程代写,Rust编程代写,Canadaprogramming help,Ryerson Universityprogramming help,CPS506programming help,Comparative Programming Languagesprogramming help, Simulate a game of Warprogramming help,Smalltakprogramming help,Haskhellprogramming help,Rustprogramming help,Canadaassignment help,Ryerson Universityassignment help,CPS506assignment help,Comparative Programming Languagesassignment help, Simulate a game of Warassignment help,Smalltakassignment help,Haskhellassignment help,Rustassignment help,Canadasolution,Ryerson Universitysolution,CPS506solution,Comparative Programming Languagessolution, Simulate a game of Warsolution,Smalltaksolution,Haskhellsolution,Rustsolution,