# Automapping works just once

**URL:** <https://discourse.mapeditor.org/t/automapping-works-just-once/418>\
**Category:** Bugs\
**Created:** [March 24, 2015, 1:29am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418 "2015-03-24T01:29:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monsaic](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/monsaic/32/1851_2.png) [@Monsaic](https://discourse.mapeditor.org/u/Monsaic)\
**Post date:** [March 24, 2015, 1:29am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/1 "2015-03-24T01:29:25Z")

</div>

Hey,  
first of all, thank you for Tiled! My favourite feature is the automapper. It works really well, but when I change the rules.txt while working in Tiled, the automapping feature seems to be disabled. Even if I change the txt contents to something invalid or if I delete the rules.txt, there’s no errormessage popping up. When I restart Tiled and put in the new rules.txt , it just works again.

Is that a common bug?

Here’s my workflow:  
Rule1 brings me from this  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/default/212/9dc33fa96dae7eb2.png)  
to that  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/default/213/58c92a40f0d1d822.png)  
Rule 2 replaces those tiles and applies some variation  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/default/214/1b482a508cd84978.png)

R1  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/default/215/ce68248a109fb7ff.png)  
R2  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/default/216/40cca4ffe9c02edf.png)

Keep up the good work.

~Monsaic

PS: I’m using Tiled 0.11  
PS2: I can only embed 2 images.

---

<div class="post-metadata">

