Author Topic: Philippines in the maze  (Read 9639 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Philippines in the maze
« on: July 18, 2020, 03:13:17 pm »
Hi !

I am pleased to report that I have finally managed to solve a lot of problems.
Finally, the track structure is the same as usual for 3D games. You can go anywhere, but you only really get out on 1 path.
Try it, you are plugged in what you need to find.
Generate a track first, it does everything automatically, saves it.
Then start the game.
I made different architectural solutions, it was a big challenge not to accidentally fall where I shouldn’t be allowed. The random track is closed all the way, you can't cheat.

who will find the end of the game?


https://drive.google.com/file/d/1Uiq4pyq0LYyyLK5BFbsexM6zhV_D917H/view?usp=sharing
« Last Edit: July 18, 2020, 03:16:10 pm by MasterGy »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Philippines in the maze
« Reply #1 on: July 18, 2020, 03:48:56 pm »
Hi MasterGY, video looks very nice! I download it by your Google drive, running br58.bas, but error occur: i need _FONT betu file (row 369)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Philippines in the maze
« Reply #2 on: July 18, 2020, 03:51:32 pm »
Hey!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Philippines in the maze
« Reply #3 on: July 18, 2020, 04:24:20 pm »
b like bplus :)

Petr, Let OUTPUT EXE TO SOURCE FOLDER is on!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Philippines in the maze
« Reply #4 on: July 18, 2020, 04:32:42 pm »
Now it works corectly for me. Perfect work, MasterGY!

For an unknown reason, the "EXE to source folder" option was turned off in the IDE. Turning it as enable and all works!
I have one note. For example, if you want the MAPTRIANGLE command to place a hardware texture side by side more than once, here is an example.

Code: QB64: [Select]
  1.  
  2. himg = _COPYIMAGE(SI, 33)
  3. SCREEN _NEWIMAGE(1024, 768, 32)
  4.  
  5. W = _WIDTH(himg) - 1
  6. H = _HEIGHT(himg) - 1
  7.  
  8. 'how much copyes image in X axis:
  9. M = 3
  10. 'how much copyes image in Y axis:
  11. N = 5
  12.  
  13.  
  14.     _MAPTRIANGLE (0, 0)-(M * W, 0)-(0, H * N), himg TO(-1, 1, -5)-(1, 1, -5)-(-1, -1, -5), 0
  15.     _MAPTRIANGLE (M * W, 0)-(0, H * N)-(W * M, H * N), himg TO(1, 1, -5)-(-1, -1, -5)-(1, -1, -5), 0
  16.     _DISPLAY
  17.  
« Last Edit: July 18, 2020, 04:33:49 pm by Petr »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Philippines in the maze
« Reply #5 on: July 20, 2020, 12:16:08 am »
WOW! This is amazing! You could do GTA 6 @MasterGy! :P
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Philippines in the maze
« Reply #6 on: July 21, 2020, 03:11:52 pm »
Thank you for your answers !

yes, Petr the good thing is that if you exceed the requested point by the size of the image, it will be tiled automatically. I don't use it because then it would either be ugly for the two sides to meet, or if I edit it that way, it would have too much symmetry in it, it would be confusing anyway. I solved that when you need a texture, you use a preset size section in a large location in a large image. So in the end, for example, two planks may look the same, yet they will have different textures.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Philippines in the maze
« Reply #7 on: July 26, 2020, 02:50:33 pm »
Hi !
I want to put intelligent enemies in space. In the shooter game, I walked through his trajectory for people and planes in advance, he’s actually reading this there. On the other hand, if a track is random, it has to be intelligent, so it can move in an unknown environment.
Modern and even old shooting games had quite advanced AI! Does anyone know flowcharts, descriptions, studies on this?
I tried, but it really only moves in a plane. They avoid each other. You are attacked by a certain number of people, this can be adjusted during play by how many M and N keys. Those who attack try to get behind you. They don’t hurt, they don’t have guns, they just look ugly. I made the strategy in 2d. I want smart enemies who go up the stairs, etc., but perceiving space, finding the best direction, taking action would be a million times. What simple process could be used to move a person in 3d space with minimal strategy?



