Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

Python Turtle: For my spare time project, I need my code to generate the "land" and "beach" circle areas by random, like a real life island would look like, with plenty of curves and rough edges. I also need the area of the drawing circles to be three times as big, when you previously run the current code below. I have also included an image for what the land should look like.
(link from previous question): https://www.bartleby.com/questions-and-answers/python-how-do-i-do-specifically-do-the-following-to-my-code-1.-have-a-gui-asking-for-the-amount-of-l/9917ac48-57dd-48bb-8522-bf1cb006377d

The code so far:

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

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

# Store mountain positions
mountain_positions = []

def draw_circle(radius, line_color, fill_color):
my_turtle.color(line_color)
my_turtle.fillcolor(fill_color)
my_turtle.begin_fill()
my_turtle.circle(radius)
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(-100, 100)
y = random.randint(-50, 100)
move_turtle(x, y)
draw_circle(40, lake, lake) # Increased radius

def draw_mountain():
x = random.randint(-100, 100)
y = random.randint(-50, 100)
mountain_positions.append((x, y))

def draw_river():
move_turtle(-100, 100)
my_turtle.setheading(0)
my_turtle.color(ocean)
my_turtle.pendown()
my_turtle.forward(200)
my_turtle.penup()

def get_user_input():
root = tk.Tk()
root.withdraw()

num_lakes = simpledialog.askinteger("Input", "How many lakes?", minvalue=1, maxvalue=10)
num_mountains = simpledialog.askinteger("Input", "How many mountains?", minvalue=1, maxvalue=10)
num_rivers = simpledialog.askinteger("Input", "How many rivers?", minvalue=1, maxvalue=10)

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
screen = turtle.Screen()
screen.bgcolor(ocean)
screen.title("Island Generator")

my_turtle = turtle.Turtle()
my_turtle.pensize(4)
my_turtle.shape("circle")

# Draw the sand area
draw_circle(150, sand, sand)

# Draw the grass area
move_turtle(0, 40)
draw_circle(120, grass, grass)

# Draw lakes as bigger random dots
for _ in range(num_lakes):
draw_lake()

# Draw mountains
for _ in range(num_mountains):
draw_mountain()

# Draw mountains as triangles
for pos in mountain_positions:
move_turtle(pos[0], pos[1])
draw_triangle(45, mountain_color, mountain_color) # Increased size

# Draw rivers
for _ in range(num_rivers):
draw_river()

turtle.done()

Transcribed Image Text:example 1: Before: Wanted output: example 2: Any form of randomization generation, y'know?
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education