I'm making a battleship programming with scratch, and I'm having a little bit of trouble with the artificial intelligence.
What should each of the AI players do?
I'm planning for the game to have 3 AI players: easy, medium and hard.
Keep in mind...
1) placement of ships
2) locating player ships
Please post your thoughts before reading the next part...
Right now, I have...
Easy) Place ships randomly, but not overlapping.
Medium) Place ships randomly, but make sure they are not bordering vertically or horizontally.
Hard) Place ships like the medium AI.
The problem is, if people know that the two harder AIs don't put ships bordering, but the easy does, then they may use that information to make each of those levels easier, and it may not wind up being easy, medium and hard like it is supposed to be.
Easy) Randomly shoot in places that have not yet been targeted. Shoot around hits until those ships have been sunk
Medium) 50% of the time uses Easy's method, 50% Hard's
Hard) Randomly select a location to target. Make sure that the largest unsunken ship would fit in that spot. If not, repeat. Once largest ship would fit there, precede.
The problem is that the hard script does not narrow down its randomness based on the largest ship not fitting there, because once that ship is destroyed, the next (smaller) one will fit there, so after a few minutes, the script begins to take a long time. Should the script keep track of where it has already tried this pass in a list? Should I make the script hunt for the smaller ships first? (good for 1 shot method (right?!), but bad for 5 shot method right?))
Maybe it would be better to generate a grid of the least possible shots to locate the biggest ship, and this would only need to be run once in the beginning and whenever the biggest ship was sunk, provided that whenever a shot is made, the grid is changed accordingly. Sadly, it would be slightly complicated to have a separate target list from the "EnemyTarget" list, but it might be worth it.
Or maybe it would be better to generate the grid to of the least possible shots to locate the smaller ship... but there would still be some complicated list synchronization...
I'm also not sure the script is even doing what is supposed to properly, so I'm going to post some "code." For those of you unfamiliar with scratch, here is the color code...
and here is the "code" snippet...
Any help I could get over here would be much appreciated.
What do you guys think?
What should each of the AI players do?
I'm planning for the game to have 3 AI players: easy, medium and hard.
Keep in mind...
1) placement of ships
2) locating player ships
Please post your thoughts before reading the next part...
Right now, I have...
Easy) Place ships randomly, but not overlapping.
Medium) Place ships randomly, but make sure they are not bordering vertically or horizontally.
Hard) Place ships like the medium AI.
The problem is, if people know that the two harder AIs don't put ships bordering, but the easy does, then they may use that information to make each of those levels easier, and it may not wind up being easy, medium and hard like it is supposed to be.
Easy) Randomly shoot in places that have not yet been targeted. Shoot around hits until those ships have been sunk
Medium) 50% of the time uses Easy's method, 50% Hard's
Hard) Randomly select a location to target. Make sure that the largest unsunken ship would fit in that spot. If not, repeat. Once largest ship would fit there, precede.
The problem is that the hard script does not narrow down its randomness based on the largest ship not fitting there, because once that ship is destroyed, the next (smaller) one will fit there, so after a few minutes, the script begins to take a long time. Should the script keep track of where it has already tried this pass in a list? Should I make the script hunt for the smaller ships first? (good for 1 shot method (right?!), but bad for 5 shot method right?))
Maybe it would be better to generate a grid of the least possible shots to locate the biggest ship, and this would only need to be run once in the beginning and whenever the biggest ship was sunk, provided that whenever a shot is made, the grid is changed accordingly. Sadly, it would be slightly complicated to have a separate target list from the "EnemyTarget" list, but it might be worth it.
Or maybe it would be better to generate the grid to of the least possible shots to locate the smaller ship... but there would still be some complicated list synchronization...
I'm also not sure the script is even doing what is supposed to properly, so I'm going to post some "code." For those of you unfamiliar with scratch, here is the color code...
and here is the "code" snippet...
Any help I could get over here would be much appreciated.
What do you guys think?