Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ki1o

Pages: [1] 2 3 ... 9
1
Axe / Re: Converting from Prgm to App
« on: Yesterday at 09:41:08 pm »
Thanks for taking the time to look it over and reply. I tried inverting it and the issue still persisted. I'm not sure what the problem could be. Can you try compiling and running it when you get a chance? If possible, uncomment the first AddMob so that you can also test the AI to see how it behaves on your calc. I open a new Wabbit when I compile and test, so the RAM is always clear. Here's a screenshot showing what's happening with both the tilemap and the AI.

I don't know how to proceed with trying to fix it.

Also I can't take full credit for the tile code. It's mostly Runer's from his GRAYPKMN source that I modified and repurposed for monochrome. Took a while to read and understand haha. I'm also considering possibly using Fullrene or Crabcake if converting to an app is somehow impossible. I'll keep trying to debug this. Also if you're willing to help me learn and optimize my code maybe we can work together sometime. Thanks again.

2
Axe / Converting from Prgm to App
« on: March 23, 2023, 10:28:52 pm »
Way way late, but thanks to both E37 and Zeda I was able to implement a working A* Algorithm in my game. The source for the project is on Github here: https://github.com/kiloments/axe-rl
I've been pretty inconsistent in working on it, but recently I started back up again. I've reached the point where I need to make the program into an app. I thought it would be as simple as change from compiling to No Shell to Compiling as an Application, but once I did it looked like the my appvars were somehow being corrupted. When I moved around the map random tiles would get changed when I left an area and came back to it. The attached gif illustrates what I mean.

You can also see a little confused slime walking outside the map. This is because the DistMap appvar I'm using to calculate the AI is somehow also being corrupted. It's initially spawned in the room that gets corrupted then wanders its way out ignoring collision. I even compiled an older working version to verify and it seems to confirm. Everything works as a program and not as an App. I would like any help in beginning to convert this project into an app. And any other advice/optimizations you may have. Thanks!

3
Axe / Re: A* Star and Min Heap Help
« on: July 10, 2022, 11:28:53 am »
Yes that is correct. Not sure if the While loop condition is the problem or the Swap function.

