Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Individual Project: Make a Battleship game using MATLAB (User vs User and Computer vs Computer.) Computer vs Computer should have different strategies:1. always guess randomly2. guess randomly at...

1 answer below »
Individual Project: Make a Battleship game using MATLAB (User vs User and Computer vs Computer.)
Computer vs Computer should have different strategies:1. always guess randomly2. guess randomly at checkerboard3. Strategy 1 + try to sink the enemy's boat after a hit4. Strategy 2 + try to sink the enemy's boat after a hit
Answered 6 days After Nov 02, 2021

Solution

Sathishkumar answered on Nov 09 2021
119 Votes
battleship/comp_computer.m
clc
clear all
close all
x{1}= [1,1,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,2,0,0
0,0,0,0,0,0,0,2,0,0
0,0,0,0,0,0,0,2,0,0
0,0,3,3,3,0,0,0,0,4
0,0,0,0,0,0,0,0,0,4
0,0,0,0,0,0,0,0,0,4
0,5,5,5,5,5,0,0,0,4
0,0,0,0,0,0,0,0,0,0];
x{2}= [0,0,0,0,0,0,0,0,0,0
0,0,0,4,4,4,4,0,0,0
0,0,1,0,0,0,0,0,0,0
0,0,1,0,0,0,0,3,0,0
0,0,0,0,0,0,0,3,0,0
0,0,2,0,0,0,0,3,0,0
0,0,2,0,0,0,0,0,0,0
0,0,2,0,0,0,0,0,0,0
0,5,5,5,5,5,0,0,0,0
0,0,0,0,0,0,0,0,0,0];
x{3}= [0,0,1,1,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0
0,0,2,2,2,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0
5,5,5,5,5,0,0,3,0,4
0,0,0,0,0,0,0,3,0,4
0,0,0,0,0,0,0,3,0,4
0,0,0,0,0,0,0,0,0,4
0,0,0,0,0,0,0,0,0,0];
x{4}= [5,0,0,0,0,0,0,0,0,1
5,0,0,0,0,0,0,0,0,1
5,0,0,0,0,0,0,2,0,0
5,0,0,0,0,0,0,2,0,0
5,0,0,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,2,0,0
0,0,0,0,0,0,0,2,0,0
0,0,0,0,0,0,0,2,0,0
0,0,4,0,0,5,5,5,5,5
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here