正文
count_similar
+=
1
else
:
count_different
+=
1
if
y
>
0
and
(
x
,
y
-
1
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
,
y
-
1
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
<
(
self
.
width
-
1
)
and
y
>
0
and
(
x
+
1
,
y
-
1
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
+
1
,
y
-
1
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
>
0
and
(
x
-
1
,
y
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
-
1
,
y
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
<
(
self
.
width
-
1
)
and
(
x
+
1
,
y
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
+
1
,
y
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
>
0
and
y
<
(
self
.
height
-
1
)
and
(
x
-
1
,
y
+
1
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
-
1
,
y
+
1
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
>
0
and
y
<
(
self
.
height
-
1
)
and
(
x
,
y
+
1
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
,
y
+
1
)]
==
race
:
count_similar
+=
1
else
:
count_different
+=
1
if
x
<
(
self
.
width
-
1
)
and
y
<
(
self
.
height
-
1
)
and
(
x
+
1
,
y
+
1
)
not
in
self
.
empty_houses
:
if
self
.
agents
[(
x
+
1
,
y
+
1
)]
==
race
:
count_similar
+=
1