Skip to content

Commit 0463a06

Browse files
authored
Merge pull request #30 from boraaros/fix/nullable-warnings
Fix/nullable warnings
2 parents e0c64c0 + 05df73c commit 0463a06

14 files changed

Lines changed: 18 additions & 43 deletions

File tree

Alligator.Demo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private static Placement HumanStep()
8383
{
8484
try
8585
{
86-
string[] msg = Console.ReadLine().Split(':');
86+
string[] msg = (Console.ReadLine() ?? string.Empty).Split(':');
8787
return new Placement(int.Parse(msg[0]), int.Parse(msg[1]));
8888
}
8989
catch (Exception e)

Alligator.SixMaking/Logics/IMovingRules.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Alligator.SixMaking.Model;
1+
using Alligator.SixMaking.Model;
22

33
namespace Alligator.SixMaking.Logics
44
{

Alligator.SixMaking/Logics/Rules.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public IEnumerable<Step> LegalStepsAt(IPosition position)
4040
{
4141
var move = stepPool.GetMovement(cell, to, diskCount);
4242

43-
if (movingRules.AreInverses(position.LastStep, move))
43+
if (position.LastStep is not null && movingRules.AreInverses(position.LastStep, move))
4444
{
4545
continue;
4646
}

Alligator.SixMaking/Model/IPosition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Alligator.SixMaking.Model
55
public interface IPosition : IPosition<Step>
66
{
77
Disk Next { get; }
8-
Step LastStep { get; }
8+
Step? LastStep { get; }
99
IList<Step> History { get; }
1010
int ColumnHeightAt(int cell);
1111
Disk DiskAt(int cell, int height);

Alligator.SixMaking/Model/Position.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Position(IList<Step> history)
3232

3333
public bool IsOver => winner != Disk.None;
3434

35-
public Step LastStep => History.LastOrDefault();
35+
public Step? LastStep => History.LastOrDefault();
3636

3737
public sbyte Value => StaticEvaluate();
3838

Alligator.SixMaking/Model/Step.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public int Count
3131
get { return count; }
3232
}
3333

34-
public override bool Equals(object obj)
34+
public override bool Equals(object? obj)
3535
{
3636
if (obj is not Step other)
3737
{

Alligator.SixMaking/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static Step HumanStep()
8484
{
8585
try
8686
{
87-
string[] msg = Console.ReadLine().Split(':');
87+
string[] msg = (Console.ReadLine() ?? string.Empty).Split(':');
8888
int from = int.Parse(msg[0]);
8989
int to = int.Parse(msg[1]);
9090
int count = int.Parse(msg[2]);

Alligator.SixMaking/Singleton.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

Alligator.SixMaking/ZobristHashing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class ZobristHashing : IHashing
44
{
5-
private static ulong[] randomULongs;
5+
private static ulong[] randomULongs = null!;
66
private ulong hashValue;
77

88
private static readonly Random random =

Alligator.Solver/Algorithms/AlphaBetaPruning.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private int SearchRecursively(TPosition position, int depth, int alpha, int beta
7777
}
7878

7979
var bestValue = -int.MaxValue;
80-
TStep bestStep = default;
80+
TStep bestStep = orderedSteps[0];
8181

8282
for (int i = 0; i < orderedSteps.Count; i++)
8383
{
@@ -117,7 +117,7 @@ private List<TStep> GetOrderedLegalSteps(TPosition position, int depth, bool has
117117

118118
foreach (var move in rules.LegalStepsAt(position))
119119
{
120-
if (hasTransposition && move.Equals(transpositionStep))
120+
if (hasTransposition && move!.Equals(transpositionStep))
121121
{
122122
transpositionStepIsLegal = true;
123123
continue;

0 commit comments

Comments
 (0)