cswinter / CodeCraftGame

The CodeCraft programming game.
http://www.codecraftgame.org
35 stars 10 forks source link

Single player games never call terminate() or send out GameClosed events #10

Closed magneticflux- closed 6 years ago

magneticflux- commented 6 years ago

This prevents detection of ended singleplayer games that are running headless.

Code that works:

    val controllers = Seq(TheGameMaster.level4AI(), TheGameMaster.level4AI())
    val simulator = new DroneWorldSimulator(TheGameMaster.defaultMap.createGameConfig(controllers))

    simulator.graphicsEnabled = false
    simulator.framerateTarget = 1001
    simulator.run(10000)
    println(simulator.winner)

Code that doesn't work, but should:

    val controllers = Seq(TheGameMaster.level4AI(), TheGameMaster.level4AI())
    val simulator = new DroneWorldSimulator(TheGameMaster.defaultMap.createGameConfig(controllers))

    simulator.graphicsEnabled = false
    simulator.framerateTarget = 1001
    simulator.run(Int.MaxValue)
    println(simulator.winner)

(Technically it would work, but running all Int.MaxValue iterations would take a while.

cswinter commented 6 years ago

This should be fixed by https://github.com/cswinter/CodeCraftGame/commit/e85ac8f523711b8738be2c2581988fd32ef9a2b2.

cswinter commented 6 years ago

Actually I'm not sure it does now. Still getting reacquainted with the code :)

cswinter commented 6 years ago

Looks like it does work after all...