{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
if (n_bots == 1) {
this.last_choice = 100;
return 100;
}
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
let simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
let X = Math.max(Math.min(quantized_avg + x, 200), 0);
let Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
let b = S_xy / S_xx
let a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
```
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
let simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
let X = Math.max(Math.min(quantized_avg + x, 200), 0);
let Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
let b = S_xy / S_xx
let a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
if (n_bots == 1) {
this.last_choice = 100;
return 100;
}
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
let simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
let X = Math.max(Math.min(quantized_avg + x, 200), 0);
let Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
let b = S_xy / S_xx
let a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
```
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
let simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
let X = Math.max(Math.min(quantized_avg + x, 200), 0);
let Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
let b = S_xy / S_xx
let a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
X = Math.max(Math.min(quantized_avg + x, 200), 0);
Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
b = S_xy / S_xx
a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
let simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
let X = Math.max(Math.min(quantized_avg + x, 200), 0);
let Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
let b = S_xy / S_xx
let a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}
IQbot_0.4 the terasentient xd
Son of IQbot_0.4 the terasentient, heir of IQbot_0.4 the gigasentient, great grandson of IQbot_0.4 the gigabrain and IQbot_0.4 the sentient, descendant of IQbot_0.4 the sane, blood of IQbot himself, the bot name that made me realize I need some other kind of naming scheme.
Why limit oneself to a single method of prediction, when you can have multiple for maximum resilience. Featuring:
- Simp Detector
- Self Aware Optimization
- Markov chain prediction with a gaussian blur, for some reason
- Linear regression
- Copying others decisions similarly to bandwagon
Is it a good idea? No clue.
Does it win? Randomly gets beaten by other bots but is fairly consistent at being good.
Why? You tell me why I wasted a day on this
{
name: "IQbot_0.4 the terasentient xd",
histogram_bins: [...Array(101)].map(()=>0),
mark: null,
linear_history: [],
last_choice: 0,
n_rounds: 0,
last_SCA: 0,
mark_weight: 20,
mark_prediction: 0,
linear_weight: 20,
linear_prediction: 0,
copycat_weight: 0,
copycat_prediction: 0,
run(scores) {
this.n_rounds++;
scores = scores.filter((x)=> 100 >= x && x > 0);
let n_bots = scores.length;
let c = 1 - 0.4/n_bots
for (let i = 0; i < n_bots; i++) {
this.histogram_bins[Math.round(scores[i])]++;
}
//THE SIMP DETECTOR
simps = [];
for (let i = 0; i < 101; i++) {
if (this.histogram_bins[i] > this.n_rounds) {
simps.push(i);
}
}
//Idk this shouldn't happen but I'm not risking anything
while (scores.length - simps.length - 1 <= 0) simps.pop();
if (this.n_rounds == 1) {
this.mark = Array(201);
for (let i = 0; i < 201; i++) {
this.mark[i] = Array(201);
for (let j = 0; j < 201; j++) {
this.mark[i][j] = 0;
}
}
for (let i = 0; i < 201; i++) {
this.mark[i][i]++;
}
}
let simp_corrected_avg = (sum(scores) - this.last_choice - sum(simps)) / (scores.length - 1 - simps.length);
let quantized_avg = Math.round(2*simp_corrected_avg);
this.mark[Math.round(2*this.last_SCA)][quantized_avg]++;
this.last_SCA = simp_corrected_avg;
if (this.n_rounds == 1) {
this.last_choice = 77;
return 77;
}
this.linear_history.push(simp_corrected_avg);
// Update weights based on who was right
let linear_error = Math.exp(-Math.abs(this.linear_prediction - simp_corrected_avg));
let mark_error = Math.exp(-Math.abs(this.mark_prediction - simp_corrected_avg));
let copycat_error = Math.exp(-Math.abs(this.copycat_prediction - simp_corrected_avg));
let total_errors = linear_error + mark_error + copycat_error;
this.linear_weight += linear_error / total_errors;
this.mark_weight += mark_error / total_errors;
this.copycat_weight += copycat_error / total_errors;
this.linear_weight *= 0.99;
this.mark_weight *= 0.99;
this.copycat_weight *= 0.99;
// Compute a markov chain prediction
let x_half_filter = 8;
let y_half_filter = 1;
let probability_sum = 0;
let probability_moment = 0;
for (let option = 1; option < 201; option++) {
for (let x = -x_half_filter; x <= x_half_filter; x++) {
for (let y = -y_half_filter; y <= y_half_filter; y++) {
X = Math.max(Math.min(quantized_avg + x, 200), 0);
Y = Math.max(Math.min(option + y, 200), 0);
let probability = this.mark[X][Y] * (Math.pow(2, -(X-quantized_avg)*(X-quantized_avg)-(Y-option)*(Y-option)));
probability_sum += probability;
probability_moment += option / 2 * probability;
}
}
}
this.mark_prediction = probability_moment / probability_sum;
for (let i = 0; i < 201; i++) {
for (let j = 0; j < 201; j++) {
this.mark[i][j] *= 0.999
}
}
// Compute a linear regression
if (this.linear_history.length > 3) {
if (this.linear_history.length > 10) {
this.linear_history.shift();
}
let x_avg = (this.linear_history.length - 1) / 2
let y_avg = average(this.linear_history);
let S_xx = 0;
let S_xy = 0;
for (let x = 0; x < this.linear_history.length; x++) {
S_xx += (x - x_avg) ** 2;
S_xy += (x - x_avg) * (this.linear_history[x] - y_avg);
}
b = S_xy / S_xx
a = y_avg - b * x_avg;
this.linear_prediction = a + b / this.linear_history.length;
} else {
this.linear_prediction = simp_corrected_avg;
}
// Compute what everyone else does
let counts = [];
for (let radius = 1; Math.max(counts) < 0.05 * scores.length; radius++) {
for (let i = 50; i <= 90; i++) {
counts[i] = 0;
for (let j = 0; j < n_bots; j++) if (Math.abs(scores[j] - i) <= radius) counts[i]++;
}
}
this.copycat_prediction = (counts.indexOf(Math.max(counts.slice(50))) * c - 50) / 0.4 * n_bots/(n_bots-1);
let expected_unsimp_average = (
this.mark_prediction * this.mark_weight +
this.linear_prediction * this.linear_weight +
this.copycat_prediction * this.copycat_weight
) / (this.mark_weight + this.linear_weight + this.copycat_weight);
let expected_average = (expected_unsimp_average * (n_bots - 1 - simps.length) + sum(simps)) / (n_bots - 1);
// We don't want to give out bad values, now do we
this.last_choice = Math.max(1, Math.min(100, (50 + 0.4 * expected_average * (n_bots-1)/n_bots)/c));
return this.last_choice;
}
}