加了一堆东西 推送!!
This commit is contained in:
@@ -8,9 +8,9 @@ using CDSAE3_Lian_Lian_Kan;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
||||
namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
{
|
||||
public partial class Board
|
||||
public partial class Board:IBoard
|
||||
{
|
||||
public int[,] Bd { get; set; } = { { } };//y,x
|
||||
private int[,] Bd = { { } };//y,x
|
||||
public Dictionary<int, List<(int, int)>> board_Index { get; } = new Dictionary<int, List<(int, int)>>();
|
||||
public int[] Vals_per_Image { get; set; } = { };
|
||||
public int total;
|
||||
@@ -24,13 +24,13 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
{
|
||||
total = value;
|
||||
if (total == 0)
|
||||
Settings.game_mode_form?.Finished_Handler(this, new Forms.FinishArgs { finish_Type = Forms.FinishArgs.Finish_Type.All_done });
|
||||
Etcs.game_mode_form?.Finished_Handler(this, new Forms.FinishArgs { finish_Type = Forms.FinishArgs.Finish_Type.All_done });
|
||||
}
|
||||
}
|
||||
public void make_board()
|
||||
public int[,] make_board()
|
||||
{
|
||||
var rand = new Random();
|
||||
size = Settings.get_length_width();
|
||||
size = Etcs.get_length_width();
|
||||
var (width, height) = size;
|
||||
Bd = new int[height + 2, width + 2];
|
||||
for (int i = 0; i < height + 2; i++)
|
||||
@@ -40,7 +40,7 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
if (sum % 2 != 0)
|
||||
sum--;
|
||||
total = sum;
|
||||
int types = Settings.Images_size();
|
||||
int types = Etcs.Images_size();
|
||||
Vals_per_Image = new int[types];
|
||||
int single = sum / types;
|
||||
for (int k = sum; k > 0; k -= 2)
|
||||
@@ -68,15 +68,21 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
}
|
||||
if (not_zero <= 1)
|
||||
{
|
||||
int k = temp_val_per_Image.Single(x => x != 0);
|
||||
int k = 0;
|
||||
for(int i=0;i<temp_val_per_Image.Length;i++)
|
||||
if (temp_val_per_Image[i]!=0)
|
||||
{
|
||||
k = i;
|
||||
break;
|
||||
}
|
||||
temp_val_per_Image[k]--;
|
||||
return k;
|
||||
}
|
||||
int t = rand.Next(0, types);
|
||||
if (temp_val_per_Image[t] == 0 || t == last_val)
|
||||
if (temp_val_per_Image[t] <= 0 || t == last_val)
|
||||
{
|
||||
int i = (t + 1) % types;
|
||||
for (; temp_val_per_Image[i] == 0 || i == last_val; i %= types)
|
||||
for (; temp_val_per_Image[i] <= 0 || i == last_val; i %= types)
|
||||
i++;
|
||||
temp_val_per_Image[i]--;
|
||||
last_val = i;
|
||||
@@ -100,9 +106,9 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
cur_width = 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
return Bd;
|
||||
}
|
||||
public void remake_board()
|
||||
public int[,] remake_board()
|
||||
{
|
||||
board_Index.Clear();
|
||||
var rand = new Random();
|
||||
@@ -151,6 +157,7 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
else
|
||||
board_Index.Add(Bd[i, j], new List<(int, int)> { (j, i) });
|
||||
}
|
||||
return Bd;
|
||||
}
|
||||
public (bool, List<(int, int)>?) test((int, int) a, (int, int) b)//x,y
|
||||
{
|
||||
@@ -274,31 +281,36 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
};
|
||||
var (throughx, xrange) = intersection((squareA[3].Item1, squareA[1].Item1), (squareB[3].Item1, squareB[1].Item1));
|
||||
var (throughy, yrange) = intersection((squareA[0].Item2, squareA[2].Item2), (squareB[0].Item2, squareB[2].Item2));
|
||||
Func<(int, int), List<int>> swing_check = ((int, int) range) =>
|
||||
Func<(int, int), int, List<int>> swing_check = ((int, int) range, int center) =>
|
||||
{
|
||||
int mid = (range.Item2 - range.Item1) / 2 + range.Item1;
|
||||
bool swing = true;//up true
|
||||
List<int> ans = new List<int> { mid };
|
||||
for (int i = 1; ;)
|
||||
List<int> result = new List<int>();
|
||||
if (center < range.Item1)
|
||||
{
|
||||
int t;
|
||||
if (swing)
|
||||
t = mid + i;
|
||||
else
|
||||
{
|
||||
t = mid - i;
|
||||
i++;
|
||||
}
|
||||
swing = !swing;
|
||||
if (t >= range.Item1 && t <= range.Item2)
|
||||
ans.Add(t);
|
||||
else
|
||||
break;
|
||||
for (int k = range.Item1; k <= range.Item2; k++)
|
||||
result.Add(k);
|
||||
return result;
|
||||
}
|
||||
return ans;
|
||||
if (center > range.Item2)
|
||||
{
|
||||
for (int k = range.Item2; k >= range.Item1; k--)
|
||||
result.Add(k);
|
||||
return result;
|
||||
}
|
||||
result.Add(center);
|
||||
Func<int, bool> inrange = (int t) => t >= range.Item1 && t <= range.Item2;
|
||||
bool go_on = true;
|
||||
for (int i = 1; go_on; i++)
|
||||
{
|
||||
go_on = false;
|
||||
if (go_on |= inrange(center + i))
|
||||
result.Add(center + i);
|
||||
if (go_on |= inrange(center - i))
|
||||
result.Add(center - i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
if (throughx)
|
||||
foreach (int i in swing_check(xrange))
|
||||
foreach (int i in swing_check(xrange, a.Item1))
|
||||
if (line_test(false, i, a.Item2, b.Item2))
|
||||
if (reverse)
|
||||
return (true, new List<(int, int)> { b, (i, b.Item2), (i, a.Item2), a });
|
||||
@@ -306,7 +318,7 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
return (true, new List<(int, int)> { a, (i, a.Item2), (i, b.Item2), b });
|
||||
|
||||
if (throughy)
|
||||
foreach (int i in swing_check(yrange))
|
||||
foreach (int i in swing_check(yrange, a.Item2))
|
||||
if (line_test(true, i, a.Item1, b.Item1))
|
||||
if (reverse)
|
||||
return (true, new List<(int, int)> { b, (b.Item1, i), (a.Item1, i), a });
|
||||
@@ -315,9 +327,7 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
}
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
|
||||
internal void decrease(params (int, int)[] poss)
|
||||
public void decrease(params (int, int)[] poss)
|
||||
{
|
||||
foreach (var (x, y) in poss)
|
||||
{
|
||||
@@ -329,20 +339,19 @@ namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
}
|
||||
}
|
||||
|
||||
internal List<List<(int,int)>> get_tip((int, int) start)
|
||||
internal List<List<(int, int)>> get_tip((int, int) start)
|
||||
{
|
||||
List<List<(int, int)>> ans = new List<List<(int, int)>>();
|
||||
if(board_Index.TryGetValue( Bd[start.Item2, start.Item1], out var tip))
|
||||
if (board_Index.TryGetValue(Bd[start.Item2, start.Item1], out var tip))
|
||||
foreach (var pos in tip)
|
||||
{
|
||||
var (result, path) = test(start, pos);
|
||||
if(result&&path!=null)
|
||||
if (result && path != null)
|
||||
ans.Add(path);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public (int, int) size { get; set; }//width,height
|
||||
public Settings.Mode mode { get; set; }
|
||||
public Etcs.Mode mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CDSAE3_Lian_Lian_Kan.Board_funcs
|
||||
{
|
||||
internal interface IBoard
|
||||
{
|
||||
public int[,] make_board();
|
||||
public int[,] remake_board();
|
||||
public (bool, List<(int, int)>?) test((int, int) a, (int, int) b);
|
||||
public void decrease(params (int, int)[] poss);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user