**Author:** ![Stefan\_Beller](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/stefan_beller/32/3092_2.png) [@Stefan\_Beller](https://discourse.mapeditor.org/u/Stefan_Beller)\
**Post date:** [March 26, 2015, 8:47pm UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/2 "2015-03-26T20:47:21Z")

</div>

It’s been a long time I wrote that Automapping tool, so I forgot about the details.

which operating system do you use?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [March 26, 2015, 9:08pm UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/3 "2015-03-26T21:08:20Z")

</div>

> [@Monsaic](#):
>
> PS2: I can only embed 2 images.

I raised your trust level, please see if you can include more images in your post now.

---

<div class="post-metadata">

**Author:** ![Monsaic](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/monsaic/32/1851_2.png) [@Monsaic](https://discourse.mapeditor.org/u/Monsaic)\
**Post date:** [March 26, 2015, 9:56pm UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/4 "2015-03-26T21:56:10Z")

</div>

Thanks for your replies!  
@bjorn Yep, I can embed all the images now, thanks!  
@Stefan_Beller My operating system is Windows 8. I really love that feature and it’s a pity that I have to restart tiled everytime I change the rules.

---

<div class="post-metadata">

**Author:** ![sancho](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sancho](https://discourse.mapeditor.org/u/sancho)\
**Post date:** [August 28, 2018, 5:15am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/5 "2018-08-28T05:15:36Z")

</div>

This still seems to be an issue. I tried to find it in issues at Git repository but it is not there.  
Is there any info about this?  
I am using Win. 08, and the latest version of Tiled as per a week ago.  
Edit:  
This is also a problem with setting a tile probability. The change does not affect the paint bucket random unless you close Tiled and then reopen it again.  
Version 1.1.6

---

<div class="post-metadata">

**Author:** ![Monsaic](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/monsaic/32/1851_2.png) [@Monsaic](https://discourse.mapeditor.org/u/Monsaic)\
**Post date:** [August 28, 2018, 7:40am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/6 "2018-08-28T07:40:25Z")

</div>

Since the links don’t seem to be working anymore -\> I think these are the screenshots I took:

The steps:  
[![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/6/64be639603397c9971cf9991031abee9f964d664.png) ](https://dl.dropboxusercontent.com/s/kz2txyzkbiw6a9k/ex3%20a.png?dl=0)  
[![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/6/6e207f4e78515487efb53643a4807a712aeb4cad.png) ](https://dl.dropboxusercontent.com/s/0edzjhci5cpcbrv/ex3%20b.png?dl=0)  
[![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/2/28cb8c3d3ace94fc9670b1a2331c043157efd796.png) ](https://dl.dropboxusercontent.com/s/xqm64wy3e5htubu/ex3%20c.png?dl=0)

The rules:  
[![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/b/bea064318c44295daa0008dc24991d5bf22c6a5d.png) ](https://dl.dropboxusercontent.com/s/acpeerd38kldlw1/r1.png?dl=0)  
[![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/a/adac73eadad1c40d42065efe1f2fc68d584a5f24.png) ](https://dl.dropboxusercontent.com/s/yuhirn92bc2txly/r2.png?dl=0)

Best regards

Monsaic

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [August 28, 2018, 2:56pm UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/7 "2018-08-28T14:56:06Z")

</div>

> [@sancho](#):
>
> This is also a problem with setting a tile probability. The change does not affect the paint bucket random unless you close Tiled and then reopen it again.

This should be entirely unrelated to whatever problem is affecting the automapping. The probabilities are recalculated when the tile stamp changes, so after changing the tile probability it should be enough to re-select the tile stamp.

> [@Monsaic](#):
>
> It works really well, but when I change the rules.txt while working in Tiled, the automapping feature seems to be disabled. Even if I change the txt contents to something invalid or if I delete the rules.txt, there’s no errormessage popping up. When I restart Tiled and put in the new rules.txt , it just works again.

Hmm, I don’t see any reason why the automapping rules would work just once. Are you sure that’s what’s happening? What I do see in the code, is that the `rules.txt` file is only loaded once and not automatically reloaded when it changes (nor are any of the rule maps). The rules are cleared when another map is selected though, and then loaded again upon the first use of the automapping feature.

> [@Monsaic](#):
>
> Since the links don’t seem to be working anymore -\> I think these are the screenshots I took:

Yeah, it’s annoying the old images disappeared. I’m in contact with Discourse support and hope they’ll be able to restore them from an old backup. It’s impressive that you are able to relocate the images you uploaded three years ago!

---

<div class="post-metadata">

**Author:** ![sancho](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sancho](https://discourse.mapeditor.org/u/sancho)\
**Post date:** [August 29, 2018, 2:32am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/8 "2018-08-29T02:32:49Z")

</div>

Thanks for replying Bjorn.  
You are correct regarding the probabilities property. Here is why I thought it might be the same issue:  
I select two tiles and the paint tool and random. I can see even(ish) number of the two tiles. I edit the tileset and change one of the tiles probability to very low. Then I go back to my map and despite the tile showing the probability, it does not change the dispersment.  
To see the new dispersment, you do have to reselect the tile and thats really not a problem.

In order to reproduce the automap issue:

1. create a new tile map
2. create a rule for that tile map and test it to make sure it works.
3. without closing tiled go into the rules.txt and comment out all the rules.
4. test automap again, and you will see that the rules are applied same as in step 2 despite commenting them out.  
Note that you can even completely remove rules.txt and the rules are still applied.

Tiled is fantastic and thanks for looking at this.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [August 29, 2018, 10:03am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/9 "2018-08-29T10:03:11Z")

</div>

> [@sancho](#):
>
> To see the new dispersment, you do have to reselect the tile and thats really not a problem.

I guess it’s not really a problem once you know how to work around it. I’ll look into fixing it anyway since it should just work. The probabilities are cached by the tool, which means it should invalidate the cache when a probability is changed.

> [@sancho](#):
>
> In order to reproduce the automap issue:
> 
> 1. create a new tile map
> 2. create a rule for that tile map and test it to make sure it works.
> 3. without closing tiled go into the rules.txt and comment out all the rules.
> 4. test automap again, and you will see that the rules are applied same as in step 2 despite commenting them out.  
> Note that you can even completely remove rules.txt and the rules are still applied.

Right, note that you’re not switching maps anywhere in your steps, which is why the `rules.txt` file is not getting reloaded.

So another issue that’s easy to work around once you what’s going on, but again I’ll want to look into fixing this. It should probably do a quick check on the timestamp of the `rules.txt` file, and reload it when it’s different from last time automapping was triggered. I hope that will be fast enough even when “Automap While Drawing” is enabled.

---

<div class="post-metadata">

**Author:** ![sancho](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sancho](https://discourse.mapeditor.org/u/sancho)\
**Post date:** [August 31, 2018, 2:42am UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/10 "2018-08-31T02:42:56Z")

</div>

Ok thanks. I get it now and it does work by re-selecting the map.  
That is easy enough.

I will add a feature request:  
Automapping is essentially a smart mask or logical masking. It seems like it would be even more useful if you made it a ‘pen’ or stamp type tool instead of affecting the entire map. The user would design the rule much the same as you have it now and then apply the rule using the mouse and selecting locations on the tile map.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [September 2, 2018, 12:22pm UTC](https://discourse.mapeditor.org/t/automapping-works-just-once/418/11 "2018-09-02T12:22:01Z")

</div>

> [@sancho](#):
>
> Automapping is essentially a smart mask or logical masking. It seems like it would be even more useful if you made it a ‘pen’ or stamp type tool instead of affecting the entire map. The user would design the rule much the same as you have it now and then apply the rule using the mouse and selecting locations on the tile map.

While there is no tool for doing this, you can select some area using any of the selection tools and then press `A` to apply automapping to that area. This was [suggested here](http://discourse.mapeditor.org/t/selective-automapping/3093) and works since [Tiled 1.1.4](https://www.mapeditor.org/2018/03/28/tiled-1-1-4-released.html).

In addition you can of course enable “AutoMap While Drawing”, so rules are re-applied in areas you modify with any tool.
