This takes place on a 10 x 10 grid with a sub (2 squares), destroyer (three squares), cruiser (4 squares), aircraft carrier (5 squares) and a 6 square battleship. 20 squares in total occupied out of the 100. Note that ships can be aligned horizontally, vertically and diagonally. The picture shows a typical layout.
- S - Sub 2 Squares
- D - Destroyer Three Squares
- C - Cruiser. Four Squares
- A - Aircraft Carrier - Five Squares
- B - Battleship - Six Squares.
- Chris Greth - C++ Score = 499573 Time(secs) = 0.1438715
- Makis Tsintsikloglou (Greece) - C# Score = 505059 Time(secs) = 5
- Dennis Muhlstein (USA) - C++ Score = 594706 Time(secs) = 0.742978
- St0le (India,20) - C++ Score = 650186 Time(secs) = 0.254
- Pedro Graca (Portugal) - C Score = 788276 Time(secs) = 0.854
- Michael Chock - C++ Score = 4522920 Time(secs) = 1497
- Link to Rock, Scissors and Paper Bot Ongoing Programming Challenge - Runs weekly.
- Link to Programming Challenge 2 - Count the Islands. (Finished)
- Link to Programming Challenge 3 - Manage Elevators. (Finished)
- Link to Programming Challenge 4 - Guess the Mastermind Code - (Finished)
- Link to Programming Challenge 5 - Squeeze words into a crossword grid - (Finished)
- Link to Programming Challenge 6 - Guess the Mastermind Code - (Finished)
- Link to Programming Challenge 7 - Validate Chess Positions - (Finished)
- Link to Programming Challenge 8 - Score Poker Hands - (Finished)
- Link to Programming Challenge 9 - Manage a Data structure - (Finished)
- Link to Programming Challenge 10 - Hide Text (Finished)
- Link to Programming Challenge 11 - Match Sets of Cards (Closed)
- Link to Programming Challenge 12 - Calculate Shortest Path - (Closed)
- Link to Programming Challenge 14 - Calculate Large multiplications - (deadline End of July 2008)
To win a game you have to correctly identify all 20 squares.
This programming challenge requires you to write code that reads a file of boards, play each board and then outputs how many shots it took to sink all five ships on all boards. It goes without saying that although your program knows how where the ships are, the ai routine you write must not cheat.
The input file is called boards.txt and contains 10,000 lines of 102 characters. Each line is exactly 100 characters long and has a . for an empty location and S, D, C, A or B plus a carriage return (0xd) and line feed (0xa) at the end of the line.
This is what the file looks like:
.......B.....S...B....S....B.........B.........B..Except I've split it over two lines to fit in here.
C.DDD..B.A.C......A...C....A.....C..A........A....
Download the Data file. This is a zip file about 123Kb in size.
Your program must read the boards.txt file* and from each line create one grid of ships. Your AI routine should then play against this grid and keep track of how many shots it took to sink all the ships in all 10,000 boards.
Note: (Thanks to William Fishburne who raised this). When you register a hit, your code can both identify the type of ship hit and whether this sank that ship. This was changed from the original specification in the challenge on June 22 2008.
Output
Please output the following text.
Total Shots to sink all ships = 398,645
Obviously the figure will be your total.
*Note: The file supplied is for your testing. I will compile and run your program with another file with 10,000 other boards. You can assume that all 10,000 boards will be legitimate to the specification I've given. Each line will be exactly 100 chars long using only the characters .SDCAB plus a carriage return/line feed to separate each 100 char line. (ie 102 chars * 10,000).
Results
Thank you to all six who entered. Congratulations to first place Makis Tsintsikloglou from Greece who managed to just beat Chris Greth's score. Makis wasn't the fastest but it was the score (total number of shots) that decided. One entry sadly never completed and is still running...Congrats also to Chris Greth, Dennis Muhlestein and St0le for very fast programs.
All entries were compiled with Microsoft Visual C++ or C# 2008 and ran in release mode.


