diff --git a/.gitignore b/.gitignore index fc0ef0d5d..7ba7b4c25 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ astro/.astro/types.d.ts .vercel */node_modules astro/.env +.env diff --git a/art/eca-henry/eca.js b/art/eca-henry/eca.js index be29b6eb3..9f5dcea34 100644 --- a/art/eca-henry/eca.js +++ b/art/eca-henry/eca.js @@ -1,4 +1,4 @@ -const t = new Turtle() +const t = createTurtle(); const w = 50 @@ -68,4 +68,7 @@ for (let gen = 0; gen < w * 2; gen++) { drawGen(allGens[gen + 1], -gen) } -drawTurtles([t]) +t.scale(110/t.height); +t.translate([125/2, 125/2], t.cc); + +drawTurtles([t]); diff --git a/art/hilbert_golf-henry/index.js b/art/hilbert_golf-henry/index.js index 2ee35067b..5724ea228 100644 --- a/art/hilbert_golf-henry/index.js +++ b/art/hilbert_golf-henry/index.js @@ -1,8 +1,11 @@ -let t = new Turtle([7, -6]) +let t = createTurtle([7, -7]) for (let i of eval( `'A'` + `.replace(/[AB]/g,c=>c=='A'?'-BF+AFA+FB-':'+AF-BFB-FA+')`.repeat(5) )) try { eval(i == 'F' ? `t.forward(-0.1)` : `t.left(${i}87)`) } catch {} + +t.scale(125/t.width); +t.translate([125/2, 125/2], t.cc); drawTurtles([t]) diff --git a/art/landscape-henry/index.js b/art/landscape-henry/index.js index 25c849828..4c6764435 100644 --- a/art/landscape-henry/index.js +++ b/art/landscape-henry/index.js @@ -1,5 +1,5 @@ -const t = new Turtle() -drawTurtles([t]) +const t = createTurtle(); + const time = 106 const resX = 5.16 @@ -84,3 +84,9 @@ function drawLandscape() { } drawLandscape() + +t.scale(125/t.width); +t.translate([125/2, 0], t.cb); + +drawTurtles([t]) + diff --git a/art/raymarching-henry/raymarch.js b/art/raymarching-henry/raymarch.js index 2f6f22069..7d42c664c 100644 --- a/art/raymarching-henry/raymarch.js +++ b/art/raymarching-henry/raymarch.js @@ -3,7 +3,7 @@ const screenHeight = 2 const dx = 0.01 const dy = 0.01 -const t = new Turtle() +const t = createTurtle() class Vec3 { constructor(x, y, z) { diff --git a/art/roots-kai/index.js b/art/roots-kai/index.js index 9b0317084..3d208a7ca 100644 --- a/art/roots-kai/index.js +++ b/art/roots-kai/index.js @@ -3,7 +3,7 @@ const WIDTH = 10 const HEIGHT = 20 -const t = new Turtle([WIDTH / 2, 0]) +const t = createTurtle([WIDTH / 2, 0]) t.right(90) // Manage array of turtles that need to be drawn @@ -88,7 +88,7 @@ function thicken(turtle, startingTime) { const deltaX = rightPoint[0] - leftPoint[0] const deltaY = rightPoint[1] - leftPoint[1] - const ring = new Turtle(leftPoint) + const ring = createTurtle(leftPoint) .setAngle((Math.atan2(deltaY, deltaX) / Math.PI) * 180) .forward(Math.sqrt(deltaX * deltaX + deltaY * deltaY)) // Straight line from left to right .resample(0.01) // Resample so we can modulate individual points @@ -162,7 +162,7 @@ function makeBranch(turtle, length, startingT) { pt[0] += parentThickness * Math.cos(curAngleRad - a) pt[1] += parentThickness * Math.sin(curAngleRad - a) - const newBranch = new Turtle(pt) + const newBranch = createTurtle(pt) newBranch.setAngle(curAngleDeg) newBranch.right(a) @@ -180,5 +180,11 @@ function makeBranch(turtle, length, startingT) { // Make initial branch makeBranch(t, 0.1, 0) +// Center piece +const final = createTurtle(); +turtles.forEach(t => final.join(t)); +final.scale(115/final.height) +final.translate([125/2, 125/2], final.cc) + // Draw turtles array -drawTurtles([turtles]) +drawTurtles([ final ]) diff --git a/art/tree-leo/index.js b/art/tree-leo/index.js index d9af821f4..816d46aed 100644 --- a/art/tree-leo/index.js +++ b/art/tree-leo/index.js @@ -84,4 +84,8 @@ for (let i = 0; i < 100000; i++) { randomWalk.rotate(randInRange(-5, 5)).translate([-0.1, -0.6]) -drawTurtles([trunk, randomWalk]) +const final = [trunk, randomWalk].reduce((acc, cur) => acc.join(cur), createTurtle()); +final.scale(110/final.height); +final.translate([125/2, 0], final.cb); + +drawTurtles([final]); diff --git a/astro/src/components/Toolbar.tsx b/astro/src/components/Toolbar.tsx index 5fd3b3796..fa8cc1168 100644 --- a/astro/src/components/Toolbar.tsx +++ b/astro/src/components/Toolbar.tsx @@ -186,11 +186,12 @@ function DownloadSVG() { const paths = turtles.map(turtleToPath) const svg = ` - + ${paths.join('\n')} ` @@ -239,11 +240,12 @@ function DownloadPNG() { const paths = turtles.map(turtleToPath) const svg = ` - + ${paths.join('\n')} ` diff --git a/astro/src/components/landing/ThreeDModel.astro b/astro/src/components/landing/ThreeDModel.astro index 3dd0ee04b..c60c198dc 100644 --- a/astro/src/components/landing/ThreeDModel.astro +++ b/astro/src/components/landing/ThreeDModel.astro @@ -20,7 +20,6 @@ import { MTLLoader } from 'three/addons/loaders/MTLLoader.js' import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' import * as THREE from 'three' - import { turtles } from '../../lib/paths.js' import { runTextReturnTurtles } from '../../lib/runTextReturnTurtles.ts' window.onload = () => { diff --git a/astro/src/lib/paths.js b/astro/src/lib/paths.js deleted file mode 100644 index 92d933a0d..000000000 --- a/astro/src/lib/paths.js +++ /dev/null @@ -1,1132 +0,0 @@ -let turtles = [ - { - drawing: true, - position: [23.29042314884119, 107.85884615966864], - angle: 7826, - path: [ - [ - [62.96964708933757, 62.5061900725191], - [62.952194682900284, 63.50603776767549], - [60.9534130288621, 63.436238774270485], - [61.11042089759093, 60.44035017000677], - [65.10067709863023, 60.719376064983265], - [64.66489838489193, 65.70034955544199], - [58.69776701268229, 65.07317877583608], - [59.550852416518325, 58.125355714346824], - [67.47299696645088, 59.23874052202735], - [66.06508678108881, 68.1279355873836], - [56.21700925096674, 66.3914538107143], - [58.31590820010872, 55.593554792789995], - [70.0536794089144, 58.08849508260307], - [67.12931570244419, 70.75530592481113], - [53.545175534580224, 67.3683993864158], - [57.42746121111803, 52.87951199207978], - [72.80764834613113, 57.289709685151756], - [67.8373293658446, 73.54689053652336], - [50.71831207253183, 67.98458463777436], - [56.90410700721782, 50.01973170138734], - [75.69795942293601, 56.86013456790069], - [68.17223248248465, 76.4653235243419], - [47.774187682015324, 68.22397846919185], - [56.761003637268544, 47.05236683978569], - [78.68609462069102, 56.81404627360476], - [68.1206380771736, 79.47174094952103], - [44.751992873395196, 68.07409113300514], - [57.00973636636293, 44.01691497991919], - [81.73226896641293, 57.16211873792404], - [67.67278997926915, 82.52609024496653], - [41.69202786573595, 67.52609024496658], - [57.65820818794768, 40.953903923201125], - [84.79574726495333, 57.91132037866365], - [66.82265910945755, 85.58744912086271], - [38.63538164258614, 66.57489040285733], - [58.71055691487247, 37.904568852742415], - [87.83516871237069, 59.06483793527128], - [65.56801285574495, 88.61435180702117], - [35.62360421868958, 65.21921574464605], - [60.167099469633015, 34.91052324782401], - [90.80887719439221, 60.622027635285484], - [63.91045700578161, 91.56512042441932], - [32.69837433573119, 63.4616349573471], - [62.02430381841825, 32.01342578772242], - [93.67525503331892, 62.57839408791828], - [61.85544987992441, 94.39819924131302], - [29.901164838810306, 61.30856842573529], - [64.27478881491147, 29.25464550279802], - [96.3930579201371, 64.92559712571256], - [59.41228848922131, 97.07248954624745], - [27.272908004894187, 58.77026739029866], - [66.90735203919994, 26.674927446757238], - [98.92174875613458, 67.65148663430645], - [56.594066723628, 99.54768286136496], - [24.853663099834396, 55.86076516511785], - [69.90702553572879, 24.31406116581011], - [101.22182813009097, 70.74016522889221], - [53.417605757202125, 101.78459022474925], - [22.682288431676287, 52.59780064767651], - [73.25515917310085, 22.210554227983202], - [103.25515917310109, 74.17207845504939], - [49.903357037598184, 103.74546529007634], - [20.796120144873147, 49.00271453282278], - [76.92953116874034, 20.401313049231362], - [104.98528456324142, 77.92413201237798], - [46.07527840585894, 105.39431902552292], - [19.23065996285563, 45.100318821111486], - [80.90448514416883, 18.92133321232945], - [106.37773349645084, 81.969835322871], - [41.96068406814399, 106.6972238414969], - [18.01927403534587, 40.9187403864838], - [85.15109290289749, 17.80340142002604], - [107.4003164978945, 86.27947059327684], - [37.5900693125929, 107.62260503803662], - [17.19290498213474, 36.489239538601105], - [89.63734195381474, 17.077811155911604], - [108.02340601938911, 90.82028635288742], - [32.9969110309262, 108.14151753736593], - [16.77979914713983, 31.84600468012932], - [94.32834663950523, 16.772094045381998], - [108.22020085286016, 95.55671428635856], - [28.217445264654142, 108.227905954618], - [16.805250985927774, 27.025924317809377], - [99.18658157215735, 16.910768815180873], - [107.96697248663939, 100.45060802611593], - [23.29042314884119, 107.85884615966864] - ] - ] - }, - { - drawing: true, - position: [123, 125], - angle: 0, - path: [ - [ - [-1, 125], - [-0.9999999999999998, 121], - [3, 121], - [3.0000000000000004, 125], - [7, 125], - [11, 125], - [11, 121], - [7, 121], - [7, 117], - [11, 117], - [11, 113], - [7, 113], - [3, 113], - [2.999999999999999, 117], - [-1.0000000000000009, 117], - [-1.0000000000000007, 113], - [-1.0000000000000004, 109], - [2.9999999999999996, 109], - [3, 105], - [-1, 105], - [-0.9999999999999998, 101], - [-0.9999999999999996, 97], - [3.0000000000000004, 97], - [3.000000000000001, 101], - [7.000000000000001, 101], - [7.000000000000001, 97], - [11, 97], - [11, 101], - [11, 105], - [7, 105], - [7, 109], - [11, 109], - [15, 109], - [19, 109], - [19, 105], - [15, 105], - [15, 101], - [15, 97], - [19, 97], - [19, 101], - [23, 101], - [23, 97], - [27, 97], - [27, 101], - [27, 105], - [23, 105], - [23, 109], - [27, 109], - [27, 113], - [27, 117], - [23, 117], - [23, 113], - [19, 113], - [15, 113], - [15, 117], - [19, 117], - [19, 121], - [15, 121], - [15, 125], - [19, 125], - [23, 125], - [23, 121], - [27, 121], - [27, 125], - [31, 125], - [35, 125], - [35, 121], - [31, 121], - [31, 117], - [31, 113], - [35, 113], - [35, 117], - [39, 117], - [39, 113], - [43, 113], - [43, 117], - [43, 121], - [39, 121], - [39, 125], - [43, 125], - [47, 125], - [47, 121], - [51, 121], - [51, 125], - [55, 125], - [59, 125], - [59, 121], - [55, 121], - [55, 117], - [59, 117], - [59, 113], - [55, 113], - [51, 113], - [51, 117], - [47, 117], - [47, 113], - [47, 109], - [47, 105], - [51, 105], - [51, 109], - [55, 109], - [59, 109], - [59, 105], - [55, 105], - [55, 101], - [59, 101], - [59, 97], - [55, 97], - [51, 97], - [51, 101], - [47, 101], - [47, 97], - [43, 97], - [39, 97], - [39, 101], - [43, 101], - [43, 105], - [43, 109], - [39, 109], - [39, 105], - [35, 105], - [35, 109], - [31, 109], - [31, 105], - [31, 101], - [35, 101], - [35, 97], - [31, 97], - [31, 93], - [35, 93], - [35, 89], - [31, 89], - [31, 85], - [31, 81], - [35, 81], - [35, 85], - [39, 85], - [39, 81], - [43, 81], - [43, 85], - [43, 89], - [39, 89], - [39, 93], - [43, 93], - [47, 93], - [47, 89], - [51, 89], - [51, 93], - [55, 93], - [59, 93], - [59, 89], - [55, 89], - [55, 85], - [59, 85], - [59, 81], - [55, 81], - [51, 81], - [51, 85], - [47, 85], - [47, 81], - [47, 77], - [47, 73], - [51, 73], - [51, 77], - [55, 77], - [59, 77], - [59, 73], - [55, 73], - [55, 69], - [59, 69], - [59, 65], - [55, 65], - [51, 65], - [51, 69], - [47, 69], - [47, 65], - [43, 65], - [39, 65], - [39, 69], - [43, 69], - [43, 73], - [43, 77], - [39, 77], - [39, 73], - [35, 73], - [35, 77], - [31, 77], - [31, 73], - [31, 69], - [35, 69], - [35, 65], - [31, 65], - [27, 65], - [27, 69], - [23, 69], - [23, 65], - [19, 65], - [15, 65], - [15, 69], - [19, 69], - [19, 73], - [15, 73], - [15, 77], - [19, 77], - [23, 77], - [23, 73], - [27, 73], - [27, 77], - [27, 81], - [23, 81], - [23, 85], - [27, 85], - [27, 89], - [27, 93], - [23, 93], - [23, 89], - [19, 89], - [19, 93], - [15, 93], - [15, 89], - [15, 85], - [19, 85], - [19, 81], - [15, 81], - [11, 81], - [7, 81], - [6.999999999999999, 85], - [11, 85], - [11, 89], - [11, 93], - [7, 93], - [7, 89], - [3, 89], - [2.999999999999999, 93], - [-1.0000000000000009, 93], - [-1.0000000000000007, 89], - [-1.0000000000000004, 85], - [2.9999999999999996, 85], - [3, 81], - [-1, 81], - [-0.9999999999999998, 77], - [-0.9999999999999996, 73], - [3.0000000000000004, 73], - [3.000000000000001, 77], - [7.000000000000001, 77], - [11, 77], - [11, 73], - [7, 73], - [7, 69], - [11, 69], - [11, 65], - [7, 65], - [3, 65], - [2.999999999999999, 69], - [-1.0000000000000009, 69], - [-1.0000000000000007, 65], - [-1.0000000000000004, 61], - [2.9999999999999996, 61], - [3, 57], - [-1, 57], - [-0.9999999999999998, 53], - [-0.9999999999999996, 49], - [3.0000000000000004, 49], - [3.000000000000001, 53], - [7.000000000000001, 53], - [7.000000000000001, 49], - [11, 49], - [11, 53], - [11, 57], - [7, 57], - [7, 61], - [11, 61], - [15, 61], - [15, 57], - [19, 57], - [19, 61], - [23, 61], - [27, 61], - [27, 57], - [23, 57], - [23, 53], - [27, 53], - [27, 49], - [23, 49], - [19, 49], - [19, 53], - [15, 53], - [15, 49], - [15, 45], - [15, 41], - [19, 41], - [19, 45], - [23, 45], - [27, 45], - [27, 41], - [23, 41], - [23, 37], - [27, 37], - [27, 33], - [23, 33], - [19, 33], - [19, 37], - [15, 37], - [15, 33], - [11, 33], - [7, 33], - [6.999999999999999, 37], - [11, 37], - [11, 41], - [11, 45], - [7, 45], - [7, 41], - [3, 41], - [2.999999999999999, 45], - [-1.0000000000000009, 45], - [-1.0000000000000007, 41], - [-1.0000000000000004, 37], - [2.9999999999999996, 37], - [3, 33], - [-1, 33], - [-0.9999999999999998, 29], - [-0.9999999999999996, 25], - [3.0000000000000004, 25], - [3.000000000000001, 29], - [7.000000000000001, 29], - [11, 29], - [11, 25], - [7, 25], - [7, 21], - [11, 21], - [11, 17], - [7, 17], - [3, 17], - [2.999999999999999, 21], - [-1.0000000000000009, 21], - [-1.0000000000000007, 17], - [-1.0000000000000004, 13], - [2.9999999999999996, 13], - [3, 9], - [-1, 9], - [-0.9999999999999998, 5], - [-0.9999999999999996, 1], - [3.0000000000000004, 1], - [3.000000000000001, 5], - [7.000000000000001, 5], - [7.000000000000001, 1], - [11, 1], - [11, 5], - [11, 9], - [7, 9], - [7, 13], - [11, 13], - [15, 13], - [19, 13], - [19, 9], - [15, 9], - [15, 5], - [15, 1], - [19, 1], - [19, 5], - [23, 5], - [23, 1], - [27, 1], - [27, 5], - [27, 9], - [23, 9], - [23, 13], - [27, 13], - [27, 17], - [27, 21], - [23, 21], - [23, 17], - [19, 17], - [15, 17], - [15, 21], - [19, 21], - [19, 25], - [15, 25], - [15, 29], - [19, 29], - [23, 29], - [23, 25], - [27, 25], - [27, 29], - [31, 29], - [31, 25], - [35, 25], - [35, 29], - [39, 29], - [43, 29], - [43, 25], - [39, 25], - [39, 21], - [43, 21], - [43, 17], - [39, 17], - [35, 17], - [35, 21], - [31, 21], - [31, 17], - [31, 13], - [35, 13], - [35, 9], - [31, 9], - [31, 5], - [31, 1], - [35, 1], - [35, 5], - [39, 5], - [39, 1], - [43, 1], - [43, 5], - [43, 9], - [39, 9], - [39, 13], - [43, 13], - [47, 13], - [51, 13], - [51, 9], - [47, 9], - [47, 5], - [47, 1], - [51, 1], - [51, 5], - [55, 5], - [55, 1], - [59, 1], - [59, 5], - [59, 9], - [55, 9], - [55, 13], - [59, 13], - [59, 17], - [59, 21], - [55, 21], - [55, 17], - [51, 17], - [47, 17], - [47, 21], - [51, 21], - [51, 25], - [47, 25], - [47, 29], - [51, 29], - [55, 29], - [55, 25], - [59, 25], - [59, 29], - [59, 33], - [55, 33], - [55, 37], - [59, 37], - [59, 41], - [59, 45], - [55, 45], - [55, 41], - [51, 41], - [51, 45], - [47, 45], - [47, 41], - [47, 37], - [51, 37], - [51, 33], - [47, 33], - [43, 33], - [43, 37], - [39, 37], - [39, 33], - [35, 33], - [31, 33], - [31, 37], - [35, 37], - [35, 41], - [31, 41], - [31, 45], - [35, 45], - [39, 45], - [39, 41], - [43, 41], - [43, 45], - [43, 49], - [43, 53], - [39, 53], - [39, 49], - [35, 49], - [31, 49], - [31, 53], - [35, 53], - [35, 57], - [31, 57], - [31, 61], - [35, 61], - [39, 61], - [39, 57], - [43, 57], - [43, 61], - [47, 61], - [51, 61], - [51, 57], - [47, 57], - [47, 53], - [47, 49], - [51, 49], - [51, 53], - [55, 53], - [55, 49], - [59, 49], - [59, 53], - [59, 57], - [55, 57], - [55, 61], - [59, 61], - [63, 61], - [67, 61], - [67, 57], - [63, 57], - [63, 53], - [63, 49], - [67, 49], - [67, 53], - [71, 53], - [71, 49], - [75, 49], - [75, 53], - [75, 57], - [71, 57], - [71, 61], - [75, 61], - [79, 61], - [79, 57], - [83, 57], - [83, 61], - [87, 61], - [91, 61], - [91, 57], - [87, 57], - [87, 53], - [91, 53], - [91, 49], - [87, 49], - [83, 49], - [83, 53], - [79, 53], - [79, 49], - [79, 45], - [79, 41], - [83, 41], - [83, 45], - [87, 45], - [91, 45], - [91, 41], - [87, 41], - [87, 37], - [91, 37], - [91, 33], - [87, 33], - [83, 33], - [83, 37], - [79, 37], - [79, 33], - [75, 33], - [71, 33], - [71, 37], - [75, 37], - [75, 41], - [75, 45], - [71, 45], - [71, 41], - [67, 41], - [67, 45], - [63, 45], - [63, 41], - [63, 37], - [67, 37], - [67, 33], - [63, 33], - [63, 29], - [63, 25], - [67, 25], - [67, 29], - [71, 29], - [75, 29], - [75, 25], - [71, 25], - [71, 21], - [75, 21], - [75, 17], - [71, 17], - [67, 17], - [67, 21], - [63, 21], - [63, 17], - [63, 13], - [67, 13], - [67, 9], - [63, 9], - [63, 5], - [63, 1], - [67, 1], - [67, 5], - [71, 5], - [71, 1], - [75, 1], - [75, 5], - [75, 9], - [71, 9], - [71, 13], - [75, 13], - [79, 13], - [83, 13], - [83, 9], - [79, 9], - [79, 5], - [79, 1], - [83, 1], - [83, 5], - [87, 5], - [87, 1], - [91, 1], - [91, 5], - [91, 9], - [87, 9], - [87, 13], - [91, 13], - [91, 17], - [91, 21], - [87, 21], - [87, 17], - [83, 17], - [79, 17], - [79, 21], - [83, 21], - [83, 25], - [79, 25], - [79, 29], - [83, 29], - [87, 29], - [87, 25], - [91, 25], - [91, 29], - [95, 29], - [95, 25], - [99, 25], - [99, 29], - [103, 29], - [107, 29], - [107, 25], - [103, 25], - [103, 21], - [107, 21], - [107, 17], - [103, 17], - [99, 17], - [99, 21], - [95, 21], - [95, 17], - [95, 13], - [99, 13], - [99, 9], - [95, 9], - [95, 5], - [95, 1], - [99, 1], - [99, 5], - [103, 5], - [103, 1], - [107, 1], - [107, 5], - [107, 9], - [103, 9], - [103, 13], - [107, 13], - [111, 13], - [115, 13], - [115, 9], - [111, 9], - [111, 5], - [111, 1], - [115, 1], - [115, 5], - [119, 5], - [119, 1], - [123, 1], - [123, 5], - [123, 9], - [119, 9], - [119, 13], - [123, 13], - [123, 17], - [123, 21], - [119, 21], - [119, 17], - [115, 17], - [111, 17], - [111, 21], - [115, 21], - [115, 25], - [111, 25], - [111, 29], - [115, 29], - [119, 29], - [119, 25], - [123, 25], - [123, 29], - [123, 33], - [119, 33], - [119, 37], - [123, 37], - [123, 41], - [123, 45], - [119, 45], - [119, 41], - [115, 41], - [115, 45], - [111, 45], - [111, 41], - [111, 37], - [115, 37], - [115, 33], - [111, 33], - [107, 33], - [107, 37], - [103, 37], - [103, 33], - [99, 33], - [95, 33], - [95, 37], - [99, 37], - [99, 41], - [95, 41], - [95, 45], - [99, 45], - [103, 45], - [103, 41], - [107, 41], - [107, 45], - [107, 49], - [107, 53], - [103, 53], - [103, 49], - [99, 49], - [95, 49], - [95, 53], - [99, 53], - [99, 57], - [95, 57], - [95, 61], - [99, 61], - [103, 61], - [103, 57], - [107, 57], - [107, 61], - [111, 61], - [115, 61], - [115, 57], - [111, 57], - [111, 53], - [111, 49], - [115, 49], - [115, 53], - [119, 53], - [119, 49], - [123, 49], - [123, 53], - [123, 57], - [119, 57], - [119, 61], - [123, 61], - [123, 65], - [123, 69], - [119, 69], - [119, 65], - [115, 65], - [111, 65], - [111, 69], - [115, 69], - [115, 73], - [111, 73], - [111, 77], - [115, 77], - [119, 77], - [119, 73], - [123, 73], - [123, 77], - [123, 81], - [119, 81], - [119, 85], - [123, 85], - [123, 89], - [123, 93], - [119, 93], - [119, 89], - [115, 89], - [115, 93], - [111, 93], - [111, 89], - [111, 85], - [115, 85], - [115, 81], - [111, 81], - [107, 81], - [103, 81], - [103, 85], - [107, 85], - [107, 89], - [107, 93], - [103, 93], - [103, 89], - [99, 89], - [99, 93], - [95, 93], - [95, 89], - [95, 85], - [99, 85], - [99, 81], - [95, 81], - [95, 77], - [95, 73], - [99, 73], - [99, 77], - [103, 77], - [107, 77], - [107, 73], - [103, 73], - [103, 69], - [107, 69], - [107, 65], - [103, 65], - [99, 65], - [99, 69], - [95, 69], - [95, 65], - [91, 65], - [87, 65], - [87, 69], - [91, 69], - [91, 73], - [91, 77], - [87, 77], - [87, 73], - [83, 73], - [83, 77], - [79, 77], - [79, 73], - [79, 69], - [83, 69], - [83, 65], - [79, 65], - [75, 65], - [75, 69], - [71, 69], - [71, 65], - [67, 65], - [63, 65], - [63, 69], - [67, 69], - [67, 73], - [63, 73], - [63, 77], - [67, 77], - [71, 77], - [71, 73], - [75, 73], - [75, 77], - [75, 81], - [75, 85], - [71, 85], - [71, 81], - [67, 81], - [63, 81], - [63, 85], - [67, 85], - [67, 89], - [63, 89], - [63, 93], - [67, 93], - [71, 93], - [71, 89], - [75, 89], - [75, 93], - [79, 93], - [83, 93], - [83, 89], - [79, 89], - [79, 85], - [79, 81], - [83, 81], - [83, 85], - [87, 85], - [87, 81], - [91, 81], - [91, 85], - [91, 89], - [87, 89], - [87, 93], - [91, 93], - [91, 97], - [87, 97], - [87, 101], - [91, 101], - [91, 105], - [91, 109], - [87, 109], - [87, 105], - [83, 105], - [83, 109], - [79, 109], - [79, 105], - [79, 101], - [83, 101], - [83, 97], - [79, 97], - [75, 97], - [75, 101], - [71, 101], - [71, 97], - [67, 97], - [63, 97], - [63, 101], - [67, 101], - [67, 105], - [63, 105], - [63, 109], - [67, 109], - [71, 109], - [71, 105], - [75, 105], - [75, 109], - [75, 113], - [75, 117], - [71, 117], - [71, 113], - [67, 113], - [63, 113], - [63, 117], - [67, 117], - [67, 121], - [63, 121], - [63, 125], - [67, 125], - [71, 125], - [71, 121], - [75, 121], - [75, 125], - [79, 125], - [83, 125], - [83, 121], - [79, 121], - [79, 117], - [79, 113], - [83, 113], - [83, 117], - [87, 117], - [87, 113], - [91, 113], - [91, 117], - [91, 121], - [87, 121], - [87, 125], - [91, 125], - [95, 125], - [95, 121], - [99, 121], - [99, 125], - [103, 125], - [107, 125], - [107, 121], - [103, 121], - [103, 117], - [107, 117], - [107, 113], - [103, 113], - [99, 113], - [99, 117], - [95, 117], - [95, 113], - [95, 109], - [99, 109], - [99, 105], - [95, 105], - [95, 101], - [95, 97], - [99, 97], - [99, 101], - [103, 101], - [103, 97], - [107, 97], - [107, 101], - [107, 105], - [103, 105], - [103, 109], - [107, 109], - [111, 109], - [115, 109], - [115, 105], - [111, 105], - [111, 101], - [111, 97], - [115, 97], - [115, 101], - [119, 101], - [119, 97], - [123, 97], - [123, 101], - [123, 105], - [119, 105], - [119, 109], - [123, 109], - [123, 113], - [123, 117], - [119, 117], - [119, 113], - [115, 113], - [111, 113], - [111, 117], - [115, 117], - [115, 121], - [111, 121], - [111, 125], - [115, 125], - [119, 125], - [119, 121], - [123, 121], - [123, 125] - ] - ] - } -] - -export { turtles } diff --git a/critic/main.js b/critic/main.js new file mode 100644 index 000000000..6a11988fd --- /dev/null +++ b/critic/main.js @@ -0,0 +1,15 @@ +import 'dotenv/config' +import OpenAI from "openai"; + +// console.log(process.env.OPENAI_API_KEY); + +const openai = new OpenAI({ + apiKey: process.env.OPENAI_API_KEY, +}); + +const chatCompletion = await openai.chat.completions.create({ + messages: [{ role: "user", content: "Say this is a test" }], + model: "gpt-3.5-turbo", +}); + +console.log(chatCompletion.choices[0].message); \ No newline at end of file diff --git a/critic/main.py b/critic/main.py new file mode 100644 index 000000000..8685ea218 --- /dev/null +++ b/critic/main.py @@ -0,0 +1,48 @@ +import openai +import os +from dotenv import load_dotenv + +load_dotenv() + +# Ensure you have your OPENAI_API_KEY saved in your environment variables +api_key = os.getenv('OPENAI_API_KEY') + +if api_key is None: + print("Please set your OPENAI_API_KEY in your environment variables.") + exit() + +openai.api_key = api_key + +print(dir(openai)) + +def query_gpt(prompt, model='text-davinci-003', max_tokens=150): + """ + Function to query the OpenAI GPT-4 API (or whichever is the latest) + + :param prompt: str, a prompt for the AI. + :param engine: str, the engine's identifier (assuming 'text-davinci-003' is for GPT-4 or replace with GPT-4's engine ID). + :param max_tokens: int, the maximum length of the sequence to be generated. + :return: str, the AI's response + """ + + try: + response = openai.completions.create( + model, + messages=[ + {"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."}, + {"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."} + ] +) + + # Extract the text from the response object + text = response.choices[0].message + return text + except Exception as e: + print(f"Received an error from the OpenAI API: {e}") + return None + +# Test the function +prompt = "Translate the following English text to French: 'Hello, how are you?'" +response = query_gpt(prompt) +if response: + print(response) \ No newline at end of file diff --git a/critic/package-lock.json b/critic/package-lock.json new file mode 100644 index 000000000..f03783e58 --- /dev/null +++ b/critic/package-lock.json @@ -0,0 +1,290 @@ +{ + "name": "critic", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "dotenv": "^16.3.1", + "openai": "^4.12.4" + } + }, + "node_modules/@types/node": { + "version": "18.18.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.6.tgz", + "integrity": "sha512-wf3Vz+jCmOQ2HV1YUJuCWdL64adYxumkrxtc+H1VUQlnQI04+5HtH+qZCOE21lBE7gIrt+CwX2Wv8Acrw5Ak6w==" + }, + "node_modules/@types/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-lX17GZVpJ/fuCjguZ5b3TjEbSENxmEk1B2z02yoXSK9WMEWRivhdSY73wWMn6bpcCDAOh6qAdktpKHIlkDk2lg==", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "dependencies": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "engines": { + "node": ">= 14" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/openai": { + "version": "4.12.4", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.12.4.tgz", + "integrity": "sha512-oPNVJkpgxDUKF6WGGdHEZh5m/kjmYxS2Y1q7YVFCkvKUGthb8OGYRGCFBRPq5CQJezifzABTZRlVYnXLd6L4vQ==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + }, + "bin": { + "openai": "bin/cli" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/critic/package.json b/critic/package.json new file mode 100644 index 000000000..0a36b47cd --- /dev/null +++ b/critic/package.json @@ -0,0 +1,7 @@ +{ + "type": "module", + "dependencies": { + "dotenv": "^16.3.1", + "openai": "^4.12.4" + } +}