0

I am writing a model where farmers update profits seasonally and cultivate crops accordingly. In total there will 630 ticks in a year's time period.There are two seasons. First season will take 252 ticks to complete a crop cycle. And other season will take next 378 ticks to complete a crop cycle. For both seasons farmer will calculate her profits. Initially after 252 ticks and then reset some of the variables to start for next season and calculate profits for next 378 ticks. This will go on simultaneously and run for the period of time let's say 10 years or more. Is there anyone who can help in writing the codes.

Below codes are given.

Problem: Ticks mod command will overcalculate or under calculate profits for every season. I want to calculate profits for season 1 from 0 to 252 ticks for season2 from 253 ticks to 630. and again for season1 from 631 to 882 and again for sesson2 till 1260 ticks. adn this will continue.

    breed [farmers farmer]
farmers-own [water irrigation-turn]
to setup
  clear-all
  create-farmers 5
  [ set label who
    set size 2
  ]
   ask farmer 0 [ setxy min-pxcor + 1 0 set irrigation-turn 0]
     ask farmer 1 [ setxy min-pxcor + 1 2 set irrigation-turn 1]
     ask farmer 2 [ setxy min-pxcor + 1 4 set irrigation-turn 2]
     ask farmer 3 [ setxy min-pxcor + 3 0 set irrigation-turn 3]
    ask farmer 4[ setxy min-pxcor + 3 2 set irrigation-turn 4]
    ask farmers [ set label who
     set size 2]
  reset-ticks
end
to go
 irrigate
  update-profits
 tick
end
to irrigate
    ask turtles with [irrigation-turn = (ticks mod count farmers)] 
    [ set color  red]
    ask turtles with [  irrigation-turn != (ticks mod count farmers)] 
    [set color blue]
  end
to update-profits
  if ticks mod 630 = 252 [set-season1profit]
  if ticks mod 630 = 378 [ set-season2profits]
  end
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Sadaf
  • 163
  • 7
  • 4
    The answer to "is there anyone who can help" is yes, but you need to ask a specific question about a specific problem you got stuck on when you tried to write the code yourself. Including the code you wrote in your question will make it easier for us to see where you got stuck and easier to help you. – Seth Tisue Nov 04 '20 at 19:53
  • I have made changes in my question. I hope I am more specific this time. Thanks. – Sadaf Nov 05 '20 at 10:37
  • That helps. I think you might want `ticks mod 630 < 252` rather than `ticks mod 630 = 252`, so that it covers a range? But I feel like I'm just guessing, as I still don't think you've stated your question precisely. – Seth Tisue Nov 06 '20 at 15:46

0 Answers0