QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: MasterGy on July 18, 2020, 03:13:17 pm

Title: Philippines in the maze
Post by: MasterGy 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 (https://drive.google.com/file/d/1Uiq4pyq0LYyyLK5BFbsexM6zhV_D917H/view?usp=sharing)
Title: Re: Philippines in the maze
Post by: Petr 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)
Title: Re: Philippines in the maze
Post by: bplus on July 18, 2020, 03:51:32 pm
Hey!
Title: Re: Philippines in the maze
Post by: MasterGy on July 18, 2020, 04:24:20 pm
b like bplus :)

Petr, Let OUTPUT EXE TO SOURCE FOLDER is on!
Title: Re: Philippines in the maze
Post by: Petr 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.  
Title: Re: Philippines in the maze
Post by: Ashish on July 20, 2020, 12:16:08 am
WOW! This is amazing! You could do GTA 6 @MasterGy! :P
Title: Re: Philippines in the maze
Post by: MasterGy 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.
Title: Re: Philippines in the maze
Post by: MasterGy 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 (https://drive.google.com/file/d/1ZajvUNv8VD74SaZbRs4RLd3q8ncAoCEf/view?usp=sharing)
Title: Re: Philippines in the maze
Post by: Ashish 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!. ;)
Title: Re: Philippines in the maze
Post by: MasterGy on July 27, 2020, 07:06:26 am
Thank you Ashish ! :)
Title: Re: Philippines in the maze
Post by: Galleon 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.
Title: Re: Philippines in the maze
Post by: Petr 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.  
Title: Re: Philippines in the maze
Post by: Dimster 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.
Title: Re: Philippines in the maze
Post by: lpy 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.
Title: Re: Philippines in the maze
Post by: MasterGy 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.

Title: Re: Philippines in the maze
Post by: lpy on August 02, 2020, 12:27:42 pm
Hi. I tried compiling with 1.3 but still the same.
Title: Re: Philippines in the maze
Post by: MasterGy on August 02, 2020, 01:43:30 pm
I don't understand why. Try this last.

https://drive.google.com/file/d/1pkblbmBmmgsdPA1ZweaexACEDs5T9a93/view?usp=sharing (https://drive.google.com/file/d/1pkblbmBmmgsdPA1ZweaexACEDs5T9a93/view?usp=sharing)

Is it ON ?
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Philippines in the maze
Post by: lpy on August 02, 2020, 01:58:51 pm
Sorry still the same.

Yes, Output to EXE folder is ON.
Title: Re: Philippines in the maze
Post by: MasterGy on August 02, 2020, 02:10:15 pm
maybe someone knows the answer? I have no idea. :o
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 02, 2020, 02:11:13 pm
Downloading to see.
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 02, 2020, 02:20:47 pm
What is the main .bas to compile?
Title: Re: Philippines in the maze
Post by: Petr on August 02, 2020, 02:33:13 pm
Quote
What is the main .bas to compile?

First compile bas file in folder step1_track_creator7, this generate map after running [works right for me]
After compiling and running this first step, goto folder step2_game_with_ai_01 and compile and run file placed in this folder [works fine for me]

Very good work, MasterGY!
the plants in the game are made also really nice!
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 02, 2020, 02:47:44 pm
I get the same error while trying to run br59_ki_19.bas in macOS (64bit):
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Something in your calculations for the REDIM ubt(bl_xs, bl_ys, bl_zs) AS _BIT array boundaries is getting weird results with 64bit calculation.