4
Axe / A* Star and Min Heap Help
« on: July 10, 2022, 10:55:38 am »
I've been trying to implement an A* Star algorithm in Axe, but I've been encountering a whole host of bugs or things I can't explain. I need help so I'm hoping that @E37 reads this. It is in this code where I also get a few appvar bugs. Here is the whole AI code so far.
Code: [Select]
..AI
L2+00->->^^oDistMap
L2+02->->^^oTargetX
L2+04->->^^oTargetY
L2+06->->^^oStartX
L2+08->->^^oStartY
L2+10->->^^oCurrX
L2+12->->^^oCurrY
L2+14->->^^oHCost
L2+16->->^^oGCost
L2+18->->^^oSize
L2+20->->^^oMinIndex
L2+22->->^^oRoot
L2+24->->^^oRIndex
L2+26->->^^oMinHeap
Data(~1,1,~36,36)->^^oAIDir
Goto AIEND
Lbl DoMobAI
DrawGame()
For(M,0,Mobs-1)
^^oMobArray+(M*4)->Mob
CalculatePath(NewX,NewY,{^^oMobX+Mob},{^^oMobY+Mob})
End
Return
Lbl CalculatePath
GetCalc("appvDISTMAP")->DistMap
Fill(^^oTargetX,400,0)
~3->Size
Fill(DistMap,1296,|EFF)
[r1]->TargetX
[r2]->TargetY
[r3]->StartX
[r4]->StartY
Ge\tDistance(TargetX,TargetY,StartX,StartY)->HCost
GCost->{(TargetY-6)*36+(TargetX-6)+DistMap}
Insert(TargetX,TargetY)
While 1
Extract()->A
GCost++
0->J
For(4)
A+sign{^^oDir+J}->T
T^48->CurrX
T/48->CurrY
(CurrY-6)*36+(CurrX-6)->C
If ({T+Floor}<2)?({C+DistMap}=|EFF)
Ge\tDistance(CurrX,CurrY,StartX,StartY)->HCost
Insert(CurrX,CurrY)
GCost->{C+DistMap}
End
J++
End
EndIf ((CurrX=StartX)?(CurrY=StartY))
Return
Lbl Parent
Return ([r1]-3)/6
Lbl LeftChild
Return (6*[r1])+3
Lbl RightChild
Return (6*[r1])+6
Lbl ShiftUp
While ([r1]>>0)?({^^oMinHeap+Parent([r1])}>{^^oMinHeap+[r1]})
Swap(Parent([r1]),[r1])
Parent([r1])->[r1]
End
Return
Lbl ShiftDown
While 1
LeftChild([r1])->MinIndex+3->RIndex
If RIndex<<Size
If {^^oMinHeap+RIndex}<{^^oMinHeap+MinIndex}
RIndex->MinIndex
End
End
Swap([r1],MinIndex)
MinIndex->[r1]
EndIf (Size<<MinIndex)?({^^oMinHeap+MinIndex}>={^^oMinHeap+[r1]})
Return
Lbl Swap
{^^oMinHeap+[r1]}->[r3]
{^^oMinHeap+[r1]+1}^^r->[r4]
{^^oMinHeap+[r2]}->{^^oMinHeap+[r1]}
{^^oMinHeap+[r2]+1}^^r->{^^oMinHeap+[r1]+1}^^r
[r3]->{^^oMinHeap+[r2]}
[r4]->{^^oMinHeap+[r2]+1}^^r
Return
Lbl Insert
GCost+HCost->[r3]
([r2]*^^oFloorWidth+[r1])->{[r3]->{Size+3->Size+^^oMinHeap}+1}^^r
ShiftUp(Size)
Return
Lbl Extract
{^^oMinHeap+1}^^r->Root
{^^oMinHeap+Size}->{^^oMinHeap}
{^^oMinHeap+Size+1}^^r->{^^oMinHeap+1}^^r
Size-3->Size
ShiftDown(0)
Return Root
Lbl Ge\tDistance
abs([r1]-[r3])+abs([r2]-[r4])
Return
Lbl AIEND
First off, the appvar bugs that I have been getting. I am declaring the point for the DISTMAP appvar at the same time as the FLOOR appvar like so:
Code: [Select]
GetCalc("appvFLOOR",2304)->Floor
GetCalc("appvDISTMAP",1296)->DistMap
I'm only editing the floor appvar. I do not resize this in any way. If I do not call
Code: [Select]
GetCalc("appvDISTMAP")->DistMap again in CalculatePath(), then nothing will happen and the appvar doesn't get modified even though it exists. If I create the appvar in the AI code, then the pointers for the floor and the distmap somehow get mixed up and random garbage is scrolled in on the screen. The same thing happens if the distmap appvar already exists when I run the main program. However this only occurs for the distmap appvar as the floor appvar never has this issue. Also calling
Code: [Select]
DelVar "appvDISTMAP" does nothing. Not sure how this works. Please explain appvars to me like I'm 5 because something is not making sense.
Another bug I experience is using custom named variables to hold function labels. If that's not something that's possible please let me know. I know custom variables are 2 bytes and I am making sure of that so I don't know what is going on there. It only works with Alpha variables.
Back to the MinHeap, my ShiftUp function seems to do nothing. I don't know where the logic is failing. Each entry in the MinHeap is 3 bytes. The first byte is the F Cost of a given tile and the 2 bytes after that are the tile's offset. I'm trying to sort by F Cost, so that the lowest F Cost is the root of the MinHeap. Is the problem with my ShiftUp function or the Swap function? Please help! Thanks  :banghead:

5
Axe / Re: Axe Q&A
« on: July 10, 2022, 12:56:01 am »
Its more like a little note to the compiler that tells it to replace that named constant with the value you assigned it.

6
Axe / Re: Axe Q&A
« on: July 09, 2022, 10:11:48 pm »
You use the degree when you are first naming any constant. If you are going to use it as a variable elsewhere you no longer need the degree when using it. On the other hand, if you are using the named constant for its value, then you always need the degree.

7
Axe / Re: Axe Q&A
« on: July 09, 2022, 08:45:39 pm »
Hey there! If you are talking about custom named variables, what you can do is take a memory location and give it a name using the degree symbol like so:
Code: [Select]
L1+00->->°MyVarThen you can use it as a variable in any way like so:
Code: [Select]
42->MyVarAny custom variable you create will always be 2 bytes in size.
If you use this for any other value that is not a memory location, it is basically a named constant that you can use in place of that number. It serves no purpose outside of improving readability, but it is helpful.
When using named constants you must include the degree symbol. This is not the case when using a custom variable.
There are a few additional rules for naming anything in Axe. They must begin with a capital letter and they cannot be more than 13 characters long. They must also only contain letters or numbers. Hope this helps.

