Author Topic: What are you working on? :D  (Read 34432 times)

0 Members and 1 Guest are viewing this topic.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #615 on: February 03, 2012, 05:53:09 PM »
Yay, stack overflow! Don't you just looooooooove them?

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 148
Re: What are you working on? :D
« Reply #616 on: February 03, 2012, 08:54:45 PM »
I'm trying to absorb all this and have to do some studying...will respond at length as soon as brain reboots......(Synaptic Stack Overflow).

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #617 on: February 03, 2012, 09:03:14 PM »
Recursion is the best thing evar! :P

It needs a breaking point though :/

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #618 on: February 04, 2012, 08:45:41 AM »
My posts were written in a huge rush and probably not all that clear.  Let me know if you want more explanations on anything :>

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 148
Re: What are you working on? :D
« Reply #619 on: February 04, 2012, 11:33:22 AM »
Quite clear ...and helpful. Still trying to figure some things out. I may have bitten off more than my rusty math education can chew. I haven't needed to use Trigonometry since college, aside from what I've done here the last few months. I've managed to overcome my Stack Overflow problem, but haven't tackled the Send Distance problem yet. Will look at that this weekend maybe.

 If I can get a handle on Aino's math, I might be able to adapt it to my vision. However, there is a bigger problem looming yet, as demonstrated by the attached screenshot of a 3-AI battlefield using Aino's Trig method. You can see what it is. That is not the half of it, either. I've got a lot of work to do.

If I can make some progress worthy of bothering anyone I'll be back...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #620 on: February 04, 2012, 01:29:51 PM »
If you have any question about the Trigonometry or how to use it, ask :P

You can google around too, but I'll be here answering :)

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 148
Re: What are you working on? :D
« Reply #621 on: February 06, 2012, 08:29:15 AM »
Here, I've changed it from random coords to trigonometry(meaning no collision detection needed) :)


I really liked this method of creating the asteroid field without having to check for overlaps. You had quite a few things in there that were new to me, like using periods and semicolons, your array setup, and even putting commands on separate lines (I never knew I could do that!). So it took me a while just to figure out what was going on with those little things. But- there was something about the end result that I didn't like.

Before I get into that, let me expand a bit further on what I wanted in this map and some of the problems I’ve encountered.

A randomized map for two AI opponents would be very simple to create, but I want the map to be expandable to accommodate any number of AI factions. In order to maintain perfect symmetry for the purpose of maximizing fairness, a circle-based battlefield becomes necessary for three or more opponents. This method gives each faction the same starting point relative to asteroid availability. Once the starting factions exceed three, however, placement of starting asteroids relative to stronger/weaker opponents creates an unavoidable bias. This cannot be avoided in a 2-dimensional arena, but this problem is minimized by utilizing a circle-based starting grid.

How to design the map?

I figured the easiest way (for my level of math and programming skill) was to divide a circle by the number of opponents, fill out one portion with an asteroid field, and then copy it repeatedly. This would give each faction the most even playing field possible. (I can think of a better way to do this but just don’t know how).
 
Consider the arena layouts below:









As you can see, the more opponents, the narrower the space becomes for each opponent to “own”. This creates several problems.

If asteroids spawn too close to the center, they will overlap.



If asteroids spawn too close to the edge of  “their” boundaries at the same distance from the center, they will overlap.





What about asteroids of different sizes? The AI opponents may or may not care about the radius of an asteroid since the size is not always indicative of an asteroid’s strength, but for aesthetic purposes I wanted to have various diameters on the map. This creates another variable to consider. Assuming a large asteroid spawns close to the map center or an edge, care must be taken that it does not overlap another faction’s identical asteroid. So, the largest potential asteroid size must be taken into account during the map-seeding process.




As this picture shows, the larger the asteroid, the farther from the map center it can be allowed to spawn.

I also want the number of asteroids to be adjustable. This requires the overall size of the map to be automatically adjusted so that the asteroids do not become too dense or too spread out.

Another design problem entailed connections between side-by-side factions. Ideally, side-by-side sections are connected at several points, not just at the center. It would be extremely simple to create a wheel-spoke-like map where all the asteroids are lined up in a row, meeting at the center. This would not be aesthetically pleasing in my opinion.

So back to your Trigonometry version, Aino. Despite fiddling with the code, I could not wrangle the asteroids sufficiently to create a more dense and random-looking asteroid field. Plus, as I added more asteroids, the field became larger in diameter, but continued in it’s snake-like form. If I could figure out how to control it better, it may turn out to be my only solution, since it does not require an overlap-check.  


Could you try storing the desired send distances to an array in LevelSetup?
EG you could create an array called SendDistanceStored[n] where n refers to the ID of each asteroid.
Then, at the beginning of LevelLogic(), set all the send distances a second time like this: GetAsteroid(n).SendDistance = SendDistanceStored[n]
That should correct the send distance problems. :>

