• Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About Anidem

  • Rank
  1. Alright so I was reading up on Craig Reynolds agents. He talks about a few things, and I already have the pathfinding system. But I wanted to know how to go about developing the generic surface protocol. He writes that his agents pass an x,y to the protocol and it returns the closest x,y to the surface. I need something like that so when my agents pathfind, and are in formations (they repel each other) that they don't run into the walls.
  2. A* Troubleshooting

    Wow, thanks Timkin. Just implemented it, works great! Let me ask you this though, will A* always find a path that exists (regardless of complexity like mazes)? I think the problem is, I havne't updated the subnodes, but I have yet to devise a way to do that.
  3. A* Troubleshooting

    Ok, yes, I had made that mistake. But it still doesn't completely find all paths. For some reason, not all objects placed on the open list are explored. Perhaps A* at it's most simplist doesn't find complex paths that do exist?
  4. A* Troubleshooting

    Quote:Original post by Timkin My VB is pretty much nonexistent, but if I read this correctly, you've first assigned tmpNode to tmpNode2 and then asked if they have different path costs from the root node. If that's what you've done, then this will cause you problems. Cheers, Timkin the thing is, I just set them equal so that their x, and y are the same then I update them... 'Update the parents tmpNode2.parentx = curNode.x tmpNode2.parenty = curNode.y 'Update the heuristics tmpNode2.g = curNode.g + 10 tmpNode2.f = tmpNode.g + tmpNode.h Then I check to see if they have a lower cost. Now I'm not totally sure that that makes a whole lot of a difference. Because when I debug the lower f-cost decision never runs. So how can I handle this different? [Edit] I may have found the error. But it might have just been a typo when I wrote this message. In this code what Timkim said was right. I'm effectivly comparing the same two things. But if I update the code to tmpNode2.g = curNode.g + 10 tmpNode2.f = tmpNode2.g + tmpNode2.h It might work. I'll have to go home and test it. Although I'm still not sure if I'm supposed to be comparing the f or g values. And this is only for the open list. Would I ever take something off the closed list and put it back on the open? [Edited by - Anidem on March 27, 2006 9:43:02 AM]
  5. Ok, so I'm making a pathfinder in VB. I'm having trouble finding complex paths (that do exist) and getting the shortest path to them (sometimes my pathfinder will make unnecessary trips). I think the problem is in the code where I search in four directions. Maybe I didn't understand what to do correctly, but here is what I am doing... 'Move in the direction we seek tmpNode.x = curNode.x - 1 tmpNode.y = curNode.y 'Determine if this tile is walkable If lngMap(tmpNode.x, tmpNode.y) = 0 Then 'Determine if this node is on the closed list If Not clsClosed.MemberOf(tmpNode) Then If Not clsOpen.MemberOf(tmpNode) Then 'Update the parents tmpNode.parentx = curNode.x tmpNode.parenty = curNode.y 'Update the heuristics tmpNode.g = curNode.g + 10 tmpNode.h = (Abs(tmpNode.x - nGoal.x) + Abs(tmpNode.y - nGoal.y)) * 10 tmpNode.f = tmpNode.g + tmpNode.h 'Add the node to the open list clsOpen.Add tmpNode Else 'Set them equal tmpNode2 = tmpNode 'Update the parents tmpNode2.parentx = curNode.x tmpNode2.parenty = curNode.y 'Update the heuristics tmpNode2.g = curNode.g + 10 tmpNode2.f = tmpNode.g + tmpNode.h 'Determine if this is a better route If tmpNode2.g < clsOpen.GetData(tmpNode).g Then clsOpen.SetData tmpNode2, tmpNode 'Sort the list to make up for the changes clsOpen.Sort End If End If End If End If I think the problem comes when I check if a node lying on a different path has a lower g value then the one already on the open list. But I've seen many articles using many different ways of accomplishing this. I don't want anything fancy yet, just to make sure that it finds any path that exists. Maybe someone could just tell me in pseudocode what to do in the direction search. By the way thanks!
  6. Writing formulas

    Actually, you can write equations in word. Not sure of the quality though. To do this, goto Insert->Object and look for Microsoft Equation. You might have to install it from the CD but it's there and free.
  7. Ok, so far I have a little grapher. It graphs functions nicely, but a few things come up about handling certain functions. Let me give a couple of cases: 1) y=log(x) I couldn't figure out how to stop getting an error for all x <= 0. So I just bypassed the error, but now it graphs a line y=0 for all x <= 0 when it shouldn't graph anything at all. So my question is how (I use vb6 btw, if that matters) can I bypass or determine and ignore the log of x, x <= 0? By the way, this really is log independant, its for any functions that have invalid values for certain x. 2) Asymptote Detection y=1/x Ok, so any function that has an asymptote will have it drawn when you connect the dots from the last iteration of the function to the current iteration. Just like on the old TI calculators. I have a poorly designed method, if the y value of the last iteration of the function has a different sign and its more than a certain number of pixels away from the current dot, then don't draw that line. Very crude method, and can cause problems later on, so is there a better way? I can't think of any more at the moment, but this will give me a start. Thanks! [Edited by - Anidem on February 12, 2006 8:19:28 PM]
  8. Realistic Rope Physics

    I'm beginning to wonder what I gotten myself into. A lot of this is new to me, and unfortunatly, I don't have the luxury of high level math. I'm getting there though, I started pre-cal this semester. On another note, the project really is interesting. It seems like a inadvertant GA, it tries all these different types of shapes until eventually is straightens up and a little part of the tail waves as it defies the gravity of the simulation.
  9. Realistic Rope Physics

    ozmic66, I am using 5 iterations as you suggested. Here the code I use (in vb): [source language="vb"] Option Explicit Private Type Location sngX As Double sngY As Double End Type Dim String1(99) As Location Dim String2(99) As Location Dim a As Integer Private Sub Form_Load() Dim i As Integer For i = 0 To UBound(String1) 'Initialize the starting positions String1(i).sngX = 50 '+ i * 6 String1(i).sngY = i + 50 Next i End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) String1(0).sngX = X String1(0).sngY = Y End Sub Private Sub Timer_Timer() Dim Vector1 As Location Dim Magnitude1 As Double Dim Extension1 As Double Dim Vector2 As Location Dim Magnitude2 As Double Dim Extension2 As Double Dim xv As Double Dim yv As Double Dim i As Integer Dim dx As Double Dim dy As Double Dim d1 As Double Dim d2 As Double Dim b As Integer For b = 0 To 4 For i = 1 To UBound(String1) Vector1.sngX = String1(i - 1).sngX - String1(i).sngX Vector1.sngY = String1(i - 1).sngY - String1(i).sngY Magnitude1 = VectorLenght(Vector1.sngX, Vector1.sngY) + 0.001 Extension1 = Magnitude1 - 1 'Magnitude minus normal lenght If i &lt;&gt; UBound(String1) Then Vector2.sngX = String1(i + 1).sngX - String1(i).sngX Vector2.sngY = String1(i + 1).sngY - String1(i).sngY Magnitude2 = VectorLenght(Vector2.sngX, Vector2.sngY) + 0.001 Extension2 = Magnitude2 - 1 'Magnitude minus normal lenght xv = (Vector1.sngX / Magnitude1 * Extension1) + (Vector2.sngX / Magnitude2 * Extension2) yv = (Vector1.sngY / Magnitude1 * Extension1) + (Vector2.sngY / Magnitude2 * Extension2) + 1 'Gravity Else xv = (Vector1.sngX / Magnitude1 * Extension1) yv = (Vector1.sngX / Magnitude1 * Extension1) + 1 'Gravity End If If i &gt; 0 Then dx = (String1(i - 1).sngX - String1(i).sngX) dy = (String1(i - 1).sngY - String1(i).sngY) d1 = Sqr(VectorLenght(dx, dy)) d2 = 0.5 * (d1 - 1) / d1 'r=the distance between the two points dx = dx * d2 dy = dy * d2 String1(i).sngX = String1(i).sngX + dx + (xv * 0.1) String1(i - 1).sngX = String1(i - 1).sngX - dx + (xv * 0.1) String1(i).sngY = String1(i).sngY + dy + (yv * 0.1) String1(i - 1).sngY = String1(i - 1).sngY - dy + (yv * 0.1) End If Next i Next b Cls Me.Line (250, 150)-(300, 150) Me.Line (120, 100)-(195, 100) For i = 0 To UBound(String1) 'Debug feature Me.CurrentX = String1(i).sngX Me.CurrentY = String1(i).sngY 'Me.Print String1(i).sngX, String1(i).sngY 'Draw the pixel Me.PSet (String1(i).sngX, String1(i).sngY), vbRed Next i For i = 0 To UBound(String1) - 1 'Connect the pixels Me.Line (String1(i).sngX, String1(i).sngY)-(String1(i + 1).sngX, String1(i + 1).sngY), vbRed Next i End Sub Private Function VectorLenght(ByVal sngX As Double, ByVal sngY As Double) 'Calculate the vector lenght VectorLenght = sngX ^ 2 + sngY ^ 2 End Function Maybe I'm not doing something right, my code is pretty messy from that other link. Or maybe I misunderstood the implementation of verlet.
  10. Realistic Rope Physics

    ozmic66, I like the verlet integration. It created interesting patterns (espacially when expiermenting with radii<1) that would act like those single cell organisms when moving. That is, when the tail whipped and the body was pretty straight, it would move upward...even though I had gravity in my simulation. However, it still was the spring thing, and the rope would get bigger and smaller throughout the simulation. So I am forced to try ury's methods. Thanks though!
  11. Realistic Rope Physics

    Hey everyone, I was programming a rope simulation for fun with this resource The problem with this implementation of a rope is that it uses the concept of springs between each point on the rope. Making a fairly unrealistic rope when some points are farther away than others. I would like my rope to be pixel by pixel, not points and lines. So one point in my rope would never be more than one pixel away from its neighboring pixels. And if at all possible with gravity and mass that affect the movement. For example if a rope is hanging a point and I disturb the position of the rope, it will swing back and forth realistically. Anyone have any resources on this? Thanks [Edited by - Anidem on February 5, 2006 12:39:53 PM]
  12. Autonomous Entities

    Cool! Thanks!
  13. Autonomous Entities

    Ok, so I'm having a little trouble with this because there are from what I see multiple equations. First being A @ B = AX*BX + AY*BY (let @ be the dot product). So that is the dot product, but from that the following equation can be satisfied A @ B = |A| * |B| * Cos(Theta). I can further derive it to this form: (AX*BX + AY*BY) <-The dot product ArcCos -------------- = Theta (The angle difference) |A| * |B| <-The multiplied lenght of vector a & b So it got screwed up, but so far is that right? To the angle take the ArcCosine of the dot product divided by the multiplied lenght of vector a and b? Then after I find the angle, I find if I should turn left of right with help from the cross product? Then I just turn left or right until I reach that angle? I'm also having trouble with the cross product, from what I understand it is A X B = AX*BX - AY*BY, however, do I use that or this equation A X B = |A| * |B| * Sin(Theta), to determine to turn left or right? [Edited by - Anidem on June 5, 2005 1:53:09 PM]
  14. Ok, I'm a little stuck creating my autonomous entity, in visual basic. It's nothing special really, I just want it to avoid collision better. Right now, my algorithm is flawed, in that it allows the agent to cross over a boundry too often. I really just need theory, my current algoritm checks with an invisable line (probe) from the outside radius of the agent to the agent's velocity*25 (a number I choose because it estimates well). It does this in a loop, and checks each pixel in front of the agent. if there is a collision between this line and a boundry, the velocity is lowered and the heading is changed (+15 degrees). This isn't producing the results I wanted, perhaps it has something to do with timing the braking properly, and/or changing the heading in the right direction /w the right ammount of change. Or maybe I shouldn't check each pixel, and there is a better method? One last thing, is there a specific formula for determining the + or - number of degrees from an object with a position and heading (x,y @ heading) and a point (x,y). Basically for turning to a goal. Thanks!
  15. 3D - 2D

    Ok so I want to play around with creating my own simple 3D engine, not using DX or anything like that. I searched google and yahoo and didn't find anything (probably didn't word it right). Anyway, all I want to be able to do is create an object (cube for now) and render in on a 2d screen and rotate the perspective so I can view how real it looks, instead of it being straight on. And for this, I would approciate if someone could give me a link, or explain 3D to 2D equations. Thanks!