New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RandomPicker no longer accepts things that have probability zero or less #1100

Merged
merged 1 commit into from Sep 28, 2015

Conversation

Projects
None yet
2 participants
@henu
Contributor

henu commented Sep 28, 2015

I'm developing a game with my friend, that includes random level generator. The level generator works better, if I set terraintypes to as many tiles as possible. However, I don't want these tiles to appear when modifying terrain in Tiled, so I set their probability to zero. This causes problems, because things in QMap container in RandomPicker get overwritten.

In this pull request, I've modifier the RandomPicker class, so it ignores those things that have zero probability or less. It fixes the problem.

I tested it with stamp and bucket fill with random mode, and I also tested terrain tool. It didn't cause any problems, not even when I set everything to have zero or negative probability.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 28, 2015

Owner

Ah, good catch! Indeed without this check it will overwrite valid choices with values that should be impossible...

Owner

bjorn commented Sep 28, 2015

Ah, good catch! Indeed without this check it will overwrite valid choices with values that should be impossible...

bjorn added a commit that referenced this pull request Sep 28, 2015

Merge pull request #1100 from henu/master
RandomPicker no longer accepts things that have probability zero or less

@bjorn bjorn merged commit 9c2be76 into bjorn:master Sep 28, 2015

2 checks passed

continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 28, 2015

Owner

Looks like a nice game, btw. :-)

Owner

bjorn commented Sep 28, 2015

Looks like a nice game, btw. :-)

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 28, 2015

Owner

Btw, I Just noticed your tmx_sync tool. Did you try using external tilesets instead or would that solve only part of the problem?

Owner

bjorn commented Sep 28, 2015

Btw, I Just noticed your tmx_sync tool. Did you try using external tilesets instead or would that solve only part of the problem?

@henu

This comment has been minimized.

Show comment
Hide comment
@henu

henu Sep 28, 2015

Contributor

Damn, I didn't know there is such feature. I will try it as soon as I get to my machine again. It would be perfect, if I understood what you mean.

And thanks for merging! I was afraid this is considered too marginal case, but for us it is mandatory fix :)

Contributor

henu commented Sep 28, 2015

Damn, I didn't know there is such feature. I will try it as soon as I get to my machine again. It would be perfect, if I understood what you mean.

And thanks for merging! I was afraid this is considered too marginal case, but for us it is mandatory fix :)

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 28, 2015

Owner

It was a mandatory fix for Tiled too. :-)

You can export a tileset with the little Export button below the tileset view. You can then add that same tileset to other maps.

When you want to move your other maps over to refer to the same tileset, you could either choose to Export there too and then overwrite the external tileset file, or you could edit your maps in a text editor to change the tileset element to a reference to external tileset as you'll find in the first map file.

Owner

bjorn commented Sep 28, 2015

It was a mandatory fix for Tiled too. :-)

You can export a tileset with the little Export button below the tileset view. You can then add that same tileset to other maps.

When you want to move your other maps over to refer to the same tileset, you could either choose to Export there too and then overwrite the external tileset file, or you could edit your maps in a text editor to change the tileset element to a reference to external tileset as you'll find in the first map file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment