The Farmer Was Replaced Kaktus-Code — sortieren, dann n²

Neu für 1.0+. Größen 0–9. Sortiertes Quadrat → n² beim Ernten.

Sortierregel (Wiki)

  • Auf Soil. Kostet Kürbisse.
  • `measure()` / `measure(East)`.
  • N/O ≥, S/W ≤.
  • Braun unsortiert, grün sortiert. Auszahlung n².
  • `swap(direction)` tauscht.

Lehrskript: pflanzen → warten → nach NO bubblen → ernten

Bubble Sort ist klar, nicht schnell. Erst warten bis alles erntebereit.

python
def go_to(x, y):
	while get_pos_x() != x:
		if get_pos_x() < x:
			move(East)
		else:
			move(West)
	while get_pos_y() != y:
		if get_pos_y() < y:
			move(North)
		else:
			move(South)

def plant_all():
	size = get_world_size()
	for y in range(size):
		for x in range(size):
			go_to(x, y)
			if get_ground_type() != Grounds.Soil:
				till()
			plant(Entities.Cactus)

def wait_until_grown():
	size = get_world_size()
	ready = False
	while not ready:
		ready = True
		for y in range(size):
			for x in range(size):
				go_to(x, y)
				if get_entity_type() != Entities.Cactus or not can_harvest():
					ready = False

def bubble_sort_once():
	# Push larger sizes toward North/East
	size = get_world_size()
	swapped = False
	for y in range(size):
		for x in range(size):
			go_to(x, y)
			here = measure()
			if x < size - 1:
				east = measure(East)
				if east != None and here > east:
					swap(East)
					swapped = True
					here = measure()
			if y < size - 1:
				north = measure(North)
				if north != None and here > north:
					swap(North)
					swapped = True
	return swapped

clear()
while True:
	plant_all()
	wait_until_grown()
	while bubble_sort_once():
		pass
	go_to(0, 0)
	harvest()

Multi-Drohne / Tempo

  • Bubble auf 32×32 ist langsam. Schnellere Sorten auf GitHub.
  • Keine Shared Memory — Kachel-Besitz klären.
  • Leaderboard ≈ 32 volle n²-Ernten.