Changes
1 changed files (+15/-10)
-
-
@@ -377,7 +377,10 @@/-- Run one iteration of the game -/ def doTick : StateM State Unit := do let mut peeps := #[] -- Occupied after this tick let mut occupied : Std.HashSet Nat3 := .ofList [] -- Occupied after half this tick (all coordinates multiplied by 2) let mut occupiedMid : Std.HashSet Nat3 := .ofList [] let origPeeps := let g := (← get).grid (← (← get).peeps.shuffle).partition (fun p ↦
-
@@ -398,7 +401,7 @@ let shopIdx ← rand s.shops.sizep' := { p' with dest := shopIdx } else if p.dest == p.work then -- At work, go to shops if factory worker else go home if h : (← rand 100) == 0 && s.buildings[p.work]!.variant == .factory && !s.shops.isEmpty then if h : s.buildings[p.work]!.variant == .factory && !s.shops.isEmpty && (← rand 100) == 0 then let shopIdx ← rand s.shops.size p' := { p' with dest := shopIdx } else if (← rand 1000) == 0 then
-
@@ -441,18 +444,21 @@ pure ()neighbors := neighbors.qsort (fun a b ↦ a.1 < b.1 || (a.1 == b.1 && a.2 < b.2)) let mut moved := false for (d, i) in neighbors do -- TODO: Handle diagonally crossing roads and other fun stuff (actually not too hard to handle, just check occupancy of midpoints too) let v := u.appd i if s.occupied.contains v || occupied.contains v then continue occupied := occupied.insert v if i < 27 then if s.occupied.contains v || occupied.contains v || occupiedMid.contains (u + v) then continue occupied := occupied.insert v occupiedMid := occupiedMid.insert (u + v) peeps := peeps.push { p with pos := v, dir := some i } else let v':= u.appdk i 2 if s.occupied.contains v' || occupied.contains v' then if s.occupied.contains v || occupied.contains v || occupiedMid.contains (u + v) || s.occupied.contains v' || occupied.contains v' || occupiedMid.contains (v + v') then continue occupied := occupied.insert v occupiedMid := occupiedMid.insert (u + v) occupied := occupied.insert v' occupiedMid := occupiedMid.insert (v + v') peeps := peeps.push { p with pos := v', dir := some i } moved := true break
-
@@ -866,14 +872,14 @@ if (← isMouseButtonPressed MouseButton.left) then dolet mousePos := (← getMouse3D y camera).toNat3Shift (← get) try match start, curAction with | none, 1 | none, 2 => start := some mousePos | _, 3 => addYield mousePos | _, 4 => addTrafficLight mousePos ⟨10, 10, 0⟩ | _, 5 => addTrafficLight mousePos ⟨10, 10, 10⟩ | none, _ => start := some mousePos | some pos', 1 => addRoad pos' mousePos false start := none
-
@@ -883,8 +889,6 @@ start := none| some pos', _ => delete pos' mousePos start := none | _, _ => pure () catch e => IO.println e if (← isMouseButtonPressed MouseButton.right) then do
-
@@ -936,6 +940,7 @@ drawLine3D { posV3 with y := 0 } { stopV3 with y := 0 } Color.Raylean.gray| some pos, _ => let posV3 := pos.toVector3Shift s drawCubeV ((posV3 + mousePosV3) / 2.0) (mousePosV3 - posV3) Color.Raylean.maroon -- TODO bind more numbers for building buildings let actionText := match curAction with | 1 => "Build road"
-