I’ve been trying to organize a small project using several modules. I am doing some experiments with a board game AI in this project. I have something like this:
module BoardModule export Board, valid_moves struct Board; ... end valid_moves(board) = ... end
module GameRunner export play_game include("BoardModule.jl") using .BoardModule play_game(player1, player2) = ... end
module PlayerModule export Player, move include("BoardModule.jl") using .BoardModule struct Player; ... end move(player::Player, board) = ... end
The idea is straightforward, game rules are implemented by the Board module, a GameRunner can run games between two players, and players are structs (which may contain some private state) and an overloaded move function which is called to ask the player what move they want to make. There may be several types of Players each making moves using different algorithms: minmax, MCTS, a neural network, etc. These various players are the heart of what I want to experiment with.
The problem is that, as far as Julia is concerned,
PlayerModule are not using the same
Board, so they can’t communicate.
GameRunner is using
PlayerModule is using
PlayerModule.BoardModule.Board; they’re different types, technically.
I don’t know how to reuse the
BoardModule? (I’m afraid the answer will involve creating several different git repositories for a single project.)
Taking a step back now. When I search for “how to organize Julia modules” I find: How to organise files and modules?
I would paraphrase the conclusion of that discussion to be: “It is ‘un-Julian’ to organize functions into several different modules.” Is this correct?