-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequentialAI.java
More file actions
32 lines (28 loc) · 868 Bytes
/
sequentialAI.java
File metadata and controls
32 lines (28 loc) · 868 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
// ai player that guesses letters sequentially from 'a' to 'z'
public class sequentialAI implements WOFPlayer {
private int currentIndex;
private final char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
private String playerId;
// constructor initializing player ID
public sequentialAI() {
this.playerId = "sequentialAI";
}
// returns the next letter in alphabetical order
@Override
public char nextGuess() {
if (currentIndex < alphabet.length) {
return alphabet[currentIndex++];
}
return '?'; // fallback if all letters guessed
}
// returns the player's ID
@Override
public String playerId() {
return playerId;
}
// resets the index to start guessing from 'a' again
@Override
public void reset() {
currentIndex = 0;
}
}