Skip to content

Instantly share code, notes, and snippets.

@aiide25titania
Created June 26, 2025 15:35
Show Gist options
  • Save aiide25titania/7d492e6fc9bef779a3bd0e7808d958a4 to your computer and use it in GitHub Desktop.
Save aiide25titania/7d492e6fc9bef779a3bd0e7808d958a4 to your computer and use it in GitHub Desktop.
Run Specification: Dodgeball
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameFeelDescriptions.Examples;
/*
More complex run specification with multiple autoplayers
*/
public class DodgeballRunSpec : RunSpec
{
public DodgeballRunSpec(){
//6 runs per test
this.runsPerSolution = 6;
}
public override void OnRunStart(int run){
UnityEngine.Random.InitState(0);
//first three runs use a 'good' player
if(run < 3){
GameObject.Find("Player").GetComponent<Player>().frameSkip = 1;
GameObject.Find("Player").GetComponent<Player>().modFactor = 0.75f;
GameObject.Find("Player").GetComponent<Player>().magFactor = 4f;
}
//lowered reaction time for the worse player
else{
GameObject.Find("Player").GetComponent<Player>().frameSkip = 1;
GameObject.Find("Player").GetComponent<Player>().frameDelay = 4;
GameObject.Find("Player").GetComponent<Player>().modFactor = 0.75f;
GameObject.Find("Player").GetComponent<Player>().magFactor = 4f;
}
}
public override void OnRunComplete(int run){
}
float p1Score = 0;
float p2Score = 0;
float firstPhase = 0;
public override float ScoreRun(int run){
if(run == 0){
p1score = 0;
p2score = 0
}
if(run < 3){
p1score += BallController.instance.TimeInLevel/60f; //normalised
}
else{
p2score += BallController.instance.TimeInLevel/60f; //normalised
}
if(run < 5){
return 0;
}
else{
return (p2Score/3f) - (p1Score/3f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment