Circle The Dot game help

hopscotch
help
helpwithcode

#1

Hey everyone!!

I'm currently trying to make a game by Ketchapp called Circle The Dot. Basically, you try to circle the blue dot (played by a computer) by placing orange dots on the screen. When the blue dot 'escapes' the game is over.

Read on if you would like to know more or just want to get completely confused because I'm terrible at explaining things XD

I'm using Clones to make this. The code kind of looks like a mess at the moment, but here's how it works: There are 81 Clones identified by their angle. After the Clones are created, 7 randomly chosen Clones turn orange and 1 randomly chosen Clone turns blue. Their color is kept track on the Self "My color" variable (1= orange 2= blue 3= tan).

When you tap a Clone, it checks if it is tan (My color= 3) and turns orange. Then the "COM Turn" variable turns to 1 (0= your turn, 1= computer's turn). Then, the blue dot chooses a random path (I'm hoping to maybe making it to where it chooses the shortest path, eventually. Not sure if that's possible though). I noticed a pattern when looking at the surrounding dots' angle numbers. This is where it gets tricky.

This part works out okay, but if a dot is orange then the blue dot can't move to that spot. I've tried to make it to where the computer moves back to its old spot and tries again, but it's not exactly working... the blue dots are multiplying.

I'm not really sure where I'm going with this project, or if it will even work, but if you have any solutions or advice (or questions!) I'd be glad to hear them. :grin:

People who have shown interest in this project or who I think might be able to help

@CreationsOfaNoob
@Rawrbear
@Caramel_Puffin
@t1_hopscotch
@BlastFusion
@Valgo
@CreativeCoder

P.S: there was an older topic on this, but it's unlisted now, so nobody can view it. I just decided to make a new one


#2

Hmmm.... Well, I can't help you on that, my variable skills suck lol.


#3

@Intellection74, I can't really make too much sense out of the code... XD

If you can, could you explain what everything is doing? That'll make it a lot easier.

If we can't find any solutions, I think we might have to start from scratch. I could help with that.


#4

Hi @Intellection74

I'd be willing to help. First I'd set up number sequence like this so the pattern to index any circle's neighbor is always the same. The rows alter between 10 & 9 dots except that 9, 28, 47, 66, & 85 aren't used, so in the end it's still a 9 x 9 grid

(I can show you simple code to create the grid if you need)

I'll add more on the other issues in another post...


#5

I haven't got this game from the App Store, but the blue dots shouldn't be multiplying? You have said that the clones randomise and 1 in every 8 dots should go blue, while the other seven goes orange?


#6

Hi @Intellection74
I think I might've found a solution to the problem. You have some code which is acting as a repeat forever, and the check "once" if isn't checking "once". So, the blue dots are only multiplying in colour.

I worked this out immediately, but I wasn't too sure on how to individualize the blue dot.

So I thought of adding a really large wait so it'll take a while to (maybe multiply from checking again)
I've tested this and I'm only seeing one blue dot.

I'n not confident that this will consistently work, but that's probably the best solution I can think of.

If there is a better way than using a large wait, it would be having the rule on the first screenshot to only occur once.


#7

And also if that doesn't exactly work, I tried adding a check once if over the wait and it seems to be more consistent than without the check.


#8

Thank you so much @ThinBuffalo and @BlastFusion! (@valgo, yeah, I'm sorry!! It's so messy) I've only really glimpsed at your posts, but I'll try out both of your solutions as soon as I can. And, Valgo, hopefully I'll come up with a better explanation, too.


#9

I've played a version of the game your trying to make.
The game involved blocking a mouse before it reaches a levels edge.
The AI for the mouse was able to detect which block to jump onto so the mouse wouldn't get surrounded(going the wrong way into a dead end)
Good luck with making the AI for your game.

A way for your "Dot" to detect a standard panel to move to would be to use Cos/Sine.
Most of the time the Dot is surrounded by 6 panels, so you have a small sprite near the dot and have the small sprite rotate around the Dot 60 degrees at a time and checking if it's touching an activated panel. When the small sprite isn't touching an activated panel, then have the Dot set position to the current small sprites X/Y position(which would be the empty space with a standard panel)
That's all I can say to help.


#10

Using the idea @ThinBuffalo had, you could add a variable describing the ID of which position the blue dot randomly choose to go to. The clone with the ID of the new position then does one out of two things;

  1. It is tan. It sets another variable that says which ID should go tan again (=the blue dot is leaving that position) and sets the blue dot position to it's own position. (It will also have to end the COM turn)

  2. It is orange. It sets "Try again, COM!" to 1.


#11

Hi @Intellection74

Sorry, the follow up to my 1st post got delayed! Essentially, I was going to suggest something very similar to what @CreationsOfaNoob has posted :+1:.

With one important additional consideration. You also want to know when the blue dot is trapped, so I was thinking to add another Object Variable to record how many movement options the blue dot would have from any given spot. So this variable would start at 6 for all spots & each time a orange dot is added, using the adjacent dot indexing pattern, subtract 1 for each adjacent dot. When it's the blue dot's turn to move and it's is on a location where the variable is 0 (no movement options left) then you know it's trapped.


#12

Hi again @Intellection74

I've been thinking about different possibilities for getting the AI to follow the shortest path. My kids loved the App Store game & I can't stop thinking about the AI.

Do you mind if I try to make a version of this game as well? I'm finding the AI challenge quite interesting.


#13

@ThinBuffalo Oh, yeah, definitely! Knock yourself out!


#14

I think I have a simple strategy to allow the dot to choose the shortest path. But in trying to implement it I ran into a problem with bumps not working properly.

I made a new, smaller version of the project trying to troubleshoot. Does anyone see why this isn't working?


#15

@Intellection74

I was able to finally work it out without using bumps. Here's my Hopscotchified version.

Since bumps aren't working right, the determination of the shortest path was done only with a logical, numeric algorithm referencing the hex indexes (setup as I originally suggested). There's a lot of details but basically it figures out the number of steps to an edge for all hexes until it gets to the mosquito. It starts with interior hexes at 99 steps and at 1 around the perimeter. Each perimeter hex increments the adjacent hexes to 2 if their current number of steps is higher. The 2s then increment adjacent hexes to 3, and so on. Venus' block the cascading of steps with a -999. After the cascade reaches the mosquito, the mosquito's adjacent hexes are searched for the lowest step count. Any of those "shortest path" candidates are then given a random number with the largest number being the chosen path. If the mosquito is surrounded but not blocked from moving, the cascade doesn't reach the mosquito meaning all valid choices are 99 so it then just randomly chooses.

There's an Easter egg in the project so that if you tap the title 3 times it changes the hexes to display the step count so you can see what it's doing. The numbers are a bit hard to tap but you can still play and see how the logic works.

Not sure how clear that was. Let me know if there's any questions.

@Stradyvarious


#16

*Enters topic
*Clears throat
*Notices who made the topic
*Realizes that with my skill level compared to yours, I will be no help.
*Leaves.


#17

My code could only detect if there was a random hex to jump to, or if there was no hex's nearby to jump to.
As you have used clones and Hopscotch code, I'll probably find it impossible to copy your code exactly.
Great job on finding a way to do this.
You are much smarter at maths than me.
I'll have to download Hopscotch again to try out your project.

I had an idea of numbering the hex's.
The outer layer is 1
Then next inside layer is 2
Etc.
If a hex is touching a value 1 hex, make self value 2
If touching value 2 hex, make self value 3
Etc.
So a domino effect would happen when a some hex 1's are gone.
Hex 2's would would be hex 3's
Etc.
I haven't felt inspired, so I haven't made any progress on that problem.


#18

@Stradyvarious

That's exactly what I did & described above :smiley:

I know you like to use graphical techniques, so try this:

  • Set a parameter for all hex to a number bigger than the most possible steps (e.g. 99)
  • Set a variable (e.g. N) to 0
  • Put a large rectangle (or 4 individual line objects) around the grid of hexes.
  • Shrink the rectangle (or move the lines inward) a certain amount to bump all outside hexes.
  • When (hex) is bumped Event:
    • All bumped hexes set their value to N+1 only if their current value is larger than N+1
    • Increment N by 1 (be careful to only increment N once per "set" of bumps)
    • Have all bumped hexes (or coincident semi-transparent objects) grow by a certain % to bump all adjacent hexes.

Then use a solution similar to the random picker you already have when the line spins sequentially bumping each adjacent hex, except with one exception. Spin entirely 360 deg first, reading the value from each hex as bumped to determine the shortest option. Then set the line, as you've done, to a random angle and spin until you bump one of the hexes that has the lowest value & choose that hex as the path.

This :point_up:️ is essentially what I did except I did it with a numeric algorithm.


#19

You remember the Tynker code I made where every cloned pellet compared it's distance to the Bot and changed some variables to it's position if the distance was closer than what the current variables value was.
I could code something similar where a Sprite has six invisible arms at angles so it's always touching the surrounding Hex's. When Hex 's is touched by the arms, they all compare their variable to a second variable and change the second variable to their variable if the second variable is higher.
If 2 or more Hex's have the same lowest value then one of them will be randomly chosen as I don't know the order in which all surrounding Hex's compare their variable.
That would be an interesting experiment that could be done with Hopscotch.
Have 30 clones onscreen and have them all at once compare/calculate something.
Each time a clones completed it's task have it set text to a variable.
So the first clone to finish it's task will set to 1, the second clone to finish it's task will set to 2 etc.
Restart the project multiple times to see if the same clones complete the task in the same order.

Thanks for replying.
You have given me some inspiration to make a working "Trap" game.


#20

@ThinBuffalo I just played this and I really love it and enjoy it!