-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f84ee37
commit 6fa71c5
Showing
4 changed files
with
251 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Schafkopf.Lib; | ||
|
||
namespace Schafkopf.Training.Tests; | ||
|
||
public class CardPickerEnvTests | ||
{ | ||
[Fact] | ||
public void Test_CanPlayGame() | ||
{ | ||
var rules = new GameRules(); | ||
var cardCache = new Card[8]; | ||
var rng = new Random(); | ||
|
||
var env = new CardPickerEnv(); | ||
var state = env.Reset(); | ||
foreach (int i in Enumerable.Range(0, 32)) | ||
{ | ||
var possActions = rules.PossibleCards(state, cardCache); | ||
var action = possActions[rng.Next(possActions.Length)]; | ||
(state, var __, var ___) = env.Step(action); | ||
Assert.Equal(i+1, state.CardCount); | ||
} | ||
|
||
Assert.Equal(32, state.CardCount); // assert that no exception occurred | ||
} | ||
|
||
[Fact(Skip="raises error (needs to be fixed)")] | ||
public void Test_CanPlayConsequtiveGames() | ||
{ | ||
var rules = new GameRules(); | ||
var cardCache = new Card[8]; | ||
var rng = new Random(); | ||
var env = new CardPickerEnv(); | ||
|
||
foreach (int _ in Enumerable.Range(0, 1000)) | ||
{ | ||
var state = env.Reset(); | ||
foreach (int i in Enumerable.Range(0, 32)) | ||
{ | ||
var possActions = rules.PossibleCards(state, cardCache); | ||
var action = possActions[rng.Next(possActions.Length)]; | ||
(state, var __, var ___) = env.Step(action); | ||
Assert.Equal(i+1, state.CardCount); | ||
} | ||
|
||
Assert.Equal(32, state.CardCount); // assert that no exception occurred | ||
} | ||
} | ||
} |
Oops, something went wrong.