How to make a sentry chase you (non-recursive method)

Okay, so this will be a simple guide compared to other algorithms. It’s simple, at the cost of the ai not being quite smart…


Not wasting any more time in the intro!

How to make it: wall version.


IMPORTANT: Once you load into your map, using a player coordinate device, find the box where the player coordinates are -1, -1. You may need to play around a bit with the player coordinate device and your maze to find it. The coordinate of -1, -1 will be where the top-left corner of the maze is. The coordinate of -2, -2 should be the open square on the top-left.

If you don’t want to find this area, don’t worry, I have plan B.
For the next few steps, the instructions that are Bolded will be instructions that you only need to do if the top square is -1, -1. Otherwise, if your maze is in a position like 323, 459, you’ll have to follow all the steps. So if you’ve got your maze in -1, -1, you don’t need to follow the instructions not highlighted.

First, you need a maze, with a lot of walls so there's something to hide behind.

Next, you need four properties.
First: PlayerXPosition1


Second, PlayerYPosition1

Third, PlayerXposition

Fourth, PlayerYPosition

Now you need a player coordinate device.

Now you need a trigger.

In the blocks of the trigger, (red circles are must-do, others you can discard if you have -1, -1) Note, play around with the numbers at the end so that the top-left corner is 1, 1.

Now you're done with the coordinate system. From now on no more bolding and stuff!


Time to make the matrix!

First, you'll need two properties. Sentry Row:


Sentry Column:

Now we need a number of properties for the number of rows of blocks. In this example, my maze is 8 tiles by 8 tiles. This means there are 8 rows and 8 columns. So I would create 8 properties, one for each row.


Now this is where it gets a bit complicated; you need to input all the tiles into the properties. For every block you can’t go through, you would put the letter “n” for no. For every tile you can go through, you would but a “y” for yes.
For the first property in this example, it is row 1 and every tile is a no.

It would be “nnnnnnnn”.
For the second property, there is just two no’s at the edges.

For the third, there is a mix.

For the fourth,

fifth,

Sixth,

Seventh,

and finally, eighth.

Now this creates a matrix, so it’s like our maze put into a series of rows and columns in text. You get the idea; for the next few rows and columns you would input more n’s and y’s and have more properties.


Continuing the setup

Now you need four properties. Above:


Below:


Left:


And right.

Now you need another property, named “name”.


Copy-paste part: the code

First, you need a lifecycle.

Then, a trigger.

Then, wire the lifecycle to the trigger.

Then, grab another trigger.

In the blocks:

Now, copy this trigger, and modify the settings so it looks like this:

In the blocks, modify it so it looks like this:

Now, grab another trigger.

In the blocks:

Good! Now grab yet another trigger.

In the blocks:

Finally! You’re done with the system!


Sentries

Let’s grab a sentry and put it at 2, 2.

Using my pseudo-health for sentries guide, input these settings:

And this:

And this:

Okay! Customize the sentry difficulty and skin however you want, but when you’re done, copy the sentry to the next column. For each copied sentry, you need to change the coordinates. The coordinates are in the channels section of the settings, where it says “Activate Sentry when receiving on”. For this next sentry, the coordinates should be

The one to the right should be 42 then it goes as follows:

Row 1 2 3 4 5 6 7 8
1 n n n n n n n n
2 n 22 32 42 52 62 72 n
3 n n n 43 n n 73 n
4 n 24 34 44 54 64 74 n
5 n 25 35 n n 65 75 n
6 n 26 n 46 56 66 76 n
7 n 27 37 47 57 n 77 n
8 n n n n n n n n

And you should know how to do it for the next few rows.

In the end, we’ve got ourselves a large matrix of sentries, and a working sentry-bot chasing after you!

If you don’t want to make the algorithm yourself, here’s a gif of me testing it out:

Screenrecording2024-06-2411.30.06AM-ezgif.com-video-to-gif-converter (4)

Screenrecording2024-06-2411.30.06AM-ezgif.com-video-to-gif-converter (3)

To reduce the choppiness, reduce the time it takes for the triggers to respond (0.5 seconds to 0.01 seconds).
To increase how fast the sentries move, decrease the interval in the repeating trigger.
Have fun gimkitting!


Algorithm for without any walls.

The algorithm without any walls is a simple change, however, watch out for possible errors if the players can go in an area the sentries can’t go to. For this algorithm, you’ll need to still track the sentry position and player position, but you won’t need a matrix. Just remember that you need to put a sentry over every tile on your map, and you can’t have the player go somewhere without any sentries.
How to change this algorithm to get to without any walls:

Remove the Row# properties and remove the if blocks for the first two triggers.

Do the same for the other one!

And that should be it!


Difficulty:
  • 1/10
  • 2/10
  • 3/10
  • 4/10
  • 5/10
  • 6/10
  • 7/10
  • 8/10
  • 9/10
  • 10/10
  • 11/10
0 voters

Rating:

  • 1/5
  • 2/5
  • 3/5
  • 4/5
  • 5/5
0 voters
8 Likes

I think I’m ded after reading this

4 Likes

Yeah forgot dropdowns again… :\

3 Likes

Nice work! A functioning AI that can be used for tag and such!
One note: Try making the AI faster than it currently is. Also, I’m too lazy (my favorite excuse :D)
EDIT: @Kormorant get on pyxelbite padlet

5 Likes

That’s actually pretty smoort, recording the terrain in text.
Looks a lil’ complicated…toaster noises trying to figure it out

4 Likes

likes
Time to finish developing the second algorithm, brrr

4 Likes

Wait a sec…
One sentry = 500 memory so
7x7 sentries - 8 sentries = 41 sentries
41 x 500 = 20500 memory

Enough for a 512 frame animation :skull: :skull: :skull: :skull: :skull: :skull::skull:

Ok nevermind time to use props instead

3 Likes

no, any sentry after the first sentry costs less than 500 memory (i forgot the exact amount) and it stays that same amount.

likes
Hmm… still a lot of memory though.
expanding my 9x9 grid…

1 Like

but a lot less than 20500 memory

1 Like

How memory does it take to fill 100% memory? I’m trying to calculate how much memory this takes

Um 100K memory… 1K equals 1%.

1 Like

Oh ok… doing calculations
28x500 +500= 14500
8+8+8+7+7 = 38 props
8+4+1+2+4 properties
6 triggers = 240
Lifecycle = 50
Blocks x 5 = 2500 memory
1 wire
1 player coordinates
14880+190+240+50+2000+5=21365 memory I think… around 21%

2 Likes

20500 only takes up [about] a fifth of the memory anyways.

1 Like

I don’t think a fifth of the map’s memory is worth it to make this.

2 Likes

Using props, a 8x8 grid with this system would take only
640+190+240+50+2500+wire+3500=7125 memory, around 7%
might be wrong though

but sentry memory is 500 per sentry
you are wrong

1 Like

Kosmo said the sentry memory decreases after the first one, I just assumed 400
re-calculating with blocks in mind

Yeah, it goes from 1000 to 500
the 40ish sentries you used take up 20000 memory, and 2/5ths of the sentry limit

2 Likes

sorry, i got it wrong. i was thinking of something else :/
what cassius said.

1 Like