The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsI'd say I learned as2.0 throughout the course of a year and a half. My submissions to NG are the early products of my learning. I went through countless bytes though doing experiments. You'll find millions of little .fla's that really don't do anything, but just try out a very small component to a larger game. Now, after as2.0 (I started that in about 06 as well), I've just gotten into as3.0 in the last 3 months, and I already feel very comfortable with it. Actionscript in general was pretty easy to pick up with no other coding experience.
Holy hell man!!! They do NOT expect college course levels! I'm 15 and I know as2.0 and as3.0 very well, am making a game right now with Flex + FlashDevelop, and have a social life! Screw your age kid, that doesn't mean anything. Just try to learn it all yourself, and it is no where near going 0 to 100, since you probably don't even know what's there to learn, and what that 100 is.
Just so you don't cry, try this, and examine it, see what it does:
onClipEvent (enterFrame)
{
if (Key.isDown(Key.LEFT))
{
this._x --;
}
}
Paste that onto a Movieclip.
I dunno...
I don't really like collabs...Putting everyone's stuff together? Nah...I think this challenge this is the best way...
People using AS3 have a WAY bigger of an advantage over me...if only I have as3...the things I could do with the API without having all the other classes being automatically loaded in... :(
Anyways, I definitely think we should start doing rounds of this challenge! This challenge definitely made me a better programmer, since you start noticing exactly how you program!
Maybe round 1 is 100kb, round 2 50kb, round 3 10kb, and finally, 1 kb (or maybe make it two or something...)
But this challenge thing is definitely a good excercise for programmers to keep sharp! Especially since it took me about 45 mins. to make my game!
If anyone wants the raw, messy code for my game, paste this into any AS2 .fla, and run it, and there you go! Have fun playing my game on your computers...
tr = function () {t.text = "Click to start"
t._x = 170
t._y = 189}
createTextField("t",0,5,5,400,22)
t.selectable = false
t.variable = "s"
tr();
G = function () {
d = 2;
t.text = ""
t._x = 5
t._y = 5
s = 0
p.removeMovieClip()
for (i=0;i<q.length;i++) {
q[i].removeMovieClip()
}
createEmptyMovieClip('p',1)
p._x = 200
p._y = 200
q = new Array()
p.moveTo(10,0)
p.beginFill(0xEC7746)
p.lineTo(-10,10)
p.lineTo(-10,-10)
p.endFill()
p6 = Math.PI/3
onEnterFrame = function () {
xm = _xmouse;
ym = _ymouse;
xd = xm-p._x
yd = ym-p._y
p._rotation = 180/Math.PI*Math.atan2(yd,xd)
p._x += (xm-p._x)*0.1
p._y += (ym-p._y)*0.1
if (Math.random()<0.02) {
e = createEmptyMovieClip('e'+d,d)
d++
e.beginFill(0x6AD55E)
e.moveTo(random(6),0)
for (i=0;i<6;i++) {
r = random(6)+4
e.lineTo(Math.cos(p6*i)*r,Math.sin(p6*i)*r)
}
e.endFill()
e.r = Math.PI/180*random(360)
e._x = Math.cos(e.r)*400+200
e._y = Math.sin(e.r)*400+200
_root.q.push(e)
e.onEnterFrame = function () {
with (this) {
_x -= Math.cos(r)
_y -= Math.sin(r)
_rotation++
if (hitTest(_root.p)) {
with(_root){
delete onEnterFrame;
tr();
onMouseDown = function () {
G()
}
p.removeMovieClip()
}
removeMovieClip()
}}}}}
onMouseDown = function () {
b = _root.createEmptyMovieClip('b'+d,d)
b._rotation =p._rotation
b.x = Math.cos(Math.atan2(yd,xd))*6
b.y = Math.sin(Math.atan2(yd,xd))*6
b._x = p._x+b.x*5
b._y = p._y+b.y*5
b.lineStyle(1,0xFF0000)
b.lineTo(5,0)
b.onEnterFrame = function () {
with (this) {
_x += x
_y += y
for (i=0;i<_root.q.length;i++) {
if (hitTest(_root.q[i])) {
_root.q[i].removeMovieClip()
_root.q.splice(i,1)
i--
_root.s+=100
removeMovieClip()
break
}}
if (_x<0||_x>400||_y<0||_y>400) {
removeMovieClip()
}}}
d++
}}
onMouseDown = function () {
G()
}
I hope it's ok to have your game 1.06 kb? I tried ALL that I could to get it that low...couldn't get it any lower...
WAAAIIITTT!!!
CAN THE CONTEST PLEASE NOT BE OVER?! I JUST FOUND THIS THREAD!!!
I SWEAR MY GAME WILL BE WORTH THE WAIT!!!
It seems that we should start programming...but not a lot of programmers have the time because of their other projects...
If there's anyone who would willingly help start, then please come forward.
Btw, I got the pathfinding thing done.
Thanks for taking interest! Some people here are just trying to discourage us...
I got most of the pathfinding engine done last night. As soon as I finish, I'll make a freewebs, and post a link, and then everyone can see it + see source code + I'll give some more people who actually try to do something the freewebs pass so they can start posting too.
Thanks to everyone who have been helpful so far...And I'll try chickendances suggestion. I might PM a few other game developers, see if they want to give this a try.
CL
The reason this collab doesn't have anything too good yet is because it took a very long time to actually start up, and for people to start taking a bit bigger interest...
I see what Keiran is pointing at...though using MC's would be a bit glitchy, and I think it would be better off using vectors. For example, figuring out the distance of the target, and then where it is in relation to it's rotation. If the AI is behind the target, then it approaches. The problem with doing something like that, is that we would only want to do calculations on what to do next when the player is in sight. Not only would it be more realistic, but also less processor load (not that there'll be that much anyways). Because of that, it would be hard to make something accurate and working, though then again, that's one of the things in realism...approximations.
I'm really hoping to get some work done tonight. Should we make a freewebs site just where we can upload the .swf's and also link more people to? If we could get something going for AI on a bigger scale than NG, I think we would get a lot more ideas, and therefore get a lot farther.
CL
Thanks
I do admit I'm not the best Actionscripter on NG, but since nobody else has started any programming collabs, especially none on AI, then I started one. I think we should ignore whose 'running' the collab, and just work together in theory, then move onto programming.
I want to start narrowing down what we discussed before...
If we want to start to build something concrete, then I guess I should give out some specs, but since this is AS based, I guess there aren't really any...
I'll get the basic pathfinding stuff over with this weekend, so we can start on actual AI. I guess everyone should remember, that by starting to do it, we will run into problems+answers. The sooner we start, the better!
I was just thinking...If we want to make our AI look realistic, we should certainly make visibility a factor. But not only that, but the AI should guess where the player is going to be looking. Let's say, that the game just started. The player needs to kill computer, and vice versa.
The AI will assume that the player will go directly to where it spawned. This way, it will know the average place the player should be if he's going to the spawn point. If we use the type of movement system in my paintball game (relative), then it will also be fairly safe to assume, that the player will be facing the direction he's going in most of the time. The AI would then try to avoid the players potential position and field of view, and try to sneak up on him.
How? Well, our pathfinding so far was that it chooses directions to find the fastest way there. We can easily modify it, so that the computer chooses the longest way to a place, or simply away from a place. We can modify both axis too. What we should do, is measure the x and y diffs, then we choose the longest diff to be our opposite axis. So now our AI would be roughly moving around the player. When the longest diff becomes , let's say 3/4 short, we change the axis back to normal pathfinding. This might result it coming out in front of the player, but it would be a lot more realistic than simple following...
That was my simple brainstorming idea I got recently...suggestions?
CL
Well, eventually we could of course develop something for platformers, but since birds eye view AI gives equal conditions to all 4 sides, where as for platformers we need seperate conditions for up and down, and left and right.
Do you people want more explaining+some diagrams, or should we all get down to some programming before we continue...?
Hey! I'm glad you found this! I kept forgetting to mention it to you...
Engines 1, 2, 3? If you're refering to the different concepts we already talked about, then I was actually thinking of a combination of all. So we'd start with simple pathfinding, then move onto wandering, and if it sees the player, it will try to escape or attack, depending on the health and weapon the computer itself has (2 weights needed), then we just keep adding weights and conditions until we get a nice game with nice AI.
I was thinking a birds eye view game (a bit like my paintball) except that the tiles would be a lot smaller, and of course we'd have better AI.
Thanks for helping out!
CL
(send me an e-mail)
Rovere...we need to develop high AI before we can say "Let's make an RPG with high AI". I'm thinking I'll have an example soon...I really hope so. It's been tough getting enough time to work on something solid...
OK.
If nobody out there really wants to join this thread except Rovere, so be it!
This wasn't meant to be the type of collab where we put together a game, it was meant as a discussion of AI in theory, then we can just put in snippets of code, then we each do whatever we want with it...
I'll still post stuff here, but this isn't turning out as I hoped it would...
CL
I'm sorry guys...can't seem to squeeze in enough time to work on this collab. I'll mostly by on weekends, so you might expect something in the next week or so...
If anyone else could share the responsibility of this thread going? I know there are a lot of experienced programmers out there!!!
CL
OK, wtf. First of all, a mod already let this thread go if you even read this whole thread, and second, I don't need stupid and cocky people full of themselves acting as police men/forum mods trying to get this thread locked. If you don't have something better to do or if you don't have a life other than these forums, then I suggest you turn off your computer for once, and get out of your parents basement.
Anywho, about the AI. I don't think it would be wise for us to use hitTesting to see what the enemy does, but rather use distance. I'm in the process of making a SWAT game, where I'll be implementing things I've said here, and other lagg reducing features. Once I'm done it, I'll release bits of code for those who want to see how I did specific parts.
PS: I'm kinda busy all the time, since I've got an MMO game project going on with some other guy, this AI collab, and then the SWAT game+my damn music inspiration which keeps pulling me back to FL Studio...
I see what you mean...
Well, I guess I'll still have to work this through...But I think the key is the weights...we just change those, and eventually, our AI will have developped to the environment. Of course, the more choices we give it, the better and more realistic it will be, but for now I say that the ones I said are going to be good enough...
CL
The part we're doing programming for is the enemies. The player can go wherever he chooses.
The way we can tell where we went wrong, is just keep a var saying which choice was made last, and if it results in death in the next 3 seconds, we decrease the weighting of it. I'm sorry if you don't understand, but I'll try to get an example ready this weekend...
CL
Well, basically yes. We give even notice to all, but as the AI will evolve (through changing the weights of the different choices and random mutation), then it will start to not pay attention to certain factors as much as others, and then choose a different action to take.
So through making choices, and seeing the result of the choice, and then determining what exactly made that choice go wrong, the AI will eventually develop into something for the environment and player style...also to do this better, we could add more sensors which will sense the surrounding tiles, and then we can develop the hiding action a bit better, and add dodging. The computer will learn what to do better by trial an error...
I hope I'm not confusing most of you too much, or keeping some people in the dark...just ask questions...
CL
OK!
Since some good programmers have already given us quite a bit of code to already start working on real AI, why not?
So basically, our first AI should be a simple learning AI. What we do, is create a defined amount of circumstances. Making it simple for this version, we'll give the player and computer these properties at random:
Health:0-2
Knife:0/1 (true/false)
Gun:0/1 (true/false)
Enemies in sight:0-x (only for computer player)
The enemy will have these reactions:
Attack
Wander
Hide
Run
Now that we have the circumstances, we start out with equal weighting of each factor for the computer. To do this, and to explain better, we'll start out with an example. Let's say that the computer player has 1 health, a knife, no gun, and sees 2 enemies. We could create the equation:
currentCircumstance = (health(Wh)+knife(Wk)+gun(Wg))-enemies(W e)
In this example, the currentCircumstance comes out as 0. Now, we create a few if statements (easily replaceable with switch/case):
if (enemies==0) {
choice = wander
else if (currentCircumstance<=0) {
choice = flee
} else if (currentCircumstance>=0&&<2) {
choice = hide
} else if (currentCircumstance>=2) {
choice = attack
}
This basically sets up our engine already. Now, we just set a timer after we make a choice, then then the computer dies, we check if the timer was longer than 3 seconds. If not, then we check which choice we made, and then decrease it's weighting. If it was longer than 3 seconds, then we increase it's weighting. We would only change the weighting by 0.1 or something, so it evolves pretty slowly.
I'm still thinking on how to cook up a quick example...
CL
Thanks guys for atleast helping out!
This collab is not meant to be exactly where we share out actual programs, basically everyone makes their own version, but it's more for people to yes, share code, but also just to brainstorm ideas together...
I'm a bit busy to do with Easter, but will get back to work as soon as possible!
CL
As I keep saying...it's alright! We just need people that can say "yeah, I'll check this as often as I can and see what I can do". If your busy, then your busy. So am I actually...fairly often.
I'm starting the first version of this engine!
That's fine!
Since this isn't actually AS based, more like logic and math, you can still help with ideas!
CL
Don't worry! Experience with actual coding isn't that necessary! All you need is a bit of math, logic, and then yes, basic knowledge of Actionscript, plus we need everyone we can get right now! I'm probably going to make a freewebs site to put all the prototypes on.
Sorry for late reply! I suddenly got really busy (not a good thing for someone who's leading a collab, I know...), but I'm trying to get on as much as possible!
Since no more people are volunteering, lets start with something now:
--------------------------PROTOTYPE 1--------------------------
Goal: Make an easy editable tile engine, using a 2D array, and programming a pathfinding algorithm for the computer, where we give the computer certain tile coordinates, and it can navigate to there fairly easily.
Rules: To simplify things up, no dead ends/corners. This type of AI will be good enough for any game, and we can concentrate on actual pathfinding later.
What we need to figure out: How to tell the computer when/how to change direction.
My thinking:
What I'm thinking right now, is we make a 2D array for tiles 50x50 pixels big. We home in on which tile the computer is on by:
tileArrayX = Math.round((this._x+25)/50)
tileArrayY = Math.round((this._y+25)/50)
or we can make this more dynamic by changing the tile width values to variables...
tileArrayX = Math.round((this._x+tile.width/2)/tile.w idth)
tileArrayY = Math.round((this._y+tile.height/2)/tile.
height)
So now we have the position of the computer according to the array. We check these coordinates with the target coordinates, and then see what way we SHOULD go. We would give priority to farthest axis, so basically if ydif>xdif we go on the y axis first. If the priority axis should be blocked, we take the other axis. Now, this is actually a pretty simple part. We just check this same thing whenever we find ourselves in an intersection, IOW with 3+ possible ways to go. We should just have a simple var that we keep which way we are currently traveling, and then we check when the other axis opens up.
Problem! :
Now, this particular method won't work if there are very long stretches of corridors, because if we always give priority to the farthest axis, then the computer could end up going back and forth over long stretches. This is actually where other people from the collab come in...or I could start brainstorming for a while, but then there would be no purpose for this collab...
People, you don't need to be pro with AS 2...you just need ideas! If anyone has an idea how to solve the problem above, please contribute ideas! I think I have an idea, but I'll try to test it out before posting...(my idea is giving priority to shortest axis which still might clog it up...but until testing, I'm not going to be sure!)
Please people! Lets get some programmers collabing together finally!
CL
Alright! And thanks guys!
Basically, fps isn't that important right now, though I think 40 fps would be nice to work with.
What we're doing is creating pathfinding and then chasing AI. For the pathfinding, we would first be completely working with only AI trying to get to one point. How I would see it, is we give the computer a tile to get to, and then it starts off going the best way (If ydif>xdif, it will first choose to go on the y-axis if it's possible. Then, we check it's position to the map grid (2D array of tile positions), and whenever it hits an intersection (3+ possible ways), then we do the previous checks of xdif and ydif and choose a new way to go!
Of course, this specific real-time AI would only work on tile based games, and we would not be allowed to make U-turns anywhere in the map, but I think it's going to be a very good start, and enough to start conducting further experiments with real AI...
The complete goal of this collab is to create a game where the user and computer are thrown inside a little maze. The players objective is to get to a purple "portal", and the computers job is to catch the player before it gets there...After each round, the computer "learns" of the players habits, and then will try to be at a place ahead of time. Now, this would only work properly if we make the computer invisible to the player until it comes in the direct line of sight...
I hope this filled some of you guys in on our specific goals.
Is anyone ready to start working with me? Basically we would be either dividing up work for games, or we would just be each creating a different version of the same thing, see what we come up with, and then swap ideas, fix it up, and then we all agree on one version, we make it, and if it's a game, we post it on newgrounds.
Thanks!!!
I'm not sure that a lot of programmers on here pay attention to the word "collab", which might be a problem with this one...Anyone have any ideas on how to get more programmers?
I don't want to get down to business if I don't have at least a few programmers around here, otherwise I guess this collab might die...C'MON YOU GUYS!!!
I just want people to say at least "I'm listening", so it would be worth helping each other out, and actually posting stuff. I've got ideas I want to share, but they alone aren't enough to produce the best AI we can get!!!
Please people!
CL
I'm in! PM me to fill me in on more details, I'll try to get a preliminary level engine up, and I already have a bit of XML socket experience/old prototypes on my computer which I can use... :) !
Anyhow, considering the collab:
I see that there isn't a lot of interest...I just hope that the programmers out there will see this!
For doing the tracking system, we could create a 2D array where we store the tile info. Whenever the player is in a position with more than 2 options of where to go, then the computer records which way he went. This way, we record does the player most likely take left or right turns. With this info, the computer can figure out where the player will most likely be based on this info+the players starting point.
I see...but I just hope that the admins will give me a chance with this one, since I'm a programmer, I don't spend lots of time on forums because I'm working to make Newgrounds better games! Anyways, I think that this collab is a good idea, and that there should be more programmer collabs.