GetDotted Domains

Viewing Thread:
"Clever Computery People..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sat 03/04/04 at 15:33
Regular
"SOUP!"
Posts: 13,017
i) Can you tell me the difference between a Compiler and an Interpreter language and why it might be an advantage to translate a programme using a compiler rather than a interpreter?

i) Compare the operation of the compiler with that of an interpreter

i) Identify and justify a situation where a compiler might be preferred to an interpreter

i)Identify and justify a situation where a interpreter might be preferred to an compiler

i)Is source code where something is read from and object code part of the code that tells you what to do to a certain 'thing'. If not, what are Source and Object codes

My computing teacher spends more time harassing year nines and drinking coffee than he does teaching us so I need some help please, Ic, Ali, Blue Eagle, anyone?

[S]Posted this in General too but I know some of the top brass dont venture there often.
Wed 07/04/04 at 18:59
Regular
"Jim Jam Jim"
Posts: 5,626
Bonus wrote:
> I suppose there are many different ways of doing things, the way you
> seem to be doing it isn't the way I would do it, but if you get it to
> work, then it doesn't matter how it is done.
>
> I have a decent enough idea of how I would tackle it, but without
> actualy writing it, you can never be sure of how successful it will
> be, just remember that you need to be able to beat the thing, or it
> makes the game useless. You are not striving for a perfect player,
> that defeats the purpose :D

Yeah I know :D. The way we have done it has been dependant on other factors of the program written by another person, so compromises have been made. I have gone through quite a few versions of the A.I as I have thought of other things.

The AI wont be the perfect player. As it does random hits until it hits something and then does what a player would do. It should be perfectly beatable.
Wed 07/04/04 at 17:53
Regular
Posts: 6,492
I suppose there are many different ways of doing things, the way you seem to be doing it isn't the way I would do it, but if you get it to work, then it doesn't matter how it is done.

I have a decent enough idea of how I would tackle it, but without actualy writing it, you can never be sure of how successful it will be, just remember that you need to be able to beat the thing, or it makes the game useless. You are not striving for a perfect player, that defeats the purpose :D
Wed 07/04/04 at 17:17
Regular
"Jim Jam Jim"
Posts: 5,626
Bonus wrote:
> As for searching throught the array for possible places where hits
> could be

Were not doing that, I think you miss understood what I meant by searching the array.

What we have is a array that has all the players ships, AI refers to this when it hits a ship to see what the ship code is for example 5, every ship has a different code. So on the array its using to store misses and hits, the AI will store 5 in this case. Once the ship is destroyed it will then search the array and change all the 5's to 2 and then searches the array again to see whether there are any other codes greater than a 2. So it can set that as the new co-ordinate to check around next.

So for example

000000
665555
000000
007770

The first 6 is hit then the AI goes right and destorys 5. Without doing the above method the AI wouldnt know that there was a ship 6. So with the method it scans that it as hit ship 6 at co-ordinate 0,1 and it will then feed that back into AI and then AI will check to see if it can hit right, it cant so it checks left and destorys 6. Now at this point it will change the 6's to 2's then check to see if anything is greater than 2 in the array in this case there isnt so it checks back to random.

Would be a good idea to do the check that your talking about as a human player would do that sort of thing. Have to see if we could do something like that.
Wed 07/04/04 at 17:09
Regular
Posts: 6,492
Right, I didn't realise you already had something working, the way I suggested was a simple starting point to build on :)

Someone raised an obvious point about searching for l-shaped ships, obviously didn't read the part where I said to keep the horizontal or vertical constant and vary that, if you were to detect a hit, you would make sure that you kept searching along the same axis, seems like an obvious point to me.

As for searching throught the array for possible places where hits could be, it doesn't seem too hard to figure out either, you keep a track of what length of ships you have destroyed, and you search through the board for possible places where it could be, then take at the middle of that line. Use a list to build possibilities, then compare them to see if any overlap, but don't go this far into it until you have a basic pot shot randomness working, that's the biggest thing to remember here, get the basic stuff working, and build on it.
Wed 07/04/04 at 13:14
Regular
"Jim Jam Jim"
Posts: 5,626
Miserableman wrote:
> Bonus wrote:
> Ai for battle ships isn't hard at all, wouldn't even take a couple
> of
> hours.
>
> Take random pot shots at the board, then if you get a hit, try a
> random square up down left or right at the board, simple :D
>
> Once you get a second hit on a ship, what then? I can't help but
> think your algorithm will spend much of its time searching for
> L-shaped ships. AI problems are rarely "simple" :O/

No it wouldnt. How Bonus described it in a simple way and I think I know what he means and we are doing it that way.

