public void ShouldScore800With3PairsAnd6TwosBasicRulesAnd3PairsRuleOnly() { var game = new Greed(false); game.AddScoringRule(new ThreePairsRule()); Assert.AreEqual(800, game.Score(new[] { 2, 2, 2, 2, 2, 2 })); }
public void FourOnesAreWorth1100() { var game = new Greed(false); int score = game.Score(new[] { 1, 1, 1, 1 }); Assert.AreEqual(1100, score); }
public void GivenAssertionsAreCorrect() { var game = new Greed(false); Assert.AreEqual(1150, game.Score(new[] { 1, 1, 1, 5, 1 })); Assert.AreEqual(0, game.Score(new[] { 2, 3, 4, 6, 2 })); Assert.AreEqual(350, game.Score(new[] { 3, 4, 5, 3, 3 })); Assert.AreEqual(250, game.Score(new[] { 1, 5, 1, 2, 4 })); }
void Start() { greed = new Greed(); path = greed.GetPathsByDijkstra(GetStartPosition(), AirSpawn.targets).FirstOrDefault().ToArray(); vectors = new Vector2[path.Length]; vectors = path.Select(cell => new Vector2(cell.X * MazeGenerator.Shift, cell.Y * MazeGenerator.Shift)).ToArray(); enumerator = GetEnumerator(); enumerator.MoveNext(); }
public void UpdateManagerUI(MainForm mf) { mf.lblManagerGreed.Text = "GRD: " + Greed.ToString(); mf.lblManagerIQ.Text = "INT: " + Intelligence.ToString(); mf.lblManagerNegotiate.Text = "NEG: " + Negotiating.ToString(); mf.lblManagerPower.Text = "POW: " + Power.ToString(); mf.lblManagerScouting.Text = "SCT: " + Scouting.ToString(); mf.lblManagerEfficiency.Text = "EFF: " + CurrentEfficiency.ToString(); mf.lblManagerStatus.Text = "Status: " + Status.ToString(); }
public void Score_RollingAGivenSequence_ShouldScoreAppropriately(int[] roll, int expectedScore) { //arrange Greed greed = new Greed(); int[] diceRoll = roll; greed.Roll(diceRoll); //act int score = greed.Score(); //assert score.Should().Be(expectedScore, $"because rolling {string.Join(",", diceRoll)} should earn {expectedScore} points"); }
public MovingController(List <IGameObject> allObjects, int id) { var player = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId != id); var bot = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId == id); var field = (Field)allObjects.Find(elem => elem.Type == ObjectType.Field); var dist = bot.Radius; lastPlayerPos = new Position(player.Centre.X, player.Centre.Y); greed = new Greed(field.Width, field.Height, bot.Radius, dist);//2 * dist); greed.SetBlocks(CreateBlockedAreas(allObjects, dist)); greed.SetShadows(CreateShadows(allObjects, player.Centre, player.Radius / 2)); currentPath = LeeSearch.FindPath(bot.Centre, greed); }
public static Stack <Position> FindPath(Position start, Greed greed) { var waves = new List <HashSet <Position> > { new HashSet <Position>() }; var finish = new Position(0, 0); bool isFind = FindFinish(waves, start, greed, out finish); if (!isFind) { return(null); } var path = ReestablishPath(waves, start, finish, greed); return(path); }
public int CalculateScore() { greedGame = new Greed(diceOption.UseAllRules); return(greedGame.Score(rolledDice)); }
private static Stack <Position> ReestablishPath(List <HashSet <Position> > waves, Position start, Position finish, Greed greed) { var current = finish; var level = waves.Count - 2; var isBreak = false; var path = new Stack <Position>(); while (!isBreak && level > -1) { isBreak = true; var neighbors = greed.GetNearests(current); foreach (var neighbor in neighbors) { if (waves[level].Contains(neighbor.Centre)) { isBreak = false; level--; path.Push(current); current = neighbor.Centre; break; } } } if (isBreak) { return(null); } return(path); }
public void SetUp() { _greedGame = new Greed(); }
public static void ShouldBeWorthless() { Assert.AreEqual(0, Greed.Score(new int[] { 2, 3, 4, 6, 2 }), "Should be 0 :-("); }
public static void Tripplets4() { Assert.AreEqual(1100, Greed.Score(new int[] { 1, 1, 1, 1, 2 }), "Should be 1100"); }
public static void Tripplets3() { Assert.AreEqual(300, Greed.Score(new int[] { 3, 3, 3, 2, 2 }), "Should be 300"); }
public static void Tripplets2() { Assert.AreEqual(300, Greed.Score(new int[] { 1, 1, 3, 5, 5 }), "Should be 300"); }
public static void ShouldValueMixedSets() { Assert.AreEqual(450, Greed.Score(new int[] { 2, 4, 4, 5, 4 }), "Should be 450"); }
public void SetUp() { _greed = new Greed(); }
private static bool FindFinish(List <HashSet <Position> > waves, Position start, Greed greed, out Position finish) { int level = 0; var count = 1; waves[0].Add(start); var total = greed.Total(); var totalCount = 0; var alreadyViewed = new HashSet <Position>() { start }; while (count > 0 && totalCount <= total) { count = 0; waves.Add(new HashSet <Position>()); foreach (var point in waves[level]) { var neighbors = greed.GetNearests(point); foreach (var neighbor in neighbors) { if (!alreadyViewed.Contains(neighbor.Centre)) { if (greed.IsInDestinations(neighbor.Centre) && !greed.IsInBlocks(neighbor.Centre) && greed.IsInGreed(neighbor.Centre)) { finish = new Position(neighbor.Centre.X, neighbor.Centre.Y);; return(true); } else { count++; totalCount += 1; waves[level + 1].Add(neighbor.Centre); alreadyViewed.Add(neighbor.Centre); } } } } level++; } finish = null; return(false); }
private void Build() { if (_selectBlock == 255) { return; } ray = _cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 10, _layer)) { _changedMaterials[_selectBlock].color = _inventory.SelectedItem.ItemsCount > 0 ? new TransparentColors(1).color : new TransparentColors(2).color; _blocks[_selectBlock].GetComponent <MeshRenderer>().sharedMaterial = _changedMaterials[_selectBlock]; if ((_lastBlock = hit.transform.GetComponent <BaseBlock>()) || (_lastGreed = hit.transform.GetComponent <Greed>())) { _lastType = _blocksCs[_selectBlock].Type; _blockPos = hit.point; _blocks[_selectBlock].transform.forward = hit.normal; switch (_lastType) { case 3: //dunamite if (_lastGreed) { _blocks[_selectBlock].transform.forward = Vector3.forward; _blockPos.y += 0.25f; _blocks[_selectBlock].transform.eulerAngles = new Vector3(0, 30, 0); } else { _blocks[_selectBlock].transform.right = -hit.normal; _blockPos = hit.collider.transform.position + hit.normal * 0.8f; _blocks[_selectBlock].transform.eulerAngles += new Vector3(0, 0, 30); } break; case 4: // barrel break; case 5: //mine break; default: // other blocks if (_lastGreed) { _blockPos.y += 0.5f; } else { _blockPos = hit.collider.transform.position + hit.normal; } _blocks[_selectBlock].transform.rotation = Quaternion.identity; break; } _blocks[_selectBlock].transform.position = _blockPos; if (Input.GetMouseButtonDown(0)) { if (_inventory.GetItem(_selectBlock, 1)) { ChangeBlock(hit); } } _lastGreed = null; } }
public void MyTestInitialize() { _greedGame = new Greed(); }
public static void ShouldValueTriplets() { Assert.AreEqual(400, Greed.Score(new int[] { 4, 4, 4, 3, 3 }), "Should be 400"); }