In Windows XP (32bit) it ran until the end. But then game_hum_23_ani10.bas won't run, because I don't have a D: drive:
Code: QB64: [Select]
  1. OPEN "d:\qqw.dat" FOR OUTPUT AS 33
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 02, 2020, 02:53:57 pm
I've uncommented the debug line right above line 1684, and these are the values being calculated for bl_xs, bl_ys, bl_zs when the program crashes using the 64bit compiler:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Philippines in the maze
Post by: lpy on August 02, 2020, 03:41:24 pm
Yep that was the solution for me too, running QB64 x32. It's working. The mouse sensitivity is way too high, but otherwise it's good.
Title: Re: Philippines in the maze
Post by: Galleon on August 02, 2020, 07:35:34 pm
Quote
3d to go up the stairs, and so on…
The explanation I provided works just as well for 3D. The "grid" points can be in 3D space not 2D space and don't have to be in a grid-like fashion (you could hypothetically place a point in the middle of each step, but I would just make a 3D grid precise enough to cover all major step/platform/ramp heights [for a number of optimisation/simplicity reasons I don't care to explain], or use a combination of both). If you have point A around the bottom of some stairs and point B on the 3rd stair, by simulating/testing walking from A in the direction of B (using the same code logic which would apply to the player) the enemy will naturally walk up the stairs and reach point B even though it is at a different height, making that connection valid. If they don't reach point B then that connection is invalid. Take a look at the screenshot I posted previously, the grey lines are all the results of connections I tested which were recorded as valid. I'm not going to bother you with any further explanation/details unless you feel this is of use, but I did have fun writing the prototype. I've attached the proof of basic concept code but you would need to study/review/adapt it to make it suit your purpose.