Basically you do random x y until you hit a ship. Then once hit a ship you need to go into a routine which checks right, left, up and down in any order. We have a shipSunk value which when set will exit the routine. So for example this situation

000000
012300
000000

where 123 is a ship

If the hit is on the 2 then the routine will go right to hit space 3. Then hit the 0 which will return a miss. Then the routine will go left and hit 1, which will trigger the shipSunk and exit the routine, which will then go back to random.

If its like

00000
00100
00200
00300
00000

If you hit 1 then the routine checks right, which is a miss, then left which is a miss, then up which is a miss then it goes down to hit 2 which is a hit then 3 which then sinks the ship.

The routines are in place and will work, as we have tested the 1st example and it does work. The only problem is that once the ship is sunk then the program does not follow what we want it to do. It is a problem within our AI Class but other Classes could also effect it.

Its a nice challenge to get it working as we havent done anything like this at Uni before as its a more general computing degree.
Wed 07/04/04 at 12:20
Regular
"bing bang bong"
Posts: 3,040
Bonus wrote:
> Ai for battle ships isn't hard at all, wouldn't even take a couple of
> hours.
>
> Take random pot shots at the board, then if you get a hit, try a
> random square up down left or right at the board, simple :D

Once you get a second hit on a ship, what then? I can't help but think your algorithm will spend much of its time searching for L-shaped ships. AI problems are rarely "simple" :O/
Wed 07/04/04 at 09:32
Regular
"Jim Jam Jim"
Posts: 5,626
I applied there, but didnt take it any further as they offered me 18 points but I didnt think I would get it so I didnt bother, plus I didnt fancy moving away from home.

Our Battle ships does do random but then it goes into the right-left, up-down sceniro. So what happens is that the AI gets passed whether the last hit was a true or not and whether the ship was sunk. The AI then works in directions checking whether it can hit there or not. One thing we needed to do was to see whether we had hit another ship as well.

So what we have is an array passed into AI which holds all the ships of the player with unique codes so that when it hits it can transfer the ship code to another array which is the current gameboard. If a ship is sunk it will scan the array and find all the hits with for example 5 in the array, it will then change it to 2 and then scan the array again to see if there are any numbers in the array greater than 2. If there are it will begin the AI routine from that spot, if not it will shot back to the random generater.

This is probably a really complicated way of doing it, but I started doing it without looking in any A.I books at all. The array in which you have suggested is what we do use. We keep an array of all the hits, we actually have it working as in one part it does detect a hit so

H = Hit, M = Miss, S = Ship

0000SSHHSM0000

it will go

0000SSHHHM0000

then

0000SHHHM0000

the problem we are having is that after this first bit the code does not follow the correct path that we want it to. We also think that other parts of the program are being affected, as using JBuilder we can run it perfectly in debug mode but running it normally it will stop working after the first ship is destroyed. So I think our A.I is working in a sense as it should do, but as the code path is not being followed properly it doesnt do what its suppose to.
Wed 07/04/04 at 02:06
Regular
Posts: 6,492
I'm doing at the University Of Abertay up here in sunny Scotland :D

Ai for battle ships isn't hard at all, wouldn't even take a couple of hours.

Take random pot shots at the board, then if you get a hit, try a random square up down left or right at the board, simple :D

Oh, you'll need a 2d array of where the computer has already tried to hit, but if you flag it properly, it should be easy.

Like so,

00000
00200
01200
00100
00000

where 0 = not tried, 1 = tried and mised and 2 = tried and hit.

Just pick a square at random on x (horizontal) and y (vertical) test to see if it has been tried before, if not, try it. That's the way most people play battle ships anyway, just with pot luck. If you get a hit, then try just one along one of the axes and leave the other the same.
Tue 06/04/04 at 18:28
Regular
"Jim Jam Jim"
Posts: 5,626
Bonus wrote:
> You guys should try 3rd year degree level games tech.
>
> We're currently looking at Ray Tracing and collision detection solid
> math, Java application programming, audio programming in Direct Sound
> and agroup project to boot. We're being clever and making a scripted
> strategy game engine :D
>
> Still got time to teach myself how to program on my PS2 linux kit
> when it arrives this week though :D

What Uni are you doing that at?

I wish I could have got in to doing something like this but I messed up my A-Levels and didnt really get on with doing programming in my own time.

At the moment trying to get A.I for Battleships in Java working. Not too hard to do I suppose as I bet you could do it with a few hours :D
Tue 06/04/04 at 17:30
Regular
Posts: 10,364
I'm (hopefully) going to Lincoln Uni to learn games computing.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Many thanks!
You were 100% right - great support!
I've been with Freeola for 14 years...
I've been with Freeola for 14 years now, and in that time you have proven time and time again to be a top-ranking internet service provider and unbeatable hosting service. Thank you.
Anthony

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.