2016-04-16 10 views
1

Morgen alleWarum stoppt der Lukenanschlag nach einiger Zeit?

Nach meinem Modell der Bearbeitung durch eine zufällige Spawnrate Zugabe:

to migrate 
    if random-float 100 < random-spawn-rate 
    [create-turtles 2 [rt random-float 360 fd 1]] 
end 

ich das Problem bekommen, dass nach einer Art von Schildkröten (die Boote) aussterben, auch ihre zufälligen Schraffur scheint Aussterben? Ich habe versucht, andere Wege, aber nichts wirklich funktioniert

helfen Bitte mich danke

Voll Code:

breed [fish a-fish] 
breed [boats boat] 
boats-own [profit] 

to setup 
    clear-all 
    ask patches [set pcolor blue] 

    set-default-shape fish "fish" 
    create-fish initial-number-fish 
    [ 
    set color grey 
    set size 1.0 
    setxy random-xcor random-ycor 
    ] 

    set-default-shape boats "boat" 
    create-boats initial-number-boats 
    [ 
    set color black 
    set size 1.5 
    set profit random (1 * profit-per-fish) 
    setxy random-xcor random-ycor 
    ] 
    reset-ticks 
end 

to go 
    if not any? turtles [stop] 
    ask fish 
    [ 
    move 
    fish-reproduce 
    ] 
    ask boats 
    [ 
    move-boats 
    catch-fish 
    death 
    reproduce-boats 
    migrate 
    ] 
    tick 
end 

to move 
    rt random 50 
    lt random 50 
    fd 1 
end 


to fish-reproduce 
    if random-float 100 < fish-growth 
    [hatch 1 [rt random-float 360 fd 1]] 
end 

to move-boats 
    rt random 50 
    lt random 50 
    fd 1 
    set profit profit - 0.1 
end 

to catch-fish 
    let prey one-of fish-here 
    if prey != nobody 
    [ask prey [die] 
    set profit profit + profit-per-fish] 
end 

to death 
    if profit < 0 [die] 
end 

to reproduce-boats 
    if profit > 1 
    [ 
    set profit (profit/2) 
    hatch 1 [rt random-float 360 fd 1]] 
end 


to migrate 
    if random-float 100 < random-spawn-rate 
    [create-turtles 2 [rt random-float 360 fd 1]] 
end 
+0

Hatten Sie immer noch Fische, als die Bootserstellung aufhörte? – JenB

+0

ja es sind immer noch fische, aber das boot popullation stirbt aus – bRam

+0

ich habe es funktioniert danke :) – bRam

Antwort

1

Wenn es keine Boote sind neue Boote zu schlüpfen, dann wird keine weitere Boote sein erstellt. Ihre Luke hängt davon ab, wie viele Boote es gibt.

Wesentlichen für ein Boot:

if profit > 1 
    [ 
    set profit (profit/2) 
    hatch-boat 1 ... 
    ] 

Sie schneiden den Gewinn in der Hälfte für jedes Boot hervorgebracht. Wenn Ihr Gewinn nicht wächst oder gleich bleibt, werden Ihre Boote irgendwann aussterben, da nicht mehr geschlüpft wird.