# Godot GDScript code from ChatGPT

Can it do Godot? I think so.

**Write Godot GDscript function that returns numbers between 1 and 100 which smoothly oscillate up and down in a bumpy way that isn't predictable. **

Here is a GDScript function that returns a random number between 1 and 100 with a "bumpy" oscillation:

func random_bumpy_oscillation():

var number = 50 + (50 * Math.sin(OS.get_ticks() / 100))

number += (Math.rand() - 0.5) * 20

return number.clamp(1, 100)

Explanation:

`OS.get_ticks()`

returns the number of milliseconds since the engine started.`Math.sin(OS.get_ticks() / 100)`

returns a value between -1 and 1 that smoothly oscillates over time.`50 + (50 * Math.sin(OS.get_ticks() / 100))`

shifts the oscillation so it ranges between 0 and 100.`(Math.rand() - 0.5) * 20`

adds a random value between -10 and 10 to the result, making the oscillation more "bumpy".`number.clamp(1, 100)`

limits the result to the range between 1 and 100.

**Make the bumps smoother so that the output is like a complex wave function.**

Here is an updated function that returns a smoother wave function:

func random_smooth_oscillation():

var time = OS.get_ticks() / 1000

var number = 50 + (50 * Math.sin(time)) + (20 * Math.sin(time * 2)) + (10 * Math.sin(time * 3))

number += (Math.rand() - 0.5) * 5

return number.clamp(1, 100)

Explanation:

`time = OS.get_ticks() / 1000`

converts the number of milliseconds to seconds.`50 + (50 * Math.sin(time)) + (20 * Math.sin(time * 2)) + (10 * Math.sin(time * 3))`

creates a complex wave function by summing several sinusoidal functions with different frequencies and amplitudes.`(Math.rand() - 0.5) * 5`

adds a small random value to the result, making the wave function slightly less predictable.`number.clamp(1, 100)`

limits the result to the range between 1 and 100.

I think with more time, I could have worked out code for making the ground do what I wanted with the 1 pixel wide vertical strips - but I've already drawn the larger pieces and started implementing them.

However, I will have to keep ChatGPT in mind for coding help.