Code: QB64: [Select]
  1. 'TODO: BUGS
  2. '  (no known bugs but this is just a prototype)
  3. 'TODO: OPTIMISATIONS
  4. '* Bi-directional search
  5. '* Cancel all rays on route to a just met ray
  6. '* optimize rayMovementDistance value (base this on previous results)
  7. '* do not init rays to already reached points
  8. '* do not init rays to points 2 or more away in a direct up/down/left/right direction
  9. '* Use activeRayIdList (WIP)
  10. 'TODO: FEATURES
  11. '* 3D layers
  12.  
  13. DEFLNG A-Z
  14. SCREEN _NEWIMAGE(1024, 768, 32)
  15.  
  16. mapImage = _LOADIMAGE("map.png")
  17.  
  18. mapWidth = _WIDTH(mapImage)
  19. mapHeight = _HEIGHT(mapImage)
  20.  
  21. REDIM SHARED map(-1 TO mapWidth + 1, -1 TO mapHeight + 1) AS _BYTE
  22. _SOURCE mapImage
  23. wall = 1
  24. FOR y = 0 TO _HEIGHT(mapImage) - 1
  25.     FOR x = 0 TO _WIDTH(mapImage) - 1
  26.         IF POINT(x, y) <> _RGBA(0, 0, 0, 255) THEN
  27.             map(x, y) = wall
  28.         END IF
  29.     NEXT
  30.  
  31. _PUTIMAGE (0, 0), mapImage
  32.  
  33. TYPE location
  34.     x AS SINGLE
  35.     y AS SINGLE
  36.     firstConnectionId AS LONG
  37.     'Used during path finding
  38.     reached AS LONG
  39.  
  40. granularity = 6
  41. locationsWidth = mapWidth / granularity
  42. locationsHeight = mapHeight / granularity
  43. REDIM SHARED locations(locationsWidth, locationsHeight) AS location
  44. FOR x = 0 TO locationsWidth
  45.     FOR y = 0 TO locationsHeight
  46.         locations(x, y).x = x * (mapWidth / locationsWidth)
  47.         locations(x, y).y = y * (mapHeight / locationsHeight)
  48.         PSET (locations(x, y).x, locations(x, y).y), _RGB(255, 255, 255)
  49.     NEXT
  50.  
  51. TYPE connection
  52.     destLocationX AS LONG
  53.     destLocationY AS LONG
  54.     distanceCost AS LONG
  55.     nextConnectionId AS LONG
  56.  
  57. REDIM SHARED connections(1000000) AS connection
  58. DIM SHARED finalConnectionId
  59. finalConnectionId = -1
  60.  
  61.  
  62.  
  63. maxConnectionDistance = 4
  64. 'build connections
  65. FOR y = 0 TO locationsHeight
  66.     FOR x = 0 TO locationsWidth
  67.         lastConnection = -1
  68.         FOR y2 = y - maxConnectionDistance TO y + maxConnectionDistance
  69.             FOR x2 = x - maxConnectionDistance TO x + maxConnectionDistance
  70.  
  71.  
  72.                 'Test: an entity walking from point1 in the direction of point 2 will arrive at point 2 without encountering any obstructions
  73.                 'Note: this part of the code is a mess because I coded it in the quickest way I could think of, it would be replaced with real code for walking the character and detecting if point 2 is actually reached
  74.                 IF y2 >= 0 AND y2 <= locationsHeight THEN
  75.                     IF x2 >= 0 AND x2 <= locationsWidth THEN
  76.                         IF x <> x2 OR y <> y2 THEN
  77.                             DIM xx1 AS SINGLE, yy1 AS SINGLE
  78.                             DIM xx2 AS SINGLE, yy2 AS SINGLE
  79.                             DIM dx AS SINGLE, dy AS SINGLE
  80.                             xx1 = locations(x, y).x
  81.                             yy1 = locations(x, y).y
  82.                             xx2 = locations(x2, y2).x
  83.                             yy2 = locations(x2, y2).y
  84.                             steps = granularity * 2
  85.                             dx = (xx2 - xx1) / steps
  86.                             dy = (yy2 - yy1) / steps
  87.                             blocked = 0
  88.                             FOR i = 0 TO steps
  89.                                 xx1i = xx1
  90.                                 yy1i = yy1
  91.                                 IF map(xx1i, yy1i) = 1 THEN blocked = 1: EXIT FOR
  92.                                 IF map(xx1i + 1, yy1i) = 1 THEN blocked = 1: EXIT FOR
  93.                                 IF map(xx1i - 1, yy1i) = 1 THEN blocked = 1: EXIT FOR
  94.                                 IF map(xx1i, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  95.                                 IF map(xx1i, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  96.                                 IF map(xx1i - 1, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  97.                                 IF map(xx1i - 1, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  98.                                 IF map(xx1i + 1, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  99.                                 IF map(xx1i + 1, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  100.                                 xx1 = xx1 + dx
  101.                                 yy1 = yy1 + dy
  102.                                 IF map(xx1i, yy1i) = 1 THEN blocked = 1: EXIT FOR
  103.                                 IF map(xx1i + 1, yy1i) = 1 THEN blocked = 1: EXIT FOR
  104.                                 IF map(xx1i - 1, yy1i) = 1 THEN blocked = 1: EXIT FOR
  105.                                 IF map(xx1i, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  106.                                 IF map(xx1i, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  107.                                 IF map(xx1i - 1, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  108.                                 IF map(xx1i - 1, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  109.                                 IF map(xx1i + 1, yy1i + 1) = 1 THEN blocked = 1: EXIT FOR
  110.                                 IF map(xx1i + 1, yy1i - 1) = 1 THEN blocked = 1: EXIT FOR
  111.                             NEXT
  112.  
  113.  
  114.                             IF blocked THEN
  115.  
  116.                             ELSE
  117.                                 LINE (locations(x, y).x, locations(x, y).y)-(xx2, yy2), _RGBA(128, 128, 128, 32)
  118.                                 finalConnectionId = finalConnectionId + 1
  119.                                 c = finalConnectionId
  120.  
  121.                                 IF lastConnection = -1 THEN
  122.                                     locations(x, y).firstConnectionId = c
  123.                                 ELSE
  124.                                     connections(lastConnection).nextConnectionId = c
  125.                                 END IF
  126.                                 lastConnection = c
  127.  
  128.                                 connections(c).destLocationX = x2
  129.                                 connections(c).destLocationY = y2
  130.                                 connections(c).distanceCost = CLNG(SQR((xx2 - xx1) * (xx2 - xx1) + (yy2 - yy1) * (yy2 - yy1)) * 10) 'distance cost should be calculated by movement test above
  131.  
  132.                             END IF
  133.                         END IF
  134.                     END IF
  135.                 END IF
  136.                 'test walkability
  137.             NEXT
  138.         NEXT
  139.     NEXT
  140.  
  141. TYPE ray
  142.     parentRayId AS LONG
  143.     connectionId AS LONG
  144.     distanceRemaining AS LONG
  145.     'destLocationX AS LONG
  146.     'destLocationY AS LONG
  147.  
  148. REDIM SHARED rays(1000000) AS ray
  149. lastRayId = -1
  150.  
  151. REDIM SHARED activeRayIdList(1000000) AS LONG
  152. lastActiveRayIdListId = -1
  153. REDIM SHARED activeRayIdListFreeIds(1000000) AS LONG
  154. lastActiveRayIdListFreeId = -1
  155.  
  156.  
  157. startX = 5
  158. startY = 20
  159. endX = 76
  160. endY = 55
  161.  
  162. 'add rays
  163. x = startX
  164. y = startY
  165. parentRayId = 0
  166. c = locations(x, y).firstConnectionId
  167.     lastRayId = lastRayId + 1
  168.     r = lastRayId
  169.     lastActiveRayIdListId = lastActiveRayIdListId + 1
  170.     activeRayIdList(lastActiveRayIdListId) = r
  171.     rays(r).parentRayId = parentRayId
  172.     rays(r).connectionId = c
  173.     rays(r).distanceRemaining = connections(c).distanceCost
  174.     c = connections(c).nextConnectionId
  175. PRINT lastRayId
  176.  
  177. finished = 0
  178. DO UNTIL finished
  179.     finished = 1
  180.     rayAdvancementDistance = 1
  181.     lastRayIdCached = lastRayId
  182.     FOR r = 0 TO lastRayIdCached
  183.         IF rays(r).distanceRemaining > 0 THEN
  184.             finished = 0
  185.             rays(r).distanceRemaining = rays(r).distanceRemaining - rayAdvancementDistance
  186.             ' PRINT rays(r).distanceRemaining
  187.             IF rays(r).distanceRemaining <= 0 THEN
  188.                 '      END
  189.  
  190.                 'a ray reached a destination
  191.                 c = rays(r).connectionId
  192.                 x = connections(c).destLocationX
  193.                 y = connections(c).destLocationY
  194.  
  195.                 IF locations(x, y).reached = 0 THEN
  196.                     PSET (locations(x, y).x, locations(x, y).y), _RGB(255, 255, 0)
  197.                     locations(x, y).reached = 1
  198.  
  199.                     IF x = endX AND y = endY THEN
  200.                         CIRCLE (locations(x, y).x, locations(x, y).y), 10, _RGB(255, 255, 0)
  201.                         'perform trace-back to build path
  202.                         DO WHILE r
  203.  
  204.  
  205.                             'a ray reached a destination
  206.                             c = rays(r).connectionId
  207.                             x = connections(c).destLocationX
  208.                             y = connections(c).destLocationY
  209.                             CIRCLE (locations(x, y).x, locations(x, y).y), 10, _RGB(255, 255, 0)
  210.  
  211.                             r = rays(r).parentRayId
  212.                         LOOP
  213.                         EXIT DO
  214.                     END IF
  215.  
  216.                     'add new rays
  217.                     parentRayId = r
  218.                     c2 = locations(x, y).firstConnectionId
  219.                     DO WHILE c2
  220.                         lastRayId = lastRayId + 1
  221.                         r2 = lastRayId
  222.                         lastActiveRayIdListId = lastActiveRayIdListId + 1
  223.                         activeRayIdList(lastActiveRayIdListId) = r
  224.                         rays(r2).parentRayId = parentRayId
  225.                         rays(r2).connectionId = c2
  226.                         rays(r2).distanceRemaining = connections(c2).distanceCost
  227.                         c2 = connections(c2).nextConnectionId
  228.                     LOOP
  229.                 END IF
  230.  
  231.             END IF
  232.         END IF
  233.     NEXT
  234.  
  235.  
Title: Re: Philippines in the maze
Post by: MasterGy on August 10, 2020, 01:13:42 pm
Galleon! I finally managed to understand what you mean by AI. it wasn't entirely clear because of the translation, I didn't understand what you were thinking. I understand by now. This is a universal idea. You are absolutely right, this is a very walkable path! The idea is good! No matter what the surface is, 2d, or 3d, or even how many “ds,” the point is that points are connected, and if it is calculated in advance what is the shortest path from one to another, then the puppet is immediately the shortest, “smartest” will choose a path. Thanks, I’m going to think about it a lot on what principle I could use to score points on the playing field. And then there are a lot of calculations, and there will be a universal optimal direction! thanks for the idea, very useful thought!
Title: Re: Philippines in the maze
Post by: MasterGy on August 18, 2020, 03:55:58 pm
Hi !
I develop. In the previous one, he was just throwing away the 2d elements and it was just decoration and the elements were just being thrown apart. They are now organized and animated and have an extent to stumble upon. Now it also perceives 2d elements as spatial extensions. Of course, I had to solve it so I could go through a forest if there were a lot of trees. For each element, you can specify a percentage of how much imaginary space the displayed image should be, large elements should not be 100 because you cannot go through the forest. There are forests, cornfields, sunflower fields, flower gardens. All random. I randomized what I could. I searched for gifs and solved them to animate the 2d elements. I still have a lot of ideas, I won’t test them for a try until you don’t get bored. :)


Title: Re: Philippines in the maze
Post by: bplus on August 18, 2020, 04:23:54 pm
WOW!

That is amazing!
Title: Re: Philippines in the maze
Post by: MasterGy on August 23, 2020, 06:15:36 am
Hi !

The thing is going, my only problem is that it gives an “out of memory” 1 minute after starting the game and stops.
Is there something I didn't think of? Which escapes my attention? The game at the beginning loads everything you need. After that, it only uses what is in the memory. True, it loads a lot, but if it were too much, it would stop at the beginning of the program. no ?

What could be the problem ?

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

I left only the starting bas in the package and a random track.
In the game, use the "F" key for flying mode.

https://drive.google.com/file/d/1qXWyoQLC2KkBwQ6BDOhLN8L80doAX24i/view?usp=sharing
Title: Re: Philippines in the maze
Post by: Dav on August 23, 2020, 07:50:49 am
Beautiful looking!  I especially like the cool touches like flying butterfly.  I download it and am scanning it over the code.  I don't see the problem yet, but will dig into it more today.  I thought too many opened images in a loop may be the culprit, but I dont see it.

- Dav
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 23, 2020, 09:24:00 am
A memory leak. Something is being loaded inside a loop. I'll have a look at the code in the package and see if I spot anything.
Title: Re: Philippines in the maze
Post by: FellippeHeitor on August 23, 2020, 11:15:15 am
A memory leak. Something is being loaded inside a loop. I'll have a look at the code in the package and see if I spot anything.

Whoa, I take it back. Nothing is being loaded inside the main loop. You've got a unique situation here.

I'll keep looking, but before I continue, let me just say this: I didn't follow the discussion on this project so closely and I'm late to the "blown away" party: No SUB _GL??? This is all _MAPTRIANGLE??? Cool work, man!
Title: Re: Philippines in the maze
Post by: MasterGy on August 23, 2020, 02:28:23 pm
thanks so much for looking at where the error might be, it loads everything at first, not after that, but works from what is loaded. i don't understand what could be wrong. Yes, it only contains _MAPTRIANGLE.
Title: Re: Philippines in the maze
Post by: Dav on August 23, 2020, 03:01:33 pm
I'm sorry I haven't been able to lock it down yet.  I don't see a image loading in a loop.  Could it be a recursive routine?  I'll have to play with it more. 

After a minute or two of navigating the map I get this Alert popup box:
"list add: failed to allocate new buffer, structure size:"

Then this Alert pops up:  "116". 

Then the program crashes.

Once I got a Subscript out of range error on line #460.

- Dav
Title: Re: Philippines in the maze
Post by: Galleon on August 26, 2020, 06:24:05 am
The leak is because of the way QB64 does error handling vs the C stack. The good news is if you fix the error (which is an array out of bounds error looking up a pictri2 index) you also fix the memory leak.

Code: QB64: [Select]
  1.     FOR act_ani = 0 TO ani_db - 1
  2.  
  3.         outOfBounds = 0
  4.         IF ani(act_ani, 0) THEN
  5.             merx = ani(act_ani, 5) / 2: merz = ani(act_ani, 6) / 2: wx = points2(ani(act_ani, 1), 4): wy = points2(ani(act_ani, 1), 5): wz = points2(ani(act_ani, 1), 6)
  6.             wx1 = wx - merx: wy1 = wy - merx: wz1 = wz: wx2 = wx + merx: wy2 = wy - merz: wz2 = wz: wx3 = wx - merx: wy3 = wy + merz: wz3 = wz
  7.  
  8.  
  9.             pictri2index = ani(act_ani, 4)
  10.             IF pictri2index > UBOUND(pictri2) THEN outOfBounds = 1
  11.             IF outOfBounds = 0 THEN
  12.  
  13.  
  14.                 IF ani(act_ani, 8) THEN
  15.  
  16.                     ksx1 = 0: ksy1 = _HEIGHT(pictri2(ani(act_ani, 4))) - 1: ksx2 = _WIDTH(pictri2(ani(act_ani, 4))) - 1: ksy2 = ksy1: ksx3 = 0: ksy3 = 0: ksx4 = ksx2: ksy4 = ksy3
  17.  
  18.                 ELSE
  19.  
  20.  
  21.                     ksx1 = _WIDTH(pictri2(ani(act_ani, 4))) - 1: ksy1 = _HEIGHT(pictri2(ani(act_ani, 4))) - 1: ksx2 = 0: ksy2 = ksy1: ksx3 = ksx1: ksy3 = 0: ksx4 = 0: ksy4 = ksy3
  22.  
  23.  
  24.                 END IF
  25.  
  26.  
  27.                 sx1 = ksx1: sy1 = ksy1: sx2 = ksx2: sy2 = ksy2: sx3 = ksx3: sy3 = ksy3
  28.  
  29.                 ihandle& = pictri2(ani(act_ani, 4))
  30.                 IF ihandle& <> 0 THEN
  31.                     _MAPTRIANGLE (sx1, sy1)-(sx2, sy2)-(sx3, sy3), pictri2(ani(act_ani, 4)) TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3), , _SMOOTH
  32.                     wx1 = wx + merx: wy1 = wy + merx: wz1 = wz: wx2 = wx + merx: wy2 = wy - merz: wz2 = wz: wx3 = wx - merx: wy3 = wy + merz: wz3 = wz
  33.                     sx1 = ksx4: sy1 = ksy4: sx2 = ksx2: sy2 = ksy2: sx3 = ksx3: sy3 = ksy3
  34.                     _MAPTRIANGLE (sx1, sy1)-(sx2, sy2)-(sx3, sy3), pictri2(ani(act_ani, 4)) TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3), , _SMOOTH
  35.                 END IF
  36.  
  37.  
  38.             END IF
  39.  
  40.         END IF
  41.     NEXT act_ani
Title: Re: Philippines in the maze
Post by: MasterGy on September 09, 2020, 02:20:30 pm
Hi !
I finally managed to make sure it didn’t stop with “out of memory”. Resolved by resizing the textures. Although I don't understand the connection, why would that be a problem?
Innovation:

-So far as I found images of texture on the net, I put them in their original form in the game folder. I had to figure out that what is 5 high on the screen should be 5x pixels. What is 10 high is 10x pixels, so the size of the image should be proportional to the size used in the game. The quality of the textures can be adjusted universally at the beginning of the creator, and he will scale the raw images accordingly, taking into account their size used in the game. It was a good idea, the “out of memory” was eliminated, and the size of all the images created in this way was 20% of the size of the original, so that there was no noticeable deterioration in quality.

-Old object perception proved to be slow. In vain I divided the space into cells to examine only those objects that are close, for example, at 2,000 butterflies the whole thing slowed down… believe then at 20 fps 20x2000 butterflies per second x pl 30 objects, then the multiplication of 18000 x6, sin, cos… sir god. i threw out this solution and as it is, the creator fills a high resolution 3d bit matrix so a lot of computation is saved because with a simple situation proportional reading I get whether there is YES or NO material. So the size of the array will be hundreds of Mb, but well… something for something!

-I also refined the controls to make it more ergonomic. For example, if you are going against the wall, do not stop, but look for the angle so that you can pass. This is how all fps games work, so it was mandatory for me to solve.

-I thoroughly reviewed what calculations could be used to save time and simplify. During filming, I found something that was unnecessary in the old versions. I saved resources.

The result is that I feel like the engine that works very efficiently on _maptriangle has finally been born. When you start the game, you can see that there is no need to limit the number of maptriangles. The main cycle is set to 20 –fps (_LIMIT), but if you press the L button, it will release (no limit) and you can really see that everything is visible, lots of snapshots, animated images, and lots of resources left. This will be important later. It finally runs fast, flexibly, doesn’t crash.

https://drive.google.com/file/d/1xGQeHCFSs7_XIpQ9pv2u3N_NR2jPn-W4/view?usp=sharing (https://drive.google.com/file/d/1xGQeHCFSs7_XIpQ9pv2u3N_NR2jPn-W4/view?usp=sharing)
Title: Re: Philippines in the maze
Post by: MasterGy on September 09, 2020, 02:23:58 pm

Now I'm reading your solution Galleon! Yet I look up regularly and even wait. whether someone writes and your last answer completely escaped my attention! :( I’m reading now that I’ve unloaded this. Thank you so much for dealing with it, I will enroll you in the program so there are no more. I am very happy, thank you for the explanation !!!
Title: Re: Philippines in the maze
Post by: MasterGy on September 26, 2020, 03:02:15 pm
Hi !

-Preform color channels can be created by pre-mixing the textures.
-Additional objects, architectural solutions.
-Gate system

Next, I set up a system in which the key-gate principle is realized either passively or by task, and it is possible to go through otherwise linear random trajectories by completing quests.
The video shows 3 tracks with different color mixes.



Title: Re: Philippines in the maze
Post by: MasterGy on October 03, 2020, 02:30:29 pm
Hi !

Lots of small fixes, things work. I've been exhausted for something lately.

have you ever looked at the source code and understood nothing? I need inspiration to continue, so that I can't even figure out on paper how to create the key-gate… character-object principle, which will then randomly generate a series of tasks, so the course of the game. I got stuck, it makes no sense for me to deal with it that way. I hope the inspiration will be there as soon as possible and I can finish.

in the meantime i put the save in the cloud, share it if you feel like it, try it. ergonomic handling, linear layout, gates where they should be. Minimal gaming experience comes from finding the qb logo. That is it for now.

https://drive.google.com/file/d/1JIrVMT3CN05-MfDhXdZVIfj8N0wWJSVw/view?usp=sharing (https://drive.google.com/file/d/1JIrVMT3CN05-MfDhXdZVIfj8N0wWJSVw/view?usp=sharing)