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

70.2K

Verified Solution

Question

Electrical Engineering

Programming assignment for ENSC 3213

NIM

The program is to be written in Matlab. Program must beliberally 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-zerointegers. These will constitute how many counters are in eachPile.

The machine then asks who goes first.

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

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

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

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

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

Answer & Explanation Solved by verified expert
4.2 Ratings (729 Votes)
    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students