Skip to content

Commit

Permalink
fix defect on filler char algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Hnj0 committed May 2, 2024
1 parent f59db70 commit 21bd2b5
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/main/java/uta/cse3310/Game.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package uta.cse3310;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Queue;

public class Game
{
Expand All @@ -11,7 +15,8 @@ public class Game
//public char[] word;
public ArrayList<String> identified_words;
public ArrayList<String> valid_words;

private Queue<Character> alphabet = new LinkedList<Character>();


Game(int busy, int test_grid)
{
Expand All @@ -22,12 +27,26 @@ public class Game


identified_words = new ArrayList<>();

// Create alphabet and shuffle it so our
// filler letters aren't super obvious
List<Character> temporary = new ArrayList<Character>(26);
for (char c: "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()) {
// alphabet.offer(c);
temporary.add(c);
}
Collections.shuffle(temporary);
for (char c: temporary) {
alphabet.offer(c);
}


grid = createGrid();
}

char[][] createGrid()
{
Random rand = new Random();
// Random rand = new Random();
Create_Grid create_grid = new Create_Grid(test_grid,test_grid,0.67);
char[][] grid = new char[test_grid][test_grid];
if (create_grid.initializeBoard("files.txt"))
Expand All @@ -42,7 +61,9 @@ char[][] createGrid()
{
if (grid[i][j] == '#')
{
grid[i][j] = (char) (rand.nextInt(26) + 'A');
grid[i][j] = alphabet.poll();
alphabet.offer(grid[i][j]);
// grid[i][j] = (char) (rand.nextInt(26) + 'A');
}
}

Expand Down

0 comments on commit 21bd2b5

Please sign in to comment.