PlaceBot icon indicating copy to clipboard operation
PlaceBot copied to clipboard

How to configure?

Open Danacus opened this issue 7 years ago • 11 comments

I'm from /r/TheBlueCorner and I want to configure it to automatically place blue tiles in the blue corner. Is this possible right now? If yes, how?

Danacus avatar Apr 01 '17 10:04 Danacus

I'm also interested. Looks like it saves and loads a JSON queue of tiles in LocalStorage, but I can't figure out how to insert things into the queue.

ahalekelly avatar Apr 01 '17 13:04 ahalekelly

So after editing the userscript (full) like this:

        this.tiles = [[126, 748, 9], [126, 749, 9], [126, 750, 9], [126, 751, 9], [126, 752, 9], [127, 750, 9], [128, 748, 9], [128, 749, 9], [128, 750, 9], [128, 751, 9], [128, 752, 9], [130, 748, 9], [130, 749, 9], [130, 750, 9], [130, 751, 9], [130, 752, 9]];

It isn't able to place tiles anyway.

s5bug avatar Apr 01 '17 16:04 s5bug

Hey, so I'm still working on this and it isn't really ready to go yet. It does work using either a function to generate tiles, or a list of tiles (a list for the full canvas would be ~30MB though). I left it running all night, and it was still placing this morning. I'll try and have a version that is at least easily configurable via the console out in a bit.

grind086 avatar Apr 01 '17 22:04 grind086

As a workaround, you can set up a script right now with the following:

// Generator function - note that it is stored via toString() and recovered using eval().
// It should return a function that returns tiles in the form [x, y, colorIndex]
function tileGenerator(pb){

    // Setup here

    return function() {
        return [x, y, colorIndex]
    }
}

var tiles = []; // This can be used to store any data in function mode, planning on revising
var mode = 1;   // PlaceBot.placeMode.FUNCTION

localStorage.setItem('placebot_tiles', {
    tiles: tiles,
    mode: mode,
    fn: tileGenerator.toString()
});

After setting the localStorage item just refresh the page, and the bot should start using the generator.

grind086 avatar Apr 01 '17 23:04 grind086

Here's the tileGenerator I used for testing overnight:

function pinkLine(pb) {
    var lastDraw;
    var lastTile = [456, 849, 4];

    return function() {
        if (pb.lastDrawTime !== lastDraw) {
            pb.lastDrawTime = lastDraw;
            lastTile = [456, 849, 4];
        } else {
            lastTile[1] = (lastTile[1] + 1) % 1000;
        }

        return lastTile;
    };
}

grind086 avatar Apr 01 '17 23:04 grind086

Okay you can now configure via the console (that was quicker than I expected).

// Default settings
placeBot.importBot({
    minTimer: 100,
    tiles: [],
    mode: PlaceBot.placeMode.ARRAY
    fn: 'TopDown'
});

//
// minTimer - Minimum time between draw attempts
//
// For array mode (mode = PlaceBot.placeMode.ARRAY)
// tiles - A list of tiles
// fn - The name of a built-in selector (see PlaceBot.selectors) or a function that
//    returns an index from the tiles array
//
// For function mode (mode = PlaceBot.placeMode.FUNCTION)
// tiles - Storage (planning on renaming/changing to an object)
// fn - A function that returns a function that returns tiles. If you want to save it
//    between page refreshes, then fn === eval(fn.toString()) must be true
//

grind086 avatar Apr 01 '17 23:04 grind086

Thanks! I'll try it very soon.

Danacus avatar Apr 02 '17 04:04 Danacus

So how do we configure the tiles we want to place? Can you give a code example or make a function, like queueTile(x, y, color)? And what is color? Is it 0-15, 1-16, or black-white?

EDIT: How is the data stored? I might make a tool that parses an image and turns it into the data. And if someone overwrites the tiles that we place, does it go back with priority to the first in the list?

s5bug avatar Apr 02 '17 16:04 s5bug

I made a Python tool that parses RGBA PNG images and converts them into the tile array for my fork of this bot.

Edit: The images are 0-15, you can get the list from typing r.place.palette into the console on /r/place

ahalekelly avatar Apr 02 '17 16:04 ahalekelly

What colors though? Does it take closest RGB?

EDIT: Also, does your fork work atm?

s5bug avatar Apr 02 '17 16:04 s5bug

Yeah my fork is working, use the userscript file and change the first url to point to your tiles.

You need to make a transparent image for the whole canvas, and then match the exact colors used.

ahalekelly avatar Apr 02 '17 16:04 ahalekelly