Skip to content

Comments

Local network#8

Open
Volodya-Petrov wants to merge 6 commits intomainfrom
local_network
Open

Local network#8
Volodya-Petrov wants to merge 6 commits intomainfrom
local_network

Conversation

@Volodya-Petrov
Copy link
Owner

No description provided.

Comment on lines 16 to 17
while (random.NextSingle() > computers[current].OS.ProbabilityInfection) do
yield ("Компьютеру " + prev.ToString() + " не удалось заразить компьютер " + current.ToString())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а если вероятность заразить компьютер = 0, мы просто зациклимся? (:

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так там выше проверка что вероятность не равна 0


new (matrix: bool[,], computers:Computer[]) = Network(matrix, computers, System.Random())

member public this.Computers with get() = computers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
member public this.Computers with get() = computers
member public this.Computers = computers

}

member public this.RunInfectionOneStep () =
if counted = false then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не очень понял, зачем это нужно?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если уже заражалась сеть, чтобы повторно не запускать заражение, так ничего не изменится, да и результат изменит (каждый раз одно и тоже будет возвращать)

yield ("Компьютер " + prev.ToString() + " заразил компьютер " + current.ToString())

for i in 0 .. visited.Length - 1 do
if i <> current && visited[i] = false && matrix[current, i] = true then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if i <> current && visited[i] = false && matrix[current, i] = true then
if i <> current && not visited[i] && matrix[current, i] then

Comment on lines 38 to 39
for i in 0 .. result.Length - 1 do
answers[i] |> should equal result[i]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be умеет сравнивать массивы

Comment on lines 43 to 46
let randomizer = Mock<System.Random>()
.Setup(fun x -> <@ x.NextSingle() @>)
.Returns(0.7f)
.Create()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проще передавать функцию рандома, тогда можно будет не мокать, а передать другую функцию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants