<jupyter_start><jupyter_text>Tutorial on Battleship Package<jupyter_code>from battleship import Board<jupyter_output><empty_output><jupyter_text>The `Board` object is the primary interface for this game.<jupyter_code>help(Board)
# This magic command is necessary for interactive features 
%matplotlib notebook
board = Board(dim=10, ship_config='default', vis=True, playmode=True)<jupyter_output><empty_output><jupyter_text>custom ship placement It is possible to define ship placement via the `ship_config` parameter of the Board initializer.<jupyter_code>from battleship import Ship, Direction 

# Ship(name: str, length : int, head_location: (int, int), orientation : ship.Direction)  

ship_config = [Ship('destroyer', 2,  (9, 2), Direction.NORTH),
                Ship('submarine',  3,  (7, 6), Direction.SOUTH),
                Ship('cruiser',  3, (6, 9), Direction.WEST),
                Ship('battleship', 4,  (5, 5), Direction.WEST),
                Ship('carrier',  5, (2, 9), Direction.WEST)]  

board = Board(ship_config=ship_config, playmode=False)<jupyter_output><empty_output><jupyter_text>Expert system agents Use these two agents to gather performance metrics to use as baselines.  See if your RL agent can outperform them!<jupyter_code>from battleship import TrivialAgent, LessTrivialAgent 
%matplotlib notebook<jupyter_output><empty_output><jupyter_text>Trivial AgentTrivial solution of randomly probing until the game ends.<jupyter_code>board = Board(10)
agent = TrivialAgent(board)
agent.play_until_completion()<jupyter_output><empty_output><jupyter_text>Less Trivial Agent This agent leverages the idea that future successful hits will be near prior successful hits. The agent switches between two modes: searching and hunting. When searching, it randomly probes for a hit. Upon hit, it switches to hunting and will search the region around the most recent hit using a stored fringe queue. Once the fringe is empty, it will return to searching. This solution comes from this [blogpost](https://www.datagenetics.com/blog/december32011/).<jupyter_code>board = Board(10)
agent = LessTrivialAgent(board)
agent.play_until_completion()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09174311926605505, 'fraction_numerical': 0.011926605504587157, 'mean_word_length': 5.752321981424148, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '144941', 'license': 'MIT', 'n_tokens_mistral': 679, 'n_tokens_neox': 650, 'n_words': 206, 'path': 'Course_Material/tutorial-battleship.ipynb', 'repo_name': 'Quansight/Practical-RL', 'size': '2180'}