Unfortunately I found this assignment much more difficult than the previous one; therefore I couldn’t get the bingo card to work in the way that I would have liked it to.
I firstly randomly generated a 3x9 matrix as shown in the editor window print out, I am happy with this part as it works perfectly, with all the numbers being displayed in the right places with a full range of 1-90.
The problems started to arise when deleting the terms, I got it to work where it randomly deletes 4 terms in each row, however I could not produce a code that ensures that there is always 1 number in each row.
I then created a for loop, which selects the balls, we have to use the randperm function otherwise the balls would just come out in order from 1-90. Whilst in the for loop I used to the ismember function to cross check the balls that were drawn to the ones that have been produced on a card, this works by whenever number drawn (represented by B) is in the array it produces a 1 and when it is not in the array in produces a zero, therefore we can assign certain quotes for when the ismember term is zero or 1 e.g. if (I==0) then we can display sorry no match etc. I also assigned for each number the quote the bingo caller would say to make it more enjoyable for the user.
Unfortunately I couldn’t get the bingo card to distinguish when the player had won, I tried summing up the ismember terms so that when sum(I)==15 (which is the number of numbers in the card after terms had been deleted) displayed BINGO! However I could not get the code to work so I removed it.
Overall I am disappointed with the code itself as it doesn’t feature some of the main aspects that I would of liked, I am happy however that I eventually was able to be able to match terms and produce unique sayings for each number.