I'm very new to Godot and pretty new to coding

If I have an array of X number of teams and i want each team to have Y matches with no duplicate pairings, how do I go about that in GDscript? I already have the code for the matches, given the array indexes. I just need to know how to keep the pairings unique while looping through the array.

I'm not sure that its strictly round robin since I dont need every team to face off against every other team, just for each matchup to be unique. I've found some possible solutions in Java and C# but I'm having trouble getting my head around it

Thanks

This discussion was caught in the moderation queue since you have not confirmed your account yet.
Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.
If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

I already have the code for the matches, given the array indexes. I just need to know how to keep the pairings unique while looping through the array.

Could you describe the array you are using?

Here's one approach:

extends Node2D

# Array of String
var teams: Array = ["red", "green", "blue", "orange"]
# Dictionary, String : Array of String
var matches: Dictionary = {}

func _ready() -> void:
	if visible:
		compute_matches()
		print_matches()

func compute_matches() -> void:
	for i in teams:
		matches[i] = []
		for j in teams:
			if j != i and not (matches.has(j) and matches[j].has(i)):
				matches[i].push_back(j)

func print_matches() -> void:
	print("Matches:")
	for i in matches:
		for j in matches[i]:
			print("%s vs. %s" % [i, j])

Output:

Matches: red vs. green red vs. blue red vs. orange green vs. blue green vs. orange blue vs. orange

a year later