AllureOfTheStars / Allure

Allure of the Stars is a near-future Sci-Fi roguelike and tactical squad combat game written in Haskell; please offer feedback, e.g., after trying out the web frontend version at
http://allureofthestars.com
GNU Affero General Public License v3.0
214 stars 16 forks source link

Game seems to play itself and triggers GNOME Shell's "is not responding" dialog #119

Open HebaruSan opened 2 years ago

HebaruSan commented 2 years ago

Problem

I just stumbled on this game while browsing apps randomly in my Ubuntu system menus. I'm quite interested in Haskell and Roguelikes, so this seems like a really neat project. But so far this is what I get:

image

It looks like the numerals are the player's squad members (I browsed the documentation a bit but not a lot), based on the cursor movements hovering on them, but they're moving around by themselves rather than waiting for player input. It looks like an AI autoplay mode has been triggered automatically.

I eventually noticed the prompt at the top and tried pressing a key, but nothing happened. All I can seem to do is Force Quit.

Suggestions

Mikolaj commented 2 years ago

Hi! Thank you for the report. That's most likely a bug, probably of the SDL graphics library, that blocks any key and mouse input. Which Ubuntu version is this?

Could you experiment a bit with commandline options? Run Allure --help in the terminal and try a few combination. E.g., --frontendANSI would run entirely in the terminal and so rule out the problem with SDL. Or --gameMode crawl would not start one of the AIvsAI modes but the crawl mode, so the player should be in control from the start. Once you start in such a mode once, you should be in control until you cede it intentionally or until the game ends.

HebaruSan commented 2 years ago

Sorry, I realized belatedly that you'd want system info and was in the process of grabbing it:

image

I'll experiment with those options and report back...

HebaruSan commented 2 years ago

--frontendANSI doesn't exist, so I might have an older version than expected.

$ Allure --frontendANSI
Invalid option `--frontendANSI'

Usage: Allure [--newGame N] [--knowMap] [--knowEvents] [--knowItems] 
              [--showItemSamples] [--exposePlaces] [--exposeItems] 
              [--exposeActors] [--sniff] [--allClear] [--boostRandomItem] 
              [--gameMode MODE] [--automateAll] [--keepAutomated] 
              [--stopAfterSeconds N] [--stopAfterFrames N] [--printEachScreen] 
              [--benchmark] [--setDungeonRng RNG_SEED] [--setMainRng RNG_SEED] 
              [--dumpInitRngs] [--dbgMsgSer] [--gtkFontFamily FONT_FAMILY] 
              [--sdlFontFile FONT_FILE] [--sdlScalableSizeAdd N] 
              [--sdlBitmapSizeAdd N] [--scalableFontSize N] [--fontDir FILEPATH]
              [--logPriority N] [--maxFps N] [--disableAutoYes] [--noAnim] 
              [--savePrefix PREFIX] [--frontendTeletype] [--frontendNull] 
              [--frontendLazy] [--dbgMsgCli] [--version]
  Configure debug options here, gameplay options in configuration file.
$ Allure --version
0.9.5.0

I see the repo is up to v0.11.0.0, so my apologies if this was already fixed. I'll try compiling the repo next...

--gameMode crawl seems to wait for user input but still triggers "is not responding":

image

Mikolaj commented 2 years ago

Oh, right, I forgot how ancient the version in Ubuntu is. It even has a known error for which the fix is still not applied in Ubuntu (but it's not the one).

It would be great if you tried compiling, feel free to ask questions here if there are any snags.

Another option is to download a linux binary, which may or may not work on your new Ubuntu. See the Releases github subsection.

In this Allure version --frontendTeletype is the (very ugly) terminal-only option. You may require Enter after each keystroke. Please let me know if this one accepts input.

I'd love to work around the SDL bug (it's not present in my old Ubuntu, but I've had reports about it), so any experiments would be very useful. E.g., perhaps newer Haskell SDL bindings (the ones you'd use when compiling yourself) eliminate the problem. Or perhaps upgrading SDL fixes it (downgrading certainly does, but that's hard to do). Or perhaps I can tweak something.

HebaruSan commented 2 years ago

The github build instructions from the README didn't work for me:

image

$ cabal run --project-file=cabal.project.LH.dir 
Resolving dependencies...
cabal: The run command is for running a single executable at once. The target
'' refers to the package Allure-0.11.0.0 which includes the executable
'Allure' and the test suite 'test'.

Adding Allure to the end seemed to get past that.

In a separate terminal I started the cabal install instructions, and that has been stuck on Building LambdaHack-0.11.0.0 (lib) for several minutes now. How long does it usually take? Never mind, that finished without problems. I guess the answer is "several minutes plus a bit more" :wink: .

HebaruSan commented 2 years ago

(Deleted the previous comment about running the custom compile. It hadn't actually finished, and I was running make play from the other terminal where I ran cabal install. It was in the Allure project folder, though.)

Mikolaj commented 2 years ago

Yes, cabal 3.0 is ancient. I could fix instructions for cabal run to be more portable, as you suggested, but I can't replace list-bin. Oh, I even say "version 3.4 or later is required" in the README.

HebaruSan commented 2 years ago

My custom compile of the code from GitHub is worse; it still says "not responding", but now I can't even move the window.

HebaruSan commented 2 years ago

How do I pass --frontendANSI through the cabal run command? Without quotes it thinks it's a flag for cabal, and with quotes it doesn't recognize the command as valid:

$ cabal run --project-file=cabal.project.LH.dir Allure --frontendANSI
cabal: unrecognized 'run' option `--frontendANSI'

