Page 1 of 1

Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 08 Jan 2019, 21:05
by Pilkojr
Hi all,

My first post :-)

As the title asks I guess. Can an AHK script be used to solve puzzles like CandyCrush Saga boards?

Thanks,
Pilkojr

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 13 Jan 2019, 23:13
by Pilkojr
Any ideas?? Thanks

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 14 Jan 2019, 10:39
by Ruevil2
AHK is 'turing complete', so the short answer is yes, it can do anything that any other language can do. A better question is, are you smart enough to figure it out?

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 14 Jan 2019, 16:38
by Pilkojr
Ruevil2 wrote:
14 Jan 2019, 10:39
AHK is 'turing complete', so the short answer is yes, it can do anything that any other language can do. A better question is, are you smart enough to figure it out?
Thanks Ruevil2. That's very good to know. I'm definitely not smart enough to figure it out, but I reckon there'd be plenty around who are.

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 14 Jan 2019, 17:53
by Ruevil2
Pilkojr wrote:
14 Jan 2019, 16:38
Ruevil2 wrote:
14 Jan 2019, 10:39
AHK is 'turing complete', so the short answer is yes, it can do anything that any other language can do. A better question is, are you smart enough to figure it out?
Thanks Ruevil2. That's very good to know. I'm definitely not smart enough to figure it out, but I reckon there'd be plenty around who are.
I wouldn't start with self doubt my friend. Some of these problems become easier after a little analyzing. Start with trying to write down the steps you would physically take to solve the problem with your eyes. Then try to translate that into AHK commands. I would try to throw you some ideas that might get you started but I haven't played this game in particular.

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 14 Jan 2019, 18:19
by Pilkojr
I've seen scripts written in Python that apparently can play the game. I've got one of those scripts, but looking through it means nothing to me.

I'm good for an imagesearch or 2, but solving a puzzle......hmmmm :-)

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 15 Jan 2019, 09:17
by Ruevil2
I took a look at the game and from what I gathered in a few minutes you would have to start with board recognition. Basically determine the board space and how many tiles you are dealing with. Second step would be to determine color patterns. After that the logic of determining the best move starts to get into a bit of a game theory area.

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 28 Feb 2019, 16:49
by Pilkojr
Hi Ruevil2,

I've given up on the Candy Crush type idea, and gone for a game a bit different.

I've uploaded a pic, and was wondering where to start for a script that could work out how to complete the board in the pic.

How it works is;
For each tile with a number on it, the next tile that can be selected will be 'n' tile away in any direction.
For each tile with a chess type piece, the following applies;
- Crown, next piece is on the edge of the board in any direction
- Sword Tower with Water, next piece is on the edge of the board in vertical or horizontal movement only
- Tower with Crossed Swords, next piece in on the edge of the board in diagonal movement only
- Dragon, next piece will be 2 tiles away vertically or horizontally, then 1 to the left/right/up/down (like a Knight in chess)

Any starting point would be amazing thanks.

Re: Can a AHK script solve puzzles like CandyCrush Saga?  Topic is solved

Posted: 04 Mar 2019, 12:39
by Ruevil2
Fist place to start is by taking a shot of each individual image so you can recognize each square on the board and what tile each space represents. The board is a 6x6 square so you have 36 tiles to recognize. After the recognition part I don't really have any more advice since deciding the best move takes a little more understanding of the gameplay involved.

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 04 Mar 2019, 16:15
by Pilkojr
I can get screenshots of each tile, but how do I get a script to piece together a 6x6 board and recognise what tile is in each position?

Re: Can a AHK script solve puzzles like CandyCrush Saga?

Posted: 05 Mar 2019, 09:31
by Ruevil2
Pilkojr wrote:
04 Mar 2019, 16:15
I can get screenshots of each tile, but how do I get a script to piece together a 6x6 board and recognise what tile is in each position?
That is going to be a little bit of the hard part, I can point you to the tools (basically Loop, ImageSearch and Array) but I can't really say what the best way to approach the problem will be. My gut reaction is to assign each tile a value and arrange them in an array that represents the board structure.

Like this: Referred to in the style of Array[2][3]
1 2 3 4 5 6
1|3 4 5 3 3 5
2|1 3 3 4 5 3
3|3 4 4 3 4 2
4|2 5 2 3 1 4
5|1 3 1 4 1 2
6|4 2 3 2 3 1

Then you can determine identity and position, how to move or perform logic is the part that is beyond me. Hope this helps!