8
Axe / Re: Axe Q&A
« on: July 06, 2022, 02:22:00 am »
I'm starting to think that this is just an Axe bug. I'm never resizing or deleting or recreating, just editing them. I "fixed" the problem by calling GetCalc again before I manipulate the appvar. I have another issue. It seems that signed comparison or signed operations don't seem to work.
I have a line of code that looks like this:
Code: [Select]
~8->{°MobOX+Mob}Later on I call a function that looks like this:
Code: [Select]
Lbl AnimateMob
For(I,0,Mobs-1)
°MobArray+(I*4)->Mob
If {°MobOX+Mob}>>0
{°MobOX+Mob}--
End
If {°MobOX+Mob}<<0
{°MobOX+Mob}+1->{°MobOX+Mob}
End
If {°MobOY+Mob}>>0
{°MobOY+Mob}--
End
If {°MobOY+Mob}<<0
{°MobOY+Mob}+1->{°MobOY+Mob}
End
End
Return
However, despite being a signed comparison, it still treats {°MobOX+Mob} as some large number and decrements it instead. I've used the sign{} command but that only breaks it further. How do I do this? It's starting to feel like I really have to fight the language to do simple things. I've hand calculated the offsets so nothing is off there when I draw. It is literally not working with negative numbers. I've subtracted 8 instead, I've changed the comparison from signed to unsigned. I'm really at a loss here. Please help!

9
Axe / Re: Axe Q&A
« on: July 05, 2022, 12:15:56 am »
Does Axe not allow you to manipulate more than one appvar at a time? I'm getting some really strange bugs when I do. I have 2 appvars that I create in RAM. One is the appvar for the current generated floor in my game. The second appvar is supposed to be another map that I am going to use in my AI calculation that I call DistMap. I running across several strange bugs with Axe when I do this. If I create both appvars at the same time, I am no longer able to manipulate the DistMap appvar if I do anything with the Floor appvar. In this case all I am trying to do is fill it with some value for now. If I instead create the DistMap appvar whenever I press a button (down in this case), the tilemap gets corrupted somehow. Or rather, it seems as if the 2 pointers are getting mixed up somehow. Because when I try to move down a bunch of corrupted tiles are scrolled in instead. Any ideas?

10
Introduce Yourself! / Re: Hello!
« on: June 29, 2022, 09:39:10 pm »
Hey there! Welcome! Always happy to see more Axe programmers! I'm not as proficient as Zeda or E37 but I'm also around! If you want any tips I am happy to help as well.

11
Axe / Re: Looping Through an Array in Axe
« on: February 22, 2022, 04:46:01 pm »
@E37
Thanks for the compliment on my formatting and thanks for the reply as usual. I've been trying to track down the problem by commenting out the actual Connect() lines and dumping out what values I was getting for my PathFrom/PathTo and Corridor values. Honestly after hours of checking and changing a few things around and checking again, I never was able to find out what the problem was. Eventually I was just drawing the corridors to the map to see where they were in relation to the rooms and I saw that if the corridor was right next to a room, then that would result in a negative value in the Connect() function and definitely cause a crash. But I couldn't properly debug what those values were because something somewhere was getting corrupted and spitting out garbage values. Because of this, I decided to simply scrap how I was doing room connections and try again from scratch. Which now leads me to a completely different problem that I also don't know how fix let alone what it causing this.

Right now I am starting from the beginning and I am trying to test each value before I move on, but I encountered this:
Code: [Select]
For(I,0,7)
If ({°RegionArray+I}=1)
If I^3<2
{°RoomArray+I}->Room
{°RoomY+Room}+1+(rand^({°RoomY+Room}+{°RoomHeight+Room}-{°RoomY+Room}+1))->{°CorridorArray+I}
End
End
End
So what this is saying is that if the room at the current index exists, then generate choose a value between the top of the room+1 and the bottom of the room-1. This is just the first step so we can start connecting rooms. I'm storing those values to an array so I can dump then to the screen.
The problem is that
Code: [Select]
If ({°RegionArray+I}=1) seems to be ignored for the 0th room and is producing wrong values for the others. In the screenshot what is shown are the (X,Y) then Width and Height, the value of RegionArray at their index, and finally the value being generated in the above snippet. Rooms without a height or width but have and X and Y are dummy rooms. I'm planning to use those later, so you can ignore those. The first room on this seed is a dummy room. The value of RegionArray+0 is clearly 0, yet there is still a value at CorridorArray+0. What is going on here? I really need all the help I can get at this point because this really shouldn't be an issue yet it is.

