Artificial Intelligence

you´re really doing something great for us, thanks a lot dude! =)

Thanks… I’m just glad that I can help sometime…


I was gonna spit out another tutorial but my head is aching… Had to help a gal friend paint her room tonight and I got a headache off those god awful fumes… Blah…/

Sorry guys :stuck_out_tongue:

This thread should be striped of spam and made a sticky or something. Really good stuff marz

It will be stripped of spam and moved to the best of kirupa section.

Cool. That will make it much more handy to read and use.

Allright now that he ahs the new forums up… I’ll start posting the Logical AI tutorials up…

Don’t know when… Tongiht? Tomorrow?


Very interesting, Playa :slight_smile:

Just as a side-note, when you compute the distance, you don’t really have to take the square root of the value you have. It takes time, and you could perefctly compare the square of the distance in your AI thinggy afterwards.

//instead of testing
if(distance > 200)
//you could test this to get rid of the Math.sqrt
if(distance² > 40000)

pom :slight_smile:

think u could make a DL file? it’s erm id uno how it works…

This is just teaching you the concept. There wouldn’t be a file to download.

i think these would be alot more useful for me if i knew what the hell most of that meant :-\

lmao… Man… I almost forgot I made these sections… Hell I have the AI notes laying around my room somewhere… Probably shoved in some random computer book… Wouldn’t doubt it…

**** jobs have been making me tired and my lack of mental concentration lately is disturbing.


Don’t have time to read posts except the first one but I know that this is the as of the gods and will come in handy for sure… one day! :slight_smile:

Yeah man… I hope it is… I love this kind of stuff…

playamarz :player:

Ohh Hot ****… I never finished off these tutorials…

I’ve gotta get my laptop up to GNC so I can start pumping these things out… :slight_smile:

Still… here are some tutorials on Basic AI… I will start the others then :wink:

Long overdue… And has been in production for a while now…

I now bring you…!!

:: Logical AI ::

Logical AI is a way of making an Artificial Intelligence for such games like Tic-Tac-Toe or Chess. It gives the computer the most sense of realism that any game can have and… is one of the hardest to program for as well.

You have to put yourself in the control set of a computer. How would you perform if you could only do things by doing tests and then checking out these tests against a set of equations and logarithms?

Now… it gets ten times harder by doing this over the course of time by saying that your AI needs to be able to think into the future to make sure it isn’t doing a bad move for a later reference. But… At the same time, during all of these processes, you still wnat to make the computer beatbale, so ou have him screw up every so often… And if the player doesn’t catch that screw up, then he will most likely lose.

Wow… We are in for a big treat now. But the game I’m doing won’t be tic-tac-toe… nor will it be checkers or chess. The game AI I plan on tlaking about today will be lines. You’ve all probably played lines at least once. It’s that fun game where you have a grid of dots. And you and another friend (imaginary or real :wink: ) would take turns drawing lines, trying to form boxes out of the lines. When you closed off a box, you got to take another turn and vice versa. Person with the most blocks after all lines have been used up WINS!

Now… This seems rather easy… But where do we start… First off… Let’s see what we will need to get this thing going…

We will start this thing off by making ourselves a grid, like such.

Allright. Sorry about the intermission folks… Was getting lightheaded at the office, so I decided to come here and relax for a little bit… **** flu… Anyways… Back to what i was pointing out.

We have ourselves a grid here. Ths is a rather small grid for a game of lines, but it will suffice to give us all the information that we shall need :slight_smile: Using this grid we shall need to find out how many lines we can draw on here to reach the maximum number of lines being drawn.

By the looks of it. We can have a total of 24 lines possible. With a total of 4 x 4 or 16 dots. Now… What if it were a 3 x 3 grid of dotz… How many lines would you have then? We will have to set up an equation for us to figue this out for al possible grid sizes.

How do you get 24 out of a 4 x 4 grid ? Or… How do we get 12 out of a 3 x 3 grid?! Simple…

Number of Lines = rows * ((rows - 1) + (cols - 1));


5 x 5 : Numlines = 5 * ((5 - 1) + (5 - 1)) : 5 * (4 + 4) : 5 * 8 : 40
4 x 4 : Numlines = 4 * ((4 - 1) + (4 - 1)) : 4 * (3 + 3) : 4 * 6 : 24
3 x 3 : Numlines = 3 * ((3 - 1) + (3 - 1)) : 3 * (2 + 2) : 3 * 4 : 12

So… We now have an equation to figure out how many lines a particular grid can hold and this comes to play when we are testing about combos and different line combo testing.

Now… We need to come up with a process of figuring out which one of these lines are open or not open. What better way to do this than an array?! It can hold a certain amount of data and it can be checked in a very fast manner as well!

lineHolder[] = open [1] or not open [0]

lineHolder[0] = 0
lineHolder[1] = 1
lineHolder[2] = 1
lineHolder[3] = 0

So… We have ourselves a nice establised system with how we can check if a line is availible or not and how many lines there are. Let’s get to cracking on how we can tell if placing a line is a good thing or not. :slight_smile:

Let’s go through some of the possibilities of the line game through a series of small images…

Clear field, you can place a line anywhere on the field and not have to worry about it. These lines should be labaled as the possibility of the greatest move, or a good move.

Not so clear of a field, but the list of possibilities are still very good. All moves in this catagory would still rank as a good move, except for the lines located in the same box set as the line. In which case, you are setting yourself closer to a box, which can possibly make that a bad move as well as a good move, so we dub this move as a good move at times…

This is the worst of all cases, the only moves available are a bad move. This is the worst possible move available and should ONLY be done, if it is the last availible move.

This, has the best move possible available to the computer player, this SHOULD be TAKEN at all costs… This will give you a space for yourself and add an extra move for the next turn.

So… Now we have all of the possible moves available to the computer player… Let’s give em each numbers and place them on a chart…

Image 4 can be classified as the best possible move, so we will give this the number 3. Image 3 can be classified as the worst possible move, so we classify this as 0. The first image is a better option than the second image. So it will be set as 2 and the second image as 1.

So… With four options… We will have to check what I would like to call as a combo set. A combo set is a set of 4 dots, that if all were joined by lines… they would form a box. We need to set an equation with the lineHolders that we have to be able to go through all of the combo sets to check and make sure the above number system for possible moves can be reached.

Now… I’d hate to stop this now… But it’s getting late and I need some shut eye… I’ll cover the final bit of this, possibly tomorrow :slight_smile:

Hey, can one of you global mods or admins please make another topic for the replies. It’s harder to read when all of it’s in a different spot. lol, Just a suggestion, you obviously don’t need to listen to me.

Nice Marz. You’re like, really good! lol, How did you guys get all of these people to your forum? Spamming other sites? Sites you never wanted to join, but joined to spam and get banned? lol man, thats fun, I don’t get why people complain, it’s not like they can possibly use all of their storage up anyways. I wanna start doing that! Is it against the terms of service here?

great AI tute :smiley:

nice work. I was really after the pathfinding tut though :frowning: