projectmesa/mesa

Clean up HexSingleGrid(HexGrid) andHexGrid

jackiekazil opened this issue · 5 comments

Discussed in #1827

Originally posted by jackiekazil October 2, 2023
Why is the HexSingleGrid subclassed from HexGrid and HexGrid has nothing in it?
I was reading through the code and confused by this -- because it is also visible in the docs. Wondering if there was logical reason or if someone remembered why? I was thinking we should get rid of HexGrid or make it private.

See the following two lines -

class HexSingleGrid(_HexGrid, SingleGrid):

class HexGrid(HexSingleGrid):

Looks like it was changed in #1575 and #1581 by @Tortar early this year. Maybe he can give some more details on the motivation and implementation nuts and bolts.

Hi, the motivation to make Grid private was mainly due to the fact that only SingleGrid and MultiGrid should be used. For the same reasoning the HexGrid should have been splitted in two versions. To keep retrocompatibility though a simple subclassing trick was used so that to make HexGrid still usable. But when 2.0 was released, the HexGrid class could have been dropped

Ah also, class HexSingleGrid(_HexGrid, SingleGrid): shouldn't be removed, make it possible to use an HexGrid + max 1 agent per position