Zomis / Games

Many kinds of games, playable in both multiplayer or local play. Replays, spectator mode, and AIs.
https://games.zomis.net
MIT License
17 stars 5 forks source link

State seems to be stored in reverse order #284

Closed Zomis closed 2 years ago

Zomis commented 2 years ago

There is something that ends up being in reverse when it comes to state. For a new game, the following state is stored:

[ "E", "B", "D", "H", "A", "C", "G", "F" ]

But when running the game, it looks to be in the opposite order.

It doesn't matter that much at the moment, as at least it's consistent. But it still feels strange.

Zomis commented 2 years ago

This seems to be a feature and not a bug. Or rather, it seems to be intended behavior.

When using randomFromList, the values gets reversed by removing last and adding to new list:

        while (strings.isNotEmpty()) {
            val next = strings.removeLast()
            val item = remainingList.removeAt(remainingList.indexOfFirst { stringMapper(it) == next })
            result.add(item)
        }