嘿,我已经将此代码段实现为用于 alpha-beta 修剪功能的移动排序系统。它确实加快了我的代码速度,但是当我分析我的代码时,我发现它非常笨拙。
move_ord [] (primary_ord,secondary_ord) = primary_ord ++ secondary_ord
move_ord (y:ys) (primary_ord,secondary_ord) = case no_of_pebbles state y of
0 -> move_ord ys (primary_ord,secondary_ord)
13 -> move_ord ys (y : primary_ord,secondary_ord)
x
| 7 - y == x -> move_ord ys (y : primary_ord,secondary_ord)
| otherwise -> move_ord ys (primary_ord,y : secondary_ord)
它旨在将具有特定 pebble 值(13 和 7-y==x)的移动放在列表的前面。同时也过滤掉了0个鹅卵石的非法走法。
Pebbles 存储为 Int。y 是一个整数。
先感谢您。