HTLLeonding.Utility.Turtle 1.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package HTLLeonding.Utility.Turtle --version 1.0.0                
NuGet\Install-Package HTLLeonding.Utility.Turtle -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HTLLeonding.Utility.Turtle" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HTLLeonding.Utility.Turtle --version 1.0.0                
#r "nuget: HTLLeonding.Utility.Turtle, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HTLLeonding.Utility.Turtle as a Cake Addin
#addin nuget:?package=HTLLeonding.Utility.Turtle&version=1.0.0

// Install HTLLeonding.Utility.Turtle as a Cake Tool
#tool nuget:?package=HTLLeonding.Utility.Turtle&version=1.0.0                

LeoTurtle

Allows students to control a turtle, which can primarily only move forward and turn. This turtle leaves track in the sand, and by looking at this track they can draw simple shapes.

Screenshot

Turtle

The Turtle has the following capabilities:

  • Can move forward a certain distance in meters
    • While moving forward, a line is drawn
  • Can turn in degrees euler
    • Positive values turn right
    • Negative values turn left
  • Can teleport itself to a specific position
    • No line is drawn when teleporting
  • Knows how many meters it has traveled
  • Will stay within the boundaries of the 'beach'

Smart Turtle

The SmartTurtle went to HTL Leonding and thus became the smarter cousin of Turtle with the following additional capabilities:

  • Knows where it is and can report its current position
  • Can look at a certain point on the beach
    • ⇒ turns to face that point automatically

Sample Usage

using LeoTurtle;

const int Length = 80;
const int Width = 40;
const string Basic = "1";
const string Smart = "2";

Console.Write($"Run Basic ({Basic}) or Smart ({Smart}) demo? ");
var choice = Console.ReadLine();
switch (choice)
{
    case Basic:
    {
        Beach.Prepare<Turtle>(WalkPath, 80, 40);
        break;
    }
    case Smart:
    {
        Beach.Prepare<SmartTurtle>(WalkSmartPath, 80, 40);
        break;
    }
    default:
    {
        Console.WriteLine("Unknown option");
        break;
    }
}

return;

static void WalkPath(Turtle turtle)
{
    turtle.Teleport(10, 5);
    turtle.MoveForward(30);
    turtle.Turn(180);
    turtle.MoveForward(15);
    turtle.Turn(-90);
    turtle.MoveForward(15);
    turtle.Turn(-90);
    turtle.MoveForward(15);
    turtle.Turn(180);
    turtle.MoveForward(30);
    
    turtle.Teleport(30, 35);
    turtle.Turn(90);
    turtle.MoveForward(15);
    turtle.Turn(180);
    turtle.MoveForward(15/2D);
    turtle.Turn(-90);
    turtle.MoveForward(30);
    
    turtle.Teleport(50, 35, false);
    turtle.MoveForward(30);
    turtle.Turn(-90);
    turtle.MoveForward(15);
}

static void WalkSmartPath(SmartTurtle turtle)
{
    turtle.Teleport(Length / 2D, Width / 2D);
    
    turtle.LookAt(50, 30);
    turtle.MoveForward(15);
    turtle.Turn(45);
    turtle.MoveForward(5);
    turtle.LookAt(0,0);
    turtle.MoveForward(30);
    
    Console.WriteLine($"Turtle has moved: {turtle.TravelDistanceMeters:F1} meters");
}

I recommend providing the Beach.Prepare<T> call for the students and only letting them work within a method similar to WalkPath (from which they may call other methods, of course).

License

  • The source code is licensed under the MIT License.
  • The turtle images are licensed under CC BY-SA 3.0 and CC BY-SA 4.0.

See LICENSE for more information.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 126 9/26/2024
1.1.3 82 9/26/2024
1.1.2 88 9/26/2024
1.1.1 84 9/26/2024
1.1.0 123 9/5/2024
1.0.1 119 8/22/2024
1.0.0 109 8/22/2024