12
Axe / Re: Looping Through an Array in Axe
« on: February 17, 2022, 07:57:52 pm »
A few more months, a bit more progress. Once again I'd like to say thanks for all the help and suggestions. With that being said, I've run into another issue and this time I'm not even sure what the cause is.

So here is the problem:
I have successfully written an algorithm to generate 4-6 non-intersecting rooms and I'm attempting to connect them. I wrote some code that is supposed to accomplish this task, but it seems to only work once. As in, any attempts to execute this task consecutively in any manner promptly results in a RAM clear. Here is the code in question that I am using to connect rooms:
Code: [Select]
Data(31,31,3,31,31,3,1,1)->°RegionCheck
Lbl ConnectRooms
For(I,0,7)
If {°RegionArray+I}
{°RegionCheck+I}^10->AdjacentRoom
If {°RegionArray+I+AdjacentRoom}
GetAdjRoom()
°RoomArray+(I*4)->Room
ConnectTo(AdjacentRoom)
End
If {°RegionCheck+I}/10->AdjacentRoom
GetAdjRoom()
°RoomArray+(I*4)->Room
ConnectTo(AdjacentRoom)
End
End
End
Return
Lbl GetAdjRoom
°RoomArray+(I+AdjacentRoom*4)->Room
{°RoomX+Room}->AdjacentRoomX
{°RoomY+Room}->AdjacentRoomY
{°RoomWidth+Room}->AdjRoomWidth
{°RoomHeight+Room}->AdjRoomHeight
Return
Lbl ConnectTo
.../Args
ConnectTo(AdjacentRoom)
...
If [r1]=°Below
{°RoomX+Room}+1+(Rand()^({°RoomWidth+Room}-2))->PathFromX
AdjacentRoomX+1+(Rand()^(AdjRoomWidth-2))->PathToX
If PathFromX=PathToX
Connect(PathFromX,{°RoomY+Room}+{°RoomHeight+Room},PathToX,AdjacentRoomY-1)
Else
If AdjacentRoomY-1-{°RoomY+Room}+{°RoomHeight+Room}>4
{°RoomY+Room}+{°RoomHeight+Room}+1+(Rand()^(AdjacentRoomY-({°RoomY+Room}+{°RoomHeight+Room}-1)))->CorridorY
Connect(min(PathFromX,PathToX),CorridorY,max(PathToX,PathFromX),CorridorY)
Connect(PathFromX,{°RoomY+Room}+{°RoomHeight+Room},PathFromX,CorridorY)
Connect(PathToX,CorridorY,PathToX,AdjacentRoomY-1)
Else
Rand()^1->P
If P
Connect(PathFromX,{°RoomY+Room}+{°RoomHeight+Room},PathFromX,AdjacentRoomY-1)
Else
Connect(PathToX,{°RoomY+Room}+{°RoomHeight+Room},PathToX,AdjacentRoomY-1)
End
End
End
End
If [r1]=°Right
{°RoomY+Room}+1+(Rand()^({°RoomHeight+Room}-2))->PathFromY
AdjacentRoomY+1+(Rand()^(AdjRoomHeight-2))->PathToY
If PathFromY=PathToY
Connect({°RoomX+Room}+{°RoomWidth+Room},PathFromY,AdjacentRoomX-1,PathToY)
Else
If AdjacentRoomX-1-{°RoomX+Room}+{°RoomWidth+Room}>4
{°RoomX+Room}+{°RoomWidth+Room}+1+(Rand()^(AdjacentRoomX-({°RoomX+Room}+{°RoomWidth+Room}-1)))->CorridorX
Connect(CorridorX,min(PathFromY,PathToY),CorridorX,max(PathToY,PathFromY))
Connect({°RoomX+Room}+{°RoomWidth+Room},PathFromY,CorridorX,PathFromY)
Connect(CorridorX,PathToY,AdjacentRoomX-1,PathToY)
Else
Rand()^1->P
If P
Connect({°RoomX+Room}+{°RoomWidth+Room},PathFromY,AdjacentRoomX-1,PathFromY)
Else
Connect({°RoomX+Room}+{°RoomWidth+Room},PathToY,AdjacentRoomX-1,PathToY)
End
End
End
End
Return
Lbl Connect
.../Args
Connect(X1,Y1,X2,Y2)
...
If [r1]=[r3]
For(J,0,[r4]-[r2])
0->{[r2]*°FloorWidth+[r1]+Floor+(J*48)}
End
End
If [r2]=[r4]
Fill([r2]*°FloorWidth+[r1]+Floor,[r3]-[r1]+1,0)
End
Return
In addition, any number greater than 2 in place of "I" will also cause a RAM clear.
Xeda was helping me over on the Cemetech discord, but frankly we are both lost on what the issue could be.
Overview of the current problem: inputting numbers greater than 2 as the offset of the current room causes a RAM clear and executing the code to connect rooms consecutively causes a RAM clear regardless of room "validity". As an example, if I were to change the For loop in ConnectRooms() from
Code: [Select]
For(I,0,7) to
Code: [Select]
For(I,0,1) there is no issue. This is because on the seed I'm using to test, there is no 0th room. So it is skipped and instead connects the 1st room. However it crashes once it hits 2 as the doesn't like being executed consecutively. If I were to generate additional floors of the same seed, the first room that is valid can have its connections made, but no further. I've done a lot of different tests but now I need help. Is there something that I overlooked or am not taking into account? I've attached a screenshot to further illustrate.