https://drive.google.com/file/d/1ZajvUNv8VD74SaZbRs4RLd3q8ncAoCEf/view?usp=sharing

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Philippines in the maze
« Reply #8 on: July 27, 2020, 01:16:38 am »
I don't have the alogrithm yet but what I see in the video is very impressive!. ;)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Philippines in the maze
« Reply #9 on: July 27, 2020, 07:06:26 am »
Thank you Ashish ! :)

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: Philippines in the maze
« Reply #10 on: July 31, 2020, 10:42:09 am »
Quote
What simple process could be used to move a person in 3d space with minimal strategy?
A quick and dirty solution would be to use a flood fill across a grid of points known to be accessible from each other.
Forget 3D for just a moment (the solution for this is easy once you understand this in 2D space).

Part 1 (prep):
Break the ground up into a grid of 2D points.
Whatever your current solution is for collision detection, simulate an entity moving between adjacent points and record which are and are not accessible from each other and record the results. You could record this is a file to speed up load times as this only has to be done once (for static maps).
Movement of enemies will be quite robotic if only adjacent points are considered. So also store if diagonal points are accessible, and even better consider a wider range of adjacency checks that include more close-by points at a variety of angles.
UPDATE: When performing this check it is important to simulate real player movement from the start point to the dest point. It should test "Does an enemy/player starting a point1 walking directly in the direction of point2 actually reach point2 without any obstructions (and taking non-lethal damage if they are on full health)". Whether the simulated movement jumped of a cliff, walked over some spikes or climbed a ladder doesn't matter. Record how much damage would be dealt by the movement and how long the movement took. If you want to be super clever you can incorporate multiple movement styles other than normal styles by performing multiple tests, such as jumping if the test meets a hole vs just falling in.

Part 2 (in game):
Have your enemy move to the closest known point (if they are blocked they can walk randomly until they randomly get close enough to a known point).
Now perform a path-finding algorithm (flood fill for example) to the point the player is nearest (also check that from that destination point they can walk directly to the player or they might end up on the wrong side of a wall the player is standing against)

I've attached an image.

Update: Screenshot from prototype I'm working on attached. Let me know if you want the code.
« Last Edit: August 02, 2020, 11:48:40 am by Galleon »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Philippines in the maze
« Reply #11 on: August 01, 2020, 06:13:46 am »
I would combine it a bit with the Galleon's solution proposing. After you filter the field only for points that are affected by collision detection, I would do so with this modified circle collision detection (the enemy can attack from any angle if it is close enough and there is no wall in the path). Those walls just need to be filtered out first.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 256)
  2.  
  3. r& = 200 'radius    change circle size and position here
  4. cx& = 320 'center x horizontal
  5. cy& = 200 'center y vertical
  6.  
  7. r2& = 200 'radius    change circle size and position here
  8. cx2& = 500 'center x horizontal
  9. cy2& = 240 'center y vertical
  10.  
  11.  
  12.  
  13. _MOUSESHOW "CROSSHAIR"
  14.     i = _MOUSEINPUT
  15.     x& = _MOUSEX
  16.     y& = _MOUSEY
  17.  
  18.     CIRCLE (cx&, cy&), r&, 10
  19.     CIRCLE (cx2&, cy2&), r2&, 12
  20.  
  21.     LOCATE 1
  22.     PRINT "Colission:"; C2C(x&, y&, r&, cx&, cy&, r2&, cx2&, cy2&)
  23.  
  24. LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
  25.  
  26.  
  27.  
  28. FUNCTION C2C (x&, y&, r&, cx&, cy&, r2&, cx2&, cy2&)
  29.     xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
  30.     xy2& = ((x& - cx2&) ^ 2) + ((y& - cy2&) ^ 2) 'Pythagorean theorem
  31.     IF r& ^ 2 >= xy& AND r2& ^ 2 >= xy2& THEN C2C = 1 ELSE C2C = 0
  32.  

