Output: Requested fix: Move random land generation down, and zoom out to view the WHOLE island. Help indicated via arrow on what im trying to do. Output wanted:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Help with Python Turtle: Need help finalizing turtle drawing and to be fixed. I've included an picture to show what I need for the code to resemble.
1. Lowering top circles to the middle of the canvas to be able to view the WHOLE island.
2. The possibilities of the circles being more irregular when generating.
3. Rivers being bold/thick and cutting through the island on a diagonal. 

Previous question: https://www.bartleby.com/questions-and-answers/help-with-python-turtle-struggling-with-last-few-steps-to-complete-what-i-want-the-following-1.-make/41857550-b5f1-46eb-95e1-dc46d2033b37 

The code:

import turtle
import random
import tkinter as tk
from tkinter import simpledialog
from PIL import Image

# Define colors
ocean = "#000066"
sand = "#ffff66"
grass = "#00cc00"
lake = "#0066ff"
mountain_color = "#808080"  # Gray color for mountains

# Store mountain positions
mountain_positions = []

def draw_irregular_circle(radius, line_color, fill_color, irregularity=10, spikeyness=0.2):
    my_turtle.color(line_color)
    my_turtle.fillcolor(fill_color)
    my_turtle.begin_fill()
    angle = 0
    while angle < 360:
        angle += random.uniform(10, 60)
        if angle > 360:
            angle = 360
        actual_radius = radius + random.uniform(irregularity * spikeyness, irregularity) * random.choice([-1, 1])
        my_turtle.circle(actual_radius, angle - my_turtle.heading())
    my_turtle.end_fill()

def draw_triangle(size, line_color, fill_color):
    my_turtle.color(line_color)
    my_turtle.fillcolor(fill_color)
    my_turtle.begin_fill()
    for _ in range(3):
        my_turtle.forward(size)
        my_turtle.left(120)
    my_turtle.end_fill()

def move_turtle(x, y):
    my_turtle.penup()
    my_turtle.goto(x, y)
    my_turtle.pendown()

def draw_lake():
    x = random.randint(-200, 200)
    y = random.randint(-150, 200)
    move_turtle(x, y)
    draw_irregular_circle(60, lake, lake, 10, 0.3)  # Increased radius and irregularity

def draw_mountain():
    x = random.randint(-200, 200)
    y = random.randint(-150, 200)
    mountain_positions.append((x, y))

def draw_river():
    y = random.randint(-150, 200)
    move_turtle(-300, y)
    my_turtle.setheading(0)
    my_turtle.color(ocean)
    my_turtle.pendown()
    my_turtle.forward(600)
    my_turtle.penup()

def get_user_input():
    root = tk.Tk()
    root.withdraw()
    user_input = simpledialog.askstring("Input", "Enter the number of lakes, mountains, and rivers separated by commas (e.g., 3,2,1):")
    num_lakes, num_mountains, num_rivers = map(int, user_input.split(','))
    root.destroy()
    return num_lakes, num_mountains, num_rivers

# Get user input for number of lakes, mountains, and rivers
num_lakes, num_mountains, num_rivers = get_user_input()

# Initialize screen and turtle
screen = turtle.Screen()
screen.setup(width=1200, height=800)  # Increase the size of the window
screen.bgcolor(ocean)
screen.title("Island Generator")
my_turtle = turtle.Turtle()
my_turtle.pensize(4)
my_turtle.shape("circle")

# Draw the sand and grass areas with irregular borders
draw_irregular_circle(450, sand, sand, 30, 0.4)  # Increased size
move_turtle(0, 120)
draw_irregular_circle(360, grass, grass, 25, 0.4)  # Increased size

# Draw lakes, mountains, and rivers
for _ in range(num_lakes):
    draw_lake()
for _ in range(num_mountains):
    draw_mountain()
for pos in mountain_positions:
    move_turtle(pos[0], pos[1])
    draw_triangle(135, mountain_color, mountain_color)  # Increased size
for _ in range(num_rivers):
    draw_river()

# Save the final result as an image
canvas = screen.getcanvas()
canvas.postscript(file="island.ps")  # Save the postscript file
img = Image.open("island.ps")
img.save("island.png", "png")  # Convert to PNG

turtle.done()

Output:
Requested fix: Move random land generation down, and zoom out to view
the WHOLE island. Help indicated via arrow on what im trying to do.
Output wanted:
Transcribed Image Text:Output: Requested fix: Move random land generation down, and zoom out to view the WHOLE island. Help indicated via arrow on what im trying to do. Output wanted:
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education