Mathcad Community Challenge November 2025 - You Sank My Battleship!
Recently, I was in the position of trying to explain to a 6- and 8- year old how to play the board game Battleship. (Kids from my generation had commercials that seemed to explain the basics of the game fairly well.) While trying to explain the concept of the grid to them and search algorithms, I couldn’t help but wonder, “How could this be done in Mathcad Prime?”

This month’s challenge, should you choose to accept it, is fairly open-ended: simulate various aspects of the Battleship game in Mathcad. Here are some suggestions:
-
Write a program that will place the ships on the ocean grid. The ships must be placed horizontally or vertically; no diagonals. Ships can’t overlap one another. Do you place the ships randomly or according to some kind of optimized algorithm?
-
Alternatively, can you use Advanced Input Controls to allow the user to place the ships on the ocean grid?
-
Display the placement of the ships using the plotting capability.
- Write an algorithm for hunting the ships. Do you use something like a random walk? A standard grid search? Your own preferred algorithm from when you were a kid?
- Alternatively, use Advanced Input Controls to let the user enter their own coordinates. Use these same controls to provide feedback to the user on hit or miss. (Note: David Newman and I discussed whether you could use Advanced Input Controls for the user to enter guesses and have Mathcad keep track of previous shots. David said that it doesn't work like that. I thought you could append new guesses to an existing matrix; if that doesn't work, I think the brain power we have in the community can figure out a way. That have surprised me before.)
-
Display the hits and misses on a plot or chart.
-
Can you program Mathcad Prime to run through a number of iterations of placing and hunting ships, and then evaluate statistics on number of shots needed to sink the fleet?
Again, these are just suggestions. Feel free to create a worksheet that tackles any aspects of the classic board game. Do as little or as much as you like. Also, your worksheet should stand on its own; a stranger should be able to open it and understand what it’s for.
For the sake of this challenge, we will use the following ships:
- Aircraft carrier 5
- Battleship 4
- Cruiser 3
- Submarine 3
- Destroyer 2
It’s a kids game, so have fun with this!
Find the Mathcad Community Challenge Guidelines here!