13
Axe / Re: Looping Through an Array in Axe
« on: December 14, 2021, 11:38:40 pm »
Its been a few months. I've been working on this project on and off and I have come across another issue that I need help with. I'm currently working on the procedural generation and I'm stuck. Currently I'm simply trying to select a starting locations for a set of rooms. The desired behavior I want is this: the first room generated is placed within the bounds of the map and the height and width are chosen so as not to go out of the map bounds. Then the X and Y of the starting location as well as the Xmax and the Ymax of that room is added to an array. Every subsequent starting room location that is generated must be compared to every other room in the array to ensure that the starting location is not going to be inside an already existing room. I've been trying different ways to tackle this problem and I thought I came up with a solution, but after running test after test after, I keep coming across starting locations that fail the check but are still being added to the array as valid rooms.
So, once again, I need some help. I wrote a test program that shows the X, Y, Xmax and Ymax of 9 total rooms. Here is the code:
Code: [Select]
.G
L₄+12→→°XMin
L₄+14→→°XMax
L₄+16→→°YMin
L₄+18→→°YMax
L₄+20→→°Rooms
L₄+22→→°RoomStart
L₄+24→→°RoomWidth
L₄+26→→°RoomHeight
L₄+28→→°RoomX
L₄+30→→°RoomY
L₄+32→→°NewRoomX
L₄+34→→°NewRoomY
Fill(L₁,36,0)
0→Rooms→RoomX→RoomY→RoomHeight→RoomWidth→R
ClrDraw
GenFloor()
CheckFloor()
Main()
Lbl Main
  While 1
    DispGraph
    Input()
  EndIf getKey(15)
Return
Lbl CheckFloor
  For(R,0,Rooms-1)
    R+1*4+L₁-4→Z
    R+1*5-4→Y
    R+1*4+L₁-4→Z
    {Z}→XMin
    {Z+2}→XMax
    {Z+1}→YMin
    {Z+3}→YMax
    DrawText(1,Y,"(")
    DrawInt(4,Y,{Z})
    DrawText(13,Y,",")
    DrawInt(16,Y,{Z+1})
    DrawText(24,Y,")")
    DrawInt(29,Y,XMin)
    DrawInt(38,Y,XMax)
    DrawInt(47,Y,YMin)
    DrawInt(56,Y,YMax)
  End
Return
Lbl GenFloor
  While Rooms<9
    GenRoom()
    PlaceRoom()
    0→R
  End