And with Wall (just Y coordinate detection):

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 256)
  2.  
  3. r& = 200 'radius    change circle size and position here
  4. cx& = 320 'center x horizontal
  5. cy& = 200 'center y vertical
  6.  
  7. r2& = 200 'radius    change circle size and position here
  8. cx2& = 500 'center x horizontal
  9. cy2& = 240 'center y vertical
  10.  
  11.  
  12.  
  13. _MOUSESHOW "CROSSHAIR"
  14.     i = _MOUSEINPUT
  15.     x& = _MOUSEX
  16.     y& = _MOUSEY
  17.  
  18.     CIRCLE (cx&, cy&), r&, 10
  19.     CIRCLE (cx2&, cy2&), r2&, 12
  20.     LINE (100, 50)-(750, 550)
  21.     wall = IL(100, 50, 750, 550, x&)
  22.  
  23.  
  24.     LOCATE 1
  25.     PRINT "Colission:"; C2C(x&, y&, r&, cx&, cy&, r2&, cx2&, cy2&)
  26.     PRINT "Nearest Y LINE point position: "; wall
  27.  
  28. LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
  29.  
  30.  
  31.  
  32. FUNCTION C2C (x&, y&, r&, cx&, cy&, r2&, cx2&, cy2&)
  33.     xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
  34.     xy2& = ((x& - cx2&) ^ 2) + ((y& - cy2&) ^ 2) 'Pythagorean theorem
  35.     IF r& ^ 2 >= xy& AND r2& ^ 2 >= xy2& THEN C2C = 1 ELSE C2C = 0
  36.  
  37. FUNCTION IL (iXb, iYb, iXe, iYe, iP) 'X start, Y start, X end, Y end, Your position in X axis. Function return nearest Y coordinate for LINE between points LINE (iXb, iYb) - (iXe, iYe)
  38.     Xb = iXb
  39.     Yb = iYb
  40.     Xe = iXe
  41.     Ye = iYe
  42.     P = iP
  43.     IF Xb > Xe THEN
  44.         SWAP Xb, Xe
  45.         SWAP Yb, Ye
  46.     END IF
  47.     IF P >= Xb AND P <= Xe THEN
  48.         IF Xb = Xe THEN IL = -1: EXIT FUNCTION 'error
  49.         IF Yb = Ye THEN
  50.             IL = Yb
  51.         ELSE
  52.             Lenx = Xb - Xe
  53.             LenY = Yb - Ye
  54.             Ratio = LenY / Lenx
  55.             IL = INT(Yb + (P - Xb) * Ratio)
  56.         END IF
  57.     ELSE
  58.  
  59.     END IF
  60.  

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Philippines in the maze
« Reply #12 on: August 01, 2020, 09:51:41 am »
These movements seem similar to chess pieces on a chess board. I believe the AI approach with movement and rules of combat related to chess may be of help.

Offline lpy

  • Newbie
  • Posts: 6
    • View Profile
Re: Philippines in the maze
« Reply #13 on: August 01, 2020, 05:26:20 pm »
Hi, it's not working properly for me. Mouse only moves down regardless of the direction I point it, and getting an error on line 1630.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Philippines in the maze
« Reply #14 on: August 02, 2020, 12:18:14 pm »
Hi !
Thanks for the answers and advice!
Spanish Sailing! It's complicated for me. I'm looking for a solution for :)
3d to go up the stairs, and so on… 2d, as you can see in the video, I solved it on the principle of simple attraction-repulsion. You snatch the enemy X closest to me from the crowd and draw them around a circle around me. The rest is free. But! if any of the free comes within the circle, it is repulsive. When the ideal direction vector of each enemy is ready, I solve the following logic so that they do not go to each other, avoid the wall, avoid each other and go side by side:
ideal angle +0 degrees! is there a wall or another enemy? Then -10 degrees, test..if there is an obstacle: +10… and so on… -20, + 20, -30, + 30, -40, + 40. this addition is valid for one cycle only. everyone stepped to where it was most favorable. and again 0, -10, + 10… and so on. Thus, the phenomenon is as if I consciously avoid each other or go by the wall.
Thanks Petr, that's how I did the attraction repulsion.
And the enemies attracted at a certain distance from me can attack in different ways..pl ​​there will be 1 or two no matter, it will be proportionate to the difficulty, who will come to me completely with a sword. whoever is farther away shoots the arrow, whoever is farther away, say, throws a stone… so the number of enemies placed at distances from me will simply be the level, proportional to the difficulty.
Lpy, I don't know what's wrong, I'm editing with 1.3, but I should start with what this is or above.
I'm looking for something that moves in 3d.
I colored the track with 2d moving and stationary elements.