问题描述
我有一张战争游戏地图。它代表这样
。##
#..
#.a
假设'#'是山,'。'是空地,小写字母是军队。军队无法在被山脉包围的地区之间旅行。并且军队只能向上,向下,向左和向右移动。
以上示例显示军队'拥有'该区域,但是当我换成
时。##
#b。
#。a
军队'a'不拥有该地区,因为该地区有军队'b'。
如何检测军队'a'和军队'b'在同一地区?
我使用矩阵来映射该地图。但我仍然没有办法检查'a'和'b'在同一地区。
任何帮助将是apreciate。
谢谢!
我的尝试:
我我试图解决使用矩阵,但它没有给我一个答案。看起来我需要这么多变量来保存那片空地的状态(由谁自己)
I have a map of a war game. It represent like this
.##
#..
#.a
Assuming '#' is mountain, '.' is empty land, and lowercase alphabet is an armies. Armies could not travel between region that enclosed by mountains. And armies can only move up, down, left and right.
Above example shows that armies 'a' own that region, but when I change into
.##
#b.
#.a
Armies 'a' doesn't own that region because there is armies 'b' in that region.
How to detect that armies 'a' and armies 'b' is in same region?
I use matrix to map that map. But I still don't get a way to check 'a' and 'b' is in same region.
Any help will be apreciate.
Thanks!
What I have tried:
I have tried to solve using matrix, but it doesn't give me an answer. Looks like i need so much variable here to save the status of that empty land (own by who)
推荐答案
这篇关于我如何解决这个战争游戏问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!