战舰AI约在一定的规则下沉部分 [英] Battleship AI about sinking part under certain rules

查看:175
本文介绍了战舰AI约在一定的规则下沉部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有。如果找到,根据一定的规则一些麻烦,可能code高效的AI对战舰的沉没部分。

I'm having some troubles in finding if, under certain rules, is possible to code an efficient AI for the sinking part of battleship.

规则是:

  • 的最短船的长度甚至可以是1,你得到在刚开始的时候游戏管理员给你的船阵放置
  • 要知道
  • 于不能重叠,但它们可以是相邻的
  • 在游戏经理告诉你,如果你的最后一个镜头是一个打击,沉没或错过。有关船舶的长度没有信息,您hitted /沉没

那么,我不设法前preSS正式沉没船舶的长度。我看不到的方式来理解,一旦我沉没的船舶,它的长度。

Well, what I don't manage to express formally is the length of sunk ships. I can't see the way to understand, once I sunk a ship, the length of it.

我想用密度的方式来估算,其中的基础上仍然在游戏中的船舶长度射门,但没有一个系统来获得一个沉船的长度,我的密度永远不会更聪明。暂时,我只保存每一击的北/南/东/西点,并考虑完成任务后我的筹码是空的。这是非常耗费轮番当然。

I'd like to use a density approach to estimate where to shot based on the length of still in game ships, but without a system to get the length of a sunk ship, my density never gets "smarter". For the time being, I just save North/South/East/West spots of every hit and consider the job done once my stack is empty. That's very turns consuming of course.

我试图澄清什么,我问:假设你有一个二维数组,其中你保持你的笋的跟踪结果以这种方式:

I try to clarify what I'm asking: suppose you have a bidimensional array where you keep trace of your shoots result in this way:

U =未知现货

M =你在X shooted,y和游戏经理告诉你小姐

m = you shooted on x, y and game manager told you "miss"

H =你在X shooted,y和游戏经理告诉你打

h = you shooted on x, y and game manager told you "hit"

S =你在X shooted,y和游戏经理告诉你沉没

s = you shooted on x, y and game manager told you "sunk"

假设板是5 * 5。你有这样的开头:

suppose the board is 5 * 5. At the beginning you have this:

      1 2 3 4
    1 u u u u
    2 u u u u
    3 u u u u
    4 u u u u

假设你拍上2,3和游戏经理告诉你打,现在你有:

suppose you shoot on 2, 3 and game manager tells you "hit", now you have:

      1 2 3 4
    1 u u u u
    2 u u h u
    3 u u u u
    4 u u u u

好了,现在你开始寻找周围的最后一个镜头。无论您使用的密度的方法或一叠N / S / E / W点,从那里你hitted。比方说,你的算法提出了3,3,这一次是小姐:

ok, now you start looking around your last shot. No matter if you use a density approach or a stack of N/S/E/W spots from where you hitted. Let's say your algorithm came up with 3, 3. This time is miss:

      1 2 3 4
    1 u u u u
    2 u u h u
    3 u u m u
    4 u u u u

所以现在你试试2,2,这是一个打击:

so now you try 2, 2, and it's an hit:

      1 2 3 4
    1 u u u u
    2 u h h u
    3 u u m u
    4 u u u u

现在让我们假设2,1和游戏管理员告诉你沉没:

now let's say 2,1 and game manager tell you "sunk":

      1 2 3 4
    1 u u u u
    2 s h h u
    3 u u m u
    4 u u u u

好了:明知船舶可能是相邻的,你怎么知道船的长度你刚才没有沉没在拍摄每一个N / S / E / W位置? 在这种情况下istance你需要拍上2,4和1,3是几乎肯定你沉没,它的轮番消耗。请参阅下面马克·贝西例如:那种情况下,甚至更多圈耗时和放大器;&安培;不确定性比我的。

Well: knowing that ships may be adjacent, how you get to know the length of the ship you've just sunk without shooting on every single N/S/E/W spot? In this case for istance you'd need to shoot on 2,4 and on 1,3 to be almost sure about what you sunk, and it's turns consuming. See Mark Bessey example below: that kind of situations are even more turns consuming && uncertain than mine.

所以,问题很简单:没有什么比这个N / S / E / W耗费时间和放大器更好;&安培;不确定的做法?

So the question is simple: there isn't anything better than this N/S/E/W time consuming && uncertain approach?

希望它澄清了此事。

P.S。 我知道这个问题的,但我看不懂C#语言......刚开始几个月前用java:)

p.s. I'm aware of this question, but I can't read C# language... just started some months ago with java :)

P.S。 2 我知道这个的太(见最后图示),其中,据我了解事情看起来不同的是,他认为最小长度= 2的事实不太一样我总是可以code 2的算法(一个,如果我发现一个分lenght> 1,多了一个轮流消费,如果最小长度= 1),但我不明白他是怎么管理的东西......看起来他只考虑了密度...

p.s. 2 I'm aware of this too (see last illustrations) where as far as I understand the things look quite the same except for the fact that he considers the min length = 2. I could always code 2 algorithms (one if I detect a min lenght > 1, one more "turns consuming" if min length = 1), but I don't get how he manage the thing... looks like he considers only density...

P.S。 3 为什么要关闭?我在寻找一种算法条件下工作......我给了条件,什么算法应该做的。我怎么能澄清呢?我应该如何EX preSS这样的问题? (对不起,问,没有论战意,只是学习)

p.s. 3 Why closed? I'm looking for an algorithm working under conditions... I gave conditions and what the algorithm should do. How can I clarify it? How should I express this kind of question? (sorry for asking, no polemic intended, just learning)

推荐答案

您不能真正有关于任何沉船根据这些规则的长度完美的知识。您可以分配一定的概率,但有没有办法让一个特定的船舶长度。考虑一维版本:

You can't actually have perfect knowledge about the length of any sunken ship under those rules. You can assign some probability, but there's no way to get the length of a particular ship. Consider the one-dimensional version:

0123456789
.XXXXXYY..

,其中X和Y重present不同的船只。如果你开始射击在第4位,并坚持下去吧,你会经过4次,下沉的船。你知道你刚才沉没船舶的不再的超过400位长,但它可能是从1-4空间在实践中任何事情。

Where "X" and "Y" represent different ships. If you start firing at position 4, and keep going right, you'll sink a ship after 4 hits. You know the ship you just sunk is no more than 4 spaces long, but it could be anything from 1-4 spaces in practice.

最有可能的事情是,你打一个单船,但你可以验证通过从第一回击跟踪。在这种情况下,你会得到命中所有的方式回到位置1,然后另一艘船将被报告为沉没。所以,你知道那艘X +船舶Y为一共有7位长。目前只有少数的组合是可以添加最多7,所以有一些信息那里。不幸的是,有许多的加起来7.可能的双船组合

The most likely thing is that you hit a single ship, but you can verify that by back-tracking from the first hit. In this case, you'll get hits all the way back to position 1, and then another ship will be reported as "sunk". So you know that ship X + ship Y are a total of 7 spaces long. There are only a few combinations that can add up to 7, so there's some information there. Unfortunately, there are a number of possible two-ship combos that add up to 7.

这更糟糕的2D板:

 0123456789
A..........
B..........
C..A.......
D..A.......
E..ABCDEE..
F...BCD....
G...BCD....
H....CD....
I.....D....
J..........

如果你从E0拍摄到E9,你会进球6次命中,和一个下沉。如果不检查每个点从D2至D7,你不能确定是否有任何的命中率是在一个垂直的船舶粘成排E.您也不得不检查F2到F6,以确保没有任何船只在另一个方向。

If you shoot from E0 to E9, you'll score 6 hits, and one sunk. Without checking each spot from D2 to D7, you can't be sure whether any of those hits was on a perpendicular ship sticking down into row E. You'd also have to check F2 to F6, to make sure there are no ships in the other direction.

这篇关于战舰AI约在一定的规则下沉部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