Return
Lbl GenRoom
  !If Rooms
    GetRoomStart()
    While 1
      GetRoomSide()→RoomWidth
    End!If ChkRoomWidth()
    While 1
      GetRoomSide()→RoomHeight
    End!If ChkRoomHeight()
  Else
    GetRoomStart()
    While R<Rooms-1
      R+1*4+L₁-4→Z
      {Z}→XMin
      {Z+2}→XMax
      {Z+1}→YMin
      {Z+3}→YMax
      If (RoomX≥XMin and RoomX≤XMax) and (RoomY≥YMin and RoomY≤YMax)
        0→R
        GetRoomStart()
      End
      !If (RoomX≥XMin and RoomX≤XMax) and (RoomY≥YMin and RoomY≤YMax)
        R++
      End
    End
    While 1
      GetRoomSide()→RoomWidth
    End!If ChkRoomWidth()
    While 1
      GetRoomSide()→RoomHeight
    End!If ChkRoomHeight()
  End
Return
Lbl PlaceRoom
  If Rooms<9
    RoomY+RoomHeight-1→{RoomX+RoomWidth-1→{RoomY→{RoomX→{Rooms+1→Rooms*4+L₁-4}+1}+1}+1}
  End
Return
Lbl GetRoomStart
  6+(rand^33)→RoomX
  4+(rand^37)→RoomY
Return
Lbl GetRoomSide
  4+(rand^9)
Return
Lbl ChkRoomWidth
  (RoomX+RoomWidth-1>41)
Return
Lbl ChkRoomHeight
  (RoomY+RoomHeight-1>43)
Return
Lbl DrawText
  For(I,0,length(r₃)-1)
    Copy({r₃+I}-32*4+°CharSprites,L₄+50,4)
    Fill(L₄+54,4,0)
    DrawChar()
  End
Return
Lbl DrawInt
  r₃/10+16→{L₅}
  r₃^10+16→{L₅+1}
  For(I,0,1)
    Copy({L₅+I}*4+°CharSprites,L₄+50,4)
    Fill(L₄+54,4,0)
    DrawChar()
  End
Return
Lbl DrawChar
  Pt-On(r₁+(I*((I>0)*4)),r₂,L₄+50)
Return
Lbl Input
  If getKey(9)
    ClrDraw
    0→Rooms
    GenFloor()
    CheckFloor()
  End
Return
[]→°CharSprites
[0000000080800080]
[A0A00000A0E0E0A0]
[60C060C0A060C0A0]
[40A060E040400000]
[4080804040202040]
[A040A0000040E040]
[000040800000E000]
[0000008000204080]
[E0A0A0E0C04040E0]
[E020C0E0E06020E0]
[A0A0E020E08060E0]
[E080E0E0E0204040]
[E0A0E0E0E0A0E020]
[4000400040004080]
[0020402000E000E0]
[00804080E0200040]
[40A0E04060A0E0A0]
[C0E0A0E0E08080E0]
[C0A0A0E0E0C080E0]
[E0C08080E080A0C0]
[A0E0A0A0E04040E0]
[6020A040A0C0A0A0]
[808080E0E0E0A0A0]
[C0A0A0A0C0A0A060]
[C0A0E080E0A0E040]
[C0A0C0A0E08020E0]
[E0404040A0A0A060]
[A0A0A040A0A0E0E0]
[A040A0A0A0A04040]
[E02080E000000000]

I also attached a screenshot. In the screenshot, room (33,19) should not be a valid starting location for a room because of room (28,17). 33 is clearly between 28 and 35, and 19 is also between 17 and 26. Therefore, what should have happened is that GetRoomStart() should have been called and it should have been compared to the other rooms. Instead it was treated like a valid room and added to the array. I've been having weird issues with while loops all week so far as well. Any and all help would be greatly appreciated.