$ cabal run --project-file=cabal.project.LH.dir 'Allure --frontendANSI'
cabal: Unrecognised target syntax for 'Allure --frontendANSI'.
Mikolaj commented 2 years ago

Thank you for the experiment. I guess I mixed up too different methods in the README. One for official version from Hackage, using cabal install and the other, for unofficial version straight from the repo using cabal run. Which you did you end up experimenting with?

HebaruSan commented 2 years ago

I'm trying both in parallel, which admittedly is causing some confusion, but primarily focusing on the unofficial version from the repo right now.

HebaruSan commented 2 years ago

The final output from the cabal install command was:

Starting     Allure-0.11.0.0 (exe:Allure)
Building     Allure-0.11.0.0 (exe:Allure)
Installing   Allure-0.11.0.0 (exe:Allure)
Completed    Allure-0.11.0.0 (exe:Allure)
cabal: installdir is not defined. Set it in your cabal config file or use
--installdir=<path>

I wasn't sure whether that was a warning or an error, but trying the next step suggests error:

$ ~/.cabal/bin/Allure
-bash: /home/user/.cabal/bin/Allure: No such file or directory

~/.cabal/bin exists but only contains my xmonad.

Mikolaj commented 2 years ago

I just tried and this works cabal run --project-file=cabal.project.LH.dir Allure -- --frontendANSI. However, make play would find the binary for you and so you wouldn't need cabal run, which tries to compile again. If cabal is too old, you can find the binary manually inside the repo. It's called Allure and has executable bit set. You can run it directly.

Mikolaj commented 2 years ago

cabal: installdir is not defined probably comes from your ~/.cabal/config being even older than your cabal. Perhaps remove ~/.cabal/config so that it gets regenerated?

HebaruSan commented 2 years ago

I just tried and this works cabal run --project-file=cabal.project.LH.dir Allure -- --frontendANSI

Thanks! That worked for me as well, and spacebar took me to the menu where I could turn off autoplay. My replies may slow down now that I'm trying out the gameplay...

Mikolaj commented 2 years ago

My custom compile of the code from GitHub is worse; it still says "not responding", but now I can't even move the window.

Still sounds like a broken SDL and, given that your GHC is probably ancient, it prevents the use of the new Haskell SDL bindings that have some workarounds for SDL bugs. If, at some point, you'd like to to experiment more, please consider installing new cabal and new GHC using https://www.haskell.org/ghcup/.

No rush, however, have fun playing (some people prefer the terminal interface, though it has some features turned off and the map aspect ratio is far from 1:1).

HebaruSan commented 2 years ago

Still sounds like a broken SDL and, given that your GHC is probably ancient,

In case the details would be useful:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4

Latest seems to be 9.2.4, so maybe not as bad as some of the others?

it prevents the use of the new Haskell SDL bindings that have some workarounds for SDL bugs. If, at some point, you'd like to to experiment more, please consider installing new cabal and new GHC using https://www.haskell.org/ghcup/.

OK, I'll try that, thanks.

cabal: installdir is not defined probably comes from your ~/.cabal/config being even older than your cabal. Perhaps remove ~/.cabal/config so that it gets regenerated?

That successfully installed ~/.cabal/bin/Allure, but it still does the "not responding" thing. I assume for the same SDL related reasons.

No rush, however, have fun playing (some people prefer the terminal interface, though it has some features turned off and the map aspect ratio is far from 1:1).

Heh, fortunately I'm very comfortable playing Roguelikes in a non-1:1 aspect ratio. When I started with Nethack it was the only option available.

I guess ultimately this amounts to an FYI that Ubuntu users will be having a poor user experience at the moment. Thanks for all the help in solving what would have taken me days if ever.

Mikolaj commented 2 years ago

I guess ultimately this amounts to an FYI that Ubuntu users will be having a poor user experience at the moment. Thanks for all the help in solving what would have taken me days if ever.

My pleasure. I await any other feedback you may feel like sharing in the future. When I get any news of the SDL situation, I will update this ticket.

HebaruSan commented 2 years ago

I GHCup'd my system, but ~/.ghcup/env put its new paths at the end of $PATH :facepalm:, so I was still running the older cabal until I flipped it.

I deleted dist-newstyle to force a rebuild, but it still seems to have some kind of problem with the event loop:

image

These are the APT packages that I have with sdl in them:

image

I don't know which of those is important or out of date, but they're all whatever is current in Ubuntu 22.04.

Mikolaj commented 2 years ago

Thank you for checking. If your cabal --version and ghc --version show what we expect, I'm almost sure your new setup doesn't use the Haskell packages from Ubuntu, in particular the old bindings from libghc-sdl2-dev. If so, only the libsdl2-* packages from your list are relevant. The fact you still have the problem probably means the workarounds in the newest Haskell bindings to SDL don't help. The newest SDL is 2.0.22

https://www.libsdl.org/download-2.0.php

which is available for Ubuntu (but this may break your system) here

https://launchpad.net/ubuntu/+source/libsdl2

It is possible they fixed it, but far from guaranteed (I haven't read the changelogs).

Mikolaj commented 2 years ago

The cheapest workaround in Allure we could try is change the line

ghc-options: "-with-rtsopts=-A99m -I5"

in Allure.cabal to

ghc-options: -threaded "-with-rtsopts=-A99m -I5"

Low chance of success, but hey, it's only one line. :)

I can't check easily, because in my ancient Ubuntu with its old libsdl2, I have no problems of that kind (and I never had any for a decade). And I can't install a newer libsdl2, I'm already using a version years ahead of my distribution precisely to debug the errors libsdl, libfreetype and OpenGL did introduce in the past.

P.S. It won't rebuild anything, just re-link, so the experiment should be fast.

HebaruSan commented 2 years ago

Here's what GHCup gave me:

$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library 
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7

Oddly I still can't drop the target name from the run command:

$ cabal run --project-file=cabal.project.LH.dir 
Resolving dependencies...
cabal: The run command is for running a single executable at once. The target
'' refers to the package Allure-0.11.0.0 which includes the executable
'Allure' and the test suite 'test'.
Click to expand the part where I edited the file wrong Cabal doesn't seem to like the `-threaded` flag: ![image](https://user-images.githubusercontent.com/1559108/181829996-4c07ccca-9c13-49fb-ab28-a5913d36027f.png) ``` $ cabal run --project-file=cabal.project.LH.dir Allure Build profile: -w ghc-8.10.7 -O1 In order, the following will be built (use -v for more details): - Allure-0.11.0.0 (lib:this-game-content) (configuration changed) - Allure-0.11.0.0 (lib:this-game-src) (configuration changed) - Allure-0.11.0.0 (exe:Allure) (configuration changed) Configuring library 'this-game-content' for Allure-0.11.0.0.. Preprocessing library 'this-game-content' for Allure-0.11.0.0.. Building library 'this-game-content' for Allure-0.11.0.0.. on the commandline: warning: unrecognised warning flag: -Winvalid-haddock : warning: [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - LambdaHack-0.11.0.0 Configuring library 'this-game-src' for Allure-0.11.0.0.. Preprocessing library 'this-game-src' for Allure-0.11.0.0.. Building library 'this-game-src' for Allure-0.11.0.0.. on the commandline: warning: unrecognised warning flag: -Winvalid-haddock Configuring executable 'Allure' for Allure-0.11.0.0.. Preprocessing executable 'Allure' for Allure-0.11.0.0.. Building executable 'Allure' for Allure-0.11.0.0.. on the commandline: warning: unrecognised warning flag: -Winvalid-haddock ghc: unrecognised flag: -threaded -with-rtsopts=-A99m -I5 Usage: For basic information, try the `--help' option. ```

I think I'm going to draw the line at updating SDL manually, since that might risk breaking other software.

HebaruSan commented 2 years ago

Oh, I did the quotes wrong. Hold on, will retry.

... same:

image

Mikolaj commented 2 years ago

Thanks a lot for verifying. Oh well.

Oddly I still can't drop the target name from the run command

OK, that must have changed in the pre-release cabal I'm running. In that case, README needs to be fixed by adding that "Allure" target at the end, just as you suggested.

8.10.7

I'd recommend 9.2.*, which ghcup gives you if you insist in ghcup tui. There's a slight chance this may help via transitive version dependencies.

I think I'm going to draw the line at updating SDL manually, since that might risk breaking other software.

It may indeed and recovering is a frantic mix of apt, dpkg, etc.

HebaruSan commented 2 years ago

I'd recommend 9.2.*, which ghcup gives you if you insist in ghcup tui. There's a slight chance this may help via transitive version dependencies.

Cool (and that tui is a surprisingly nice app), but Allure is still "not responding".

Mikolaj commented 2 years ago

Thank you again. I appreciate it.

Mikolaj commented 2 years ago

Note to self: I'm going to leave cabal run --project-file=cabal.project.LH.dir in, because it works in cabal 3.8.1.0, 3.6.2.0 and 3.4.1.0 and only fails in older versions.

Ark74 commented 8 months ago

Hello! I have reached here by having the same issue with MATE and X11 on Trisquel 11.0 which is Jammy 22.04 based.
I've fixed the issue by backporting libsdl2_2.26.5+dfsg-1 from bookworm.

On the other hand, backporting allure from bookworm version: 0.11.0.0

It required to also add the following dependencies in order to build allure_0.11.0.0-1;

  1. lambdahack_0.11.0.0-2
  2. libghc-call-stack-dev_0.4.0-1
  3. libghc-call-stack-doc_0.4.0-1
  4. libghc-call-stack-prof_0.4.0-1
  5. libghc-hunit-dev_1.6.2.0-1
  6. libghc-hunit-doc_1.6.2.0-1
  7. libghc-hunit-prof_1.6.2.0-1
  8. libghc-lambdahack-dev_0.11.0.0-2
  9. libghc-lambdahack-doc_0.11.0.0-2
  10. libghc-lambdahack-prof_0.11.0.0-2
  11. libghc-witch-dev_1.0.2.0-1
  12. libghc-witch-doc_1.0.2.0-1
  13. libghc-witch-prof_1.0.2.0-1

It takes a bit of work, but at the end, you can get the latest on a jammy based distro.

Mikolaj commented 8 months ago

Yay, congrats. Any idea where the root cause of the problems lies? A bug in SDL2 or the libsdl2 bindings or an incompatibility between versions of things or something else entirely?

Ark74 commented 8 months ago

Well, seems like there is a bug in the jammy sdl2 version that may be causing the issue as even the bullseye one is working. So something there is weird. :raised_eyebrow: