-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdifficulty.c
More file actions
51 lines (45 loc) · 865 Bytes
/
difficulty.c
File metadata and controls
51 lines (45 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <pic32mx.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "header.h"
#include <math.h>
int delayByDifficulty()
{
if (aiDiff == 0)
{
return (200 * myRandom());
}
else if (aiDiff == 1)
{
return (120 * myRandom());
}
else
{
return 0;
}
}
int myRandom() // stolen
{
// Use the current time as a seed for the random number generator
unsigned int seed = TMR2;
// Use a simple algorithm to generate a random number
seed = (seed * 1103515245 + 12345) % (1 << 31);
int num = (seed >> 16) % 10;
return num;
}
double ballSpeedModifierX(double ballSpeed)
{
if (aiDiff == 0)
{
return (ballSpeed * 0.5);
}
else if (aiDiff == 1)
{
return ballSpeed * 0.8;
}
else
{
return (ballSpeed * 1.5);
}
}