5 ms·
So, it's an Nx(NxN/2) half grid. This is easily solved on the implementation side by making sure, for example, that the enum values for the second 2 arguments a
by snovv_crash 5y ago
So, it's an Nx(NxN/2) half grid. This is easily solved on the implementation side by making sure, for example, that the enum values for the second 2 arguments are always in ascending order.
- thaumasiotes 5y ago> So, it's an Nx(NxN/2) half grid. No, it's an NxN grid. Look at the second half of my comment. > This is easily solved on the implementation side by making sure, for example, that the enum values for the second 2 arguments are always in ascending order. So that when somebody invokes your function and passes the defender's types in the order listed for the Pokemon rather than sorting them beforehand, you crash?
- superdimwit 5y agoYou can just define a generic fallback method like `eff(p, d1, d2) = eff(p, d2, d1)`
- snovv_crash 5y agoWell the real issue is that we're using N instead of A and D. It is A X (D X D / 2). And why the sudden helplessness? Just sort the 2 arguments before passing them to the internal Impl.
- thaumasiotes 5y ago> Well the real issue is that we're using N instead of A and D. It is A X (D X D / 2). No, it isn't. It's AxD, where A and D are always equal. There is no reason to add another dimension to the result table when the defense or offense might pick up another type. The expanded table will never contain any more information than the two-dimensional table already does. (Dividing by 2 isn't correct either, even from your perspective; you're forgetting about the table's diagonal. In the "space is no object" approach you're advocating, the diagonals need to be filled by special-casing, since they represent a phenomenon that doesn't exist (a Pokemon which bears multiple instances of the same type) and obscure a phenomenon that does exist (a Pokemon which bears fewer types than the maximum possible number).)