14
Axe / Re: Axe Loops not Working as Expected
« on: December 09, 2021, 08:08:20 pm »
Thanks for the optimization, however even with that change there wasn't any change at all. Sorry if its hard to follow, that's the unformatted tokenized text. Perhaps this would be a bit more readable:
Code: [Select]
.G
L4+22->->°RoomStart
L4+24->->°RoomWidth
L4+26->->°RoomHeight
L4+28->->°RoomX
L4+30->->°RoomY
L4+32->->°NewRoomX
L4+34->->°NewRoomY
L4+36->->°Invalid
L4+38->->°UR
L4+40->->°LL
L4+42->->°NewRoomX2
L4+44->->°NewRoomY2
L4+20->->°Rooms
Fill(L1,36,0)
0->Rooms->RoomX->RoomY->RoomHeight->RoomWidth
ClrDraw
GenFloor()
CheckFloor()
Main()
Lbl Main
While 1
DispGraph
Input()
EndIf getKey(15)
Return
Lbl CheckFloor
For(J,1,Rooms)
J*4+L1-4->Z
J*5-4->Y
DrawText(1,Y,"(")
DrawInt(4,Y,{Z})
DrawText(13,Y,",")
DrawInt(16,Y,{Z+1})
DrawText(24,Y,")")
DrawInt(29,Y,{Z+2})
DrawInt(38,Y,{Z+3})
End
Return
Lbl GenFloor
While Rooms<9
GenRoom()
PlaceRoom()
End
Return
Lbl GenRoom
GetRoomStart()
While 1
GetRoomSide()->RoomWidth
End!If ChkRoomWidth()
While 1
GetRoomSide()->RoomHeight
End!If ChkRoomHeight()
Return
Lbl PlaceRoom
If Rooms<9
RoomY+RoomHeight-1->{RoomX+RoomWidth-1->{RoomY->{RoomX->{Rooms+1->Rooms*4+L1-4}+1}+1}+1}
End
Return
Lbl GetRoomStart
6+(rand^(33))->RoomX
4+(rand^(40))->RoomY
Return
Lbl GetRoomSide
4+(rand^(9))
Return
Lbl ChkRoomWidth
(RoomX+RoomWidth-1>41)
Return
Lbl ChkRoomHeight
(RoomY+RoomHeight-1>43)
Return
Lbl DrawText
For(I,0,length([r3])-1)
Copy({[r3]+I}-32*4+°CharSprites,L4+50,4)
Fill(L4+54,4,0)
DrawChar()
End
Return
Lbl DrawInt
[r3]/10+16->{L5}
[r3]^10+16->{L5+1}
For(I,0,1)
Copy({L5+I}*4+°CharSprites,L4+50,4)
Fill(L4+54,4,0)
DrawChar()
End
Return
Lbl DrawChar
Pt-On([r1]+(I*((I>0)*4)),[r2],L4+50)
Return
Lbl Input
If getKey(9)
ClrDraw
0->Rooms
GenFloor()
End
Return
[]->°CharSprites
[0000000080800080]
[A0A00000A0E0E0A0]
[60C060C0A060C0A0]
[40A060E040400000]
[4080804040202040]
[A040A0000040E040]
[000040800000E000]
[0000008000204080]
[E0A0A0E0C04040E0]
[E020C0E0E06020E0]
[A0A0E020E08060E0]
[E080E0E0E0204040]
[E0A0E0E0E0A0E020]
[4000400040004080]
[0020402000E000E0]
[00804080E0200040]
[40A0E04060A0E0A0]
[C0E0A0E0E08080E0]
[C0A0A0E0E0C080E0]
[E0C08080E080A0C0]
[A0E0A0A0E04040E0]
[6020A040A0C0A0A0]
[808080E0E0E0A0A0]
[C0A0A0A0C0A0A060]
[C0A0E080E0A0E040]
[C0A0C0A0E08020E0]
[E0404040A0A0A060]
[A0A0A040A0A0E0E0]
[A040A0A0A0A04040]
[E02080E000000000]
Still not sure what's causing the bug let alone where to begin. I've changed the loop from a while loop to a repeat loop and there still was no change. What makes this all the more frustrating is that this exact structure and code works in another program. Somehow this program alone is having issues and I'm not sure why that would even be the case. Maybe Axe is just bugged? I don't feel like that's the case since many people have created vastly more complicated projects than this and I have yet to see anything about loops simply not working/crashing.

15
Axe / Axe Loops not Working as Expected
« on: December 09, 2021, 07:26:50 pm »
I am working on a basic debugger for procedurally generated floors for my roguelike project. However, I am running into a recurring issue that I am not sure how to fix, let alone what the cause may be. I am hoping that someone with a bit more knowledge on Axe can tell me what I am doing wrong, or if there is simply an issue with Axe or the calculator.

What I am attempting to do simply generate 9 rooms and take a look at the values of the room to see if they are acceptable. However I keep randomly getting stuck in a loop either when the program executes, or when I try to give it any input. Here is the full source:

Code: [Select]
.G
L₄+22→→°RoomStart
L₄+24→→°RoomWidth
L₄+26→→°RoomHeight
L₄+28→→°RoomX
L₄+30→→°RoomY
L₄+32→→°NewRoomX
L₄+34→→°NewRoomY
L₄+36→→°Invalid
L₄+38→→°UR
L₄+40→→°LL
L₄+42→→°NewRoomX2
L₄+44→→°NewRoomY2
L₄+20→→°Rooms
Fill(L₁,36,0)
0→Rooms→RoomX→RoomY→RoomHeight→RoomWidth
ClrDraw
GenFloor()
CheckFloor()
Main()
Lbl Main
While 1
Input()
EndIf getKey(15)
Return
Lbl CheckFloor
For(J,1,Rooms)
J*4+L₁-4→Z
J+(J*((J>0)*4))-4→Y
DrawText(1,Y,"(")
DrawInt(4,Y,{Z})
DrawText(13,Y,",")
DrawInt(16,Y,{Z+1})
DrawText(24,Y,")")
DrawInt(29,Y,{Z+2})
DrawInt(38,Y,{Z+3})
End
Return
Lbl GenFloor
While Rooms<9
GenRoom()
PlaceRoom()
End
Return
Lbl GenRoom
GetRoomStart()
While 1
GetRoomSide()→RoomWidth
End!If ChkRoomWidth()
While 1
GetRoomSide()→RoomHeight
End!If ChkRoomHeight()
Return
Lbl PlaceRoom
If Rooms<9
RoomY+RoomHeight-1→{RoomX+RoomWidth-1→{RoomY→{RoomX→{Rooms+1→Rooms*4+L₁-4}+1}+1}+1}
End
Return
Lbl GetRoomStart
6+(rand^(33))→RoomX
4+(rand^(40))→RoomY
Return
Lbl GetRoomSide
4+(rand^(9))
Return
Lbl ChkRoomWidth
(RoomX+RoomWidth-1>41)
Return
Lbl ChkRoomHeight
(RoomY+RoomHeight-1>43)
Return
Lbl DrawText
For(I,0,length(r₃)-1)
conj({r₃+I}-32*4+°CharSprites,L₄+50,4)
Fill(L₄+54,4,0)
DrawChar()
End
Return
Lbl DrawInt
r₃/10+16→{L₅}
r₃^10+16→{L₅+1}
For(I,0,1)
conj({L₅+I}*4+°CharSprites,L₄+50,4)
Fill(L₄+54,4,0)
DrawChar()
End
Return
Lbl DrawChar
Pt-On(r₁+(I*((I>0)*4)),r₂,L₄+50)
Return
Lbl Input
If getKey(9)
ClrDraw
0→Rooms
GenFloor()
End
Return
[]→°CharSprites
[0000000080800080]
[A0A00000A0E0E0A0]
[60C060C0A060C0A0]
[40A060E040400000]
[4080804040202040]
[A040A0000040E040]
[000040800000E000]
[0000008000204080]
[E0A0A0E0C04040E0]
[E020C0E0E06020E0]
[A0A0E020E08060E0]
[E080E0E0E0204040]
[E0A0E0E0E0A0E020]
[4000400040004080]
[0020402000E000E0]
[00804080E0200040]
[40A0E04060A0E0A0]
[C0E0A0E0E08080E0]
[C0A0A0E0E0C080E0]
[E0C08080E080A0C0]
[A0E0A0A0E04040E0]
[6020A040A0C0A0A0]
[808080E0E0E0A0A0]
[C0A0A0A0C0A0A060]
[C0A0E080E0A0E040]
[C0A0C0A0E08020E0]
[E0404040A0A0A060]
[A0A0A040A0A0E0E0]
[A040A0A0A0A04040]
[E02080E000000000]

The results are never consistent. Sometimes it runs perfectly and it outputs the data I want, but it doesn't update the screen with the new screen data. Exiting the loop works. Sometimes it does nothing. Just freezes up. And other times it outputs the data but is completely unresponsive. If anyone wants to look through the above and give their insights that would be greatly appreciated. Thanks.

Pages: [1] 2 3 ... 9