Question

In: Electrical Engineering

Programming assignment for ENSC 3213 NIM The program is to be written in Matlab. Program must...

Programming assignment for ENSC 3213

NIM

The program is to be written in Matlab. Program must be liberally commented.

The program is a game played by a human versus the machine.

At the start, the prompt asks the human to enter three non-zero integers. These will constitute how many counters are in each Pile.

The machine then asks who goes first.

A turn consists of selecting a Pile and taking a number of counters from that pile.

For example, if the Piles contain 3, 7 and 12 counters, a legal move consists of taking from 1 to 3 from Pile 1, or 1, 2, … 7 from Pile2 etc.

The object of the game is to be the player to take the last counter(s). So if Piles contain 0 2 0, the player whose turn it is will take 2 from Pile 2 and win.

The program must play and optimal strategy so if it has a winning position it will win the game. If it does not have a winning position it should try to extend the game.

At the end of the game, the program must declare the winner.

Solutions

Expert Solution


Related Solutions

This programming assignment will consist of a C++ program. Your program must compile correctly and produce...
This programming assignment will consist of a C++ program. Your program must compile correctly and produce the specified output. Please note that your programs should comply with the commenting and formatting described in the Required Program Development Best Practices document that has been discussed in class and is posted to the eLearning system. Please see this descriptive file on the eLearning system for more details. The name to use in the main configuration screen text box Name: [ ] in...
The following code must be written using matlab How to loop through a vector in matlab...
The following code must be written using matlab How to loop through a vector in matlab and assigning a value to every 4th entry. The vector could be of any length. Thanks
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals for position 1, position 2, position3 and position 4 of the array. After these first 4 positions are drawn. The whole thing should start over where position5 drawn from same interval as positions 1, position6 drawn from same interval as...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals in chunks of 4 , that is chunk1-chunk2-chunk3-chunk4 The parameters for specifying the lintervals by which the random numbers should be drawn should be able to change and be hardcoded in the script, however, be hardcoded in the script.
The following question must be answered in the C programming language and may not be written...
The following question must be answered in the C programming language and may not be written in C++ or any other variation. Problem 5 This problem is designed to make sure you can write a program that swaps data passed into it such that the caller's data has been swapped. This is something that is done very frequently in manipulating Data Structures. The Solution / Test Requirements I want your program to demonstrate that you understand how to swap information...
The following code must be written using matlab How to get the elements that are different...
The following code must be written using matlab How to get the elements that are different in two set without using the setdiff function in matlbab?
Assignment 1 – Writing a Linux Utility Program Instructions For this programming assignment you are going...
Assignment 1 – Writing a Linux Utility Program Instructions For this programming assignment you are going to implement a simple C version of the UNIX cat program called lolcat. The cat program allows you to display the contents of one or more text files. The lolcat program will only display one file. The correct usage of your program should be to execute it on the command line with a single command line argument consisting of the name you want to...
The deliverable for this assignment is a written report. You must address the following questions in...
The deliverable for this assignment is a written report. You must address the following questions in your analysis. Question 1: What prompted the pricing change in the case of Netflix and the debit card fee in the case of BoA? What explanation did the companies offer their customers? Do additional research as required to answer these questions. Question 2: What explains customers’ reactions to the pricing plan change announced by Netflix and the fee proposal announced by BoA? Include in...
Write a program in Basic to play the game of Nim with acom­puter.
Write a program in Basic to play the game of Nim with acom­puter.
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT