[Bug] Instant draw on empty or filled maps (FIXED)

5 replies [Last post]
Wuzzy
Wuzzy's picture
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 2012-06-20
Posts: 1301

In Hedgewars 0.9.22, if you start a game on an empty map or a map full of land, the game will instantly draw.
Hedgewars fails to spawn any hedgehogs because of lack of land (or space) to place the hedgehogs. And because there are no hedgehogs to begin with, it's an instant deaw.

This is of course annoying and I consider this a bug. Hedgewars should be able to start the game regardless of the map.

My suggestion to fix this goes like this:
If Hedgewars was unable to place all hedgehogs using the usual method, it will forcefully modify the landscape like this:
For each hedgehog which could not be spawned, it creates a girder (preferably horizontal) at a random place. The hedgehog is then spawned on that girder.

To guarantee that this works on maps with too much land as well, all land which may be around the girder is removed first.

With this simple algorithm it should be now guaranteed that the all hedgehogs can spawn regardless on how much or how few land we have on the map.

On an empty map, the game would then start with some randomly placed girders.
On a map filled with land, the game would start with holes with girders and hedgehogs in it.
Please note that it should not matter which kind of map is used, the algorithm should always be used if it is needed.

Hi, I am a Hedgewars developer. Smile

nemo
nemo's picture
User offline. Last seen 15 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861

I'm of the opinion this doesn't need fixing. My reasoning is that completely empty or completely full maps are pathological cases. The hedgewars behaviour right now when there is too little land for the # of hogs given seems a decent way to handle a shortage of space that is made use of by players already (like, putting 16 hogs on a small map).
Adding a bunch more girders wouldn't really improve that I think.

Completely filling a map you have to go out of your way to do. Empty map is easier to do by accident... I could perhaps be sold on falling back an empty map to, say, enabling bottom border. In fact... *adds*

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 2012-06-20
Posts: 1301

Okay, nemo has just implemented the feature. But instead of girders, nemo used flowers. xD

Screenshots:
Empty map:

Full map:

This is actually pretty cool, thanks.

EDIT:
Okay, there are still situations where there can be an instant draw. If you have a map which is almost full but has a tiny hole, but this hole is too small to fit any hog in, then the game does not place any hogs and still draws instantly.

On the other hand, if the map is almost empty but has a tiny speck of land, the game places all hogs onto it.

The flowers only seem to appear on a completely full or empty map.

Sad Smiley

Hi, I am a Hedgewars developer. Smile

nemo
nemo's picture
User offline. Last seen 15 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861

As noted prior, I like the existing hedgewars behaviour of placing close together on small amounts of land, and people have come to rely on this. So I put this in just as a fallback.

Can offer settings/lua option to toggle the standard hedgewars behaviour off I guess (that is, set TryHard to false causing this generation to be attempted more frequently).

This hole spawning is less reliable than TryHard so it could cause hogs to fail to spawn more frequently if that was done. (I just tweaked it so it shrinks distance between hogs if it keeps failing to place, though)

I was unable to reproduce the "almost completely filled" map behaviour reported above.

BTW, here's what a map stuffed full of hogs and with TryHard turned off looks like.
http://m8y.org/hw/hw_2015-12-31_15-10-2410478.jpeg

In current version they'd be all on the land surface.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 2012-06-20
Posts: 1301

Funny, currently the “almost filled” map thing can't be reproduced by me either now.

Probably you already accidentally fixed it in the meantime. xD

Well, I think this problem is fixed.

Hi, I am a Hedgewars developer. Smile

nemo
nemo's picture
User offline. Last seen 15 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861

Heh. Not AFAIK. I only did the one commit before trying to reproduce. Maybe you were testing code pre-commit and then did make install after w/o noticing? ☺

If you want to try and roll back to that commit w/o the tiny recent tweak, feel free, buuuut I'm skeptical it'll change anything.

Anyway, not worth worrying about.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]