I’m not sure how I could do that. How would I know what send-distances are necessary before the map is randomly-seeded? I’ve been desperately looking at collapsoul’s Web map for some clues or guidance in creating a "preview" map but his techniques are WAAAAY over my head. Waaaaaaaaaaaay waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay over!


You call MapCreation() from inside itself.  This has the potential to create an infinite loop, resulting in a Stack Overflow.

If you instead test the following:

if overlap == true and counter < 50 then

Where counter is initialised with the value 0 prior to calling the function, and then if overlap is equal to true then it increments the counter by one, and then calls the function again.

This means that the code will get a maximum of 50 attempts to do what it wants to do.  If it hasn't managed after 50 attempts, it will abandon the attempt and proceed instead of overflowing.

Yes, I was aware of that problem, but your solution seems unsatisfactory in that abandoning the attempt is not an option. By utilizing another method of repeating only the offending asteroid’s placement rather than the entire map, I was able to achieve a successful seeding in very few extra iterations. Unfortunately, that method later proved unworkable in the real world of asteroid creation (vs. Sprites), and ultimately doomed this entire project, I fear. (see the attached map)

So I experimented a bit in trying to tweak the asteroid field creation to accommodate the above-mentioned criteria. If interested, you can view one interim experiment in the  first map attached below.

I eventually got close enough to my desired intention that I tried to actually seed a map with actual asteroids. This was where I found out that my methods to this point were not going to work, and am now, I think, forced to put this project into the trash-heap of failed attempts (a growing pile!).

Perhaps I’ll finish this with a much more modest goal of a symmetrical, adjustable, 2-AI arena- something I’m sure I can complete. Or, I could just add a generated code printout for pasting into another map. Let me know if you think it would be worth it.

Attached second is my last non-functional map without attempting to create an actual asteroid field. Use it for visual entertainment purposes only. Just left-click to rotate to a new random layout. Some of the shapes get interesting! (Note- both maps are left-clickable) (Oops- attached wrong map before. Download the new one)
« Last Edit: February 06, 2012, 11:39:39 PM by Lost Seedling »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #622 on: February 06, 2012, 01:32:23 PM »
The reason why it's snake shaped is because it goes outwards all the time. I made it add some distance for each asteroid so that they wouldn't touch at all.

Also, you can solve the "outside bounds" asteroid creation by taking away a small fraction from the angle.
Easiest way for me to explain is by showing the code:
AstMap[0]
  • .Angle = math.pi/4 + (math.random()*2-1)*(math.pi/5)[/b]

    Also, hope you know that PI*2 = 360 degrees, and that you're calculating angles with radians.

    Hope that explains it. If I didn't cover what you needed, tell me :)

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 148
Re: What are you working on? :D
« Reply #623 on: February 06, 2012, 05:49:54 PM »
The reason why it's snake shaped is because it goes outwards all the time. I made it add some distance for each asteroid so that they wouldn't touch at all.

Yes, that's what I'm talking about and the point I was making. The very thing that allows it to avoid collision detection prevents me from creating the shape and density that I want. So it's forced outward as the number of asteroids is increased.

Also, you can solve the "outside bounds" asteroid creation by taking away a small fraction from the angle.
Easiest way for me to explain is by showing the code:
AstMap[0]
  • .Angle = math.pi/4 + (math.random()*2-1)*(math.pi/5)[/b]
Yes. That's what I was pointing out as one of the difficulties. If I don't take away enough of the angle, they will be out-of-bounds. Take away too much, and connections between adjoining sections becomes less likely as it moves outward, and the only contact is at the center and the field takes on a wheel-spoke appearance. This is further complicated by the variation in Roid sizes- the larger the potential roid, the greater the fraction you must account for. By using a random-seed, it allows asteroids to occupy the same diameter-ring resulting in a more dense and natural-looking field (at the cost of potential collisions at the boundaries). I think these calculations could be fairly well optimized given time.

Also, hope you know that PI*2 = 360 degrees, and that you're calculating angles with radians.

Hope that explains it. If I didn't cover what you needed, tell me :)

It doesn't matter to me really whether I use radians or degrees at this point as long as it works, or should it?

Thanks for your help.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #624 on: May 24, 2012, 12:17:15 PM »
I'm working on a 3D engine. :>

It doesn't work yet, but it's getting close.

Currently the problem I have is that, although pseudovertices render in the correct places, there are also additional pseudovertices that appear in erroneous positions.

I need to work out why these extra pseudovertices are being created before I can finish the engine.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #625 on: May 27, 2012, 01:57:00 PM »
I'm tired.  No coding today.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: What are you working on? :D
« Reply #626 on: May 27, 2012, 02:47:25 PM »
Aww poor baby :P haha

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #627 on: June 01, 2012, 11:45:38 AM »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #628 on: June 01, 2012, 01:05:11 PM »
Not much work do be doing now, eh? :P

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: What are you working on? :D
« Reply #629 on: June 01, 2012, 01:09:31 PM »
That cat looks exactly like mine, except younger haha