PhaethonH

From Egs Mayhem

(Difference between revisions)
m (Sandbox)
(Inventory)
Line 16: Line 16:
== Current Inventory ==
== Current Inventory ==
-
Generated from the Inventory Log program below.
+
Generated from the [[User:PhaethonH/PH_inventory.prolog|Inventory Log program]].
<pre>
<pre>
Current inventory (18 items):
Current inventory (18 items):
Line 42: Line 42:
== Blame List ==
== Blame List ==
-
Generated from the Inventory Log program below.
+
Generated from the [[User:PhaethonH/PH_inventory.prolog|Inventory Log program]].
Blame list:
Blame list:
Line 67: Line 67:
== Inventory Log ==
== Inventory Log ==
-
This is one giant Prolog program file:
+
[[User:PhaethonH/PH_inventory.prolog|Inventory Log program]]
-
<pre>
+
-
%#! gprolog --entry-goal "consult('./PH_inventory.prolog')"
+
-
% phaethon@EGC.prolog
+
-
% GNU Prolog.
+
-
 
+
-
:- dynamic(maxitemid/1, logtime/1).
+
-
 
+
-
% Convenience predicate -- make GNU Prolog stop complaining about deliberate singletons.
+
-
ignore(_).
+
-
 
+
-
% These predicates affect dynamic predicates.
+
-
newitemid(IDnum) :-
+
-
  maxitemid(M),
+
-
  N is (M+1),
+
-
  IDnum is M,
+
-
  retractall(maxitemid(_)),
+
-
  asserta(maxitemid(N)).
+
-
 
+
-
ts(X) :-
+
-
  retractall(logtime(_)),
+
-
  asserta(logtime(X)).
+
-
 
+
-
 
+
-
% Affects dynamic database.
+
-
 
+
-
obtain(Giver, Item) :-
+
-
  obtain(Giver, Item, []).
+
-
 
+
-
obtain(Giver, Count, Item) :-
+
-
  number(Count),
+
-
  obtain(Giver, Count, Item, []).
+
-
 
+
-
obtain(Giver, Item, Descriptions) :-
+
-
  newitemid(ID),
+
-
  describe(ID, Descriptions),
+
-
  logtime(TS),
+
-
  assertz(ts(TS, obtain(ID))),
+
-
  assertz(item(ID, Item)),
+
-
  assertz(blame(ID, Giver)).
+
-
 
+
-
obtain(_, 0, _).
+
-
 
+
-
obtain(Giver, Count, Item, Descriptions) :-
+
-
  number(Count),
+
-
  Count > 0,
+
-
  obtain(Giver, Item, Descriptions),
+
-
  Oneless is (Count-1),
+
-
  obtain(Giver, Oneless, Item, Descriptions).  %Recurse!
+
-
 
+
-
obtain(_, 0, _, _).
+
-
 
+
-
describe(_, []).
+
-
describe(ID, [Desc|Rest]) :-
+
-
  assertz(attrib(ID, Desc)),
+
-
  describe(ID, Rest).
+
-
 
+
-
 
+
-
% Inventory listing.
+
-
 
+
-
% Determine letter-coding of inventory id number -- probably buggy.
+
-
item_header(N, Header) :-
+
-
  N > 0,
+
-
  N < (1+26),
+
-
  Cc is (N + 96),
+
-
  char_code(Ch, Cc),
+
-
  Header = Ch.
+
-
 
+
-
item_header(N, Header) :-
+
-
  N > 26,
+
-
  N < (1 + 26*2),
+
-
  Cc is (N + 64 - 26),
+
-
  char_code(Ch, Cc),
+
-
  Header = Ch.
+
-
 
+
-
item_header(N, Header) :-
+
-
  N > (26*2),
+
-
  Header = N.
+
-
 
+
-
 
+
-
% string.join()
+
-
strjoin(ResultString, _, []) :-
+
-
  ResultString = "".
+
-
 
+
-
strjoin(ResultString, _, [C]) :-
+
-
  atomic(C),
+
-
  name(C, ResultString)
+
-
  ;
+
-
  strjoin(ResultString, "", []).
+
-
 
+
-
strjoin(ResultString, JoinString, [H|T]) :-
+
-
  atomic(H),
+
-
  name(H, SrcStr),
+
-
  strjoin(RestStr, JoinString, T),
+
-
  length(RestStr, Len),
+
-
  (Len > 0 -> append(JoinString, RestStr, SuffixStr) ; SuffixStr = RestStr),
+
-
  append(SrcStr, SuffixStr, ResultString)
+
-
  ;
+
-
  strjoin(ResultString, JoinString, T).
+
-
 
+
-
 
+
-
% Return string description of item #N (Opts affects description verbosity).
+
-
item_line(N, Opts, Line) :-
+
-
  item(N, ItemName),
+
-
  ignore(Opts),
+
-
 
+
-
  findall(X, attrib(N, X), [ItemNoun|ItemAttribs]),
+
-
  ignore(ItemNoun),
+
-
 
+
-
  strjoin(ItemAttribStr, ", ", ItemAttribs),
+
-
  length(ItemAttribStr, IASL),
+
-
  (IASL > 0 -> append(" (", ItemAttribStr, S1), append(S1, ")", S2) ; S2 = ""),
+
-
  name(ItemAttrib, S2),
+
-
  atom_concat(ItemName, ItemAttrib, Line),
+
-
 
+
-
  true.
+
-
 
+
-
 
+
-
% List description of item #N.
+
-
inv_item(N) :-
+
-
  maxitemid(Max),
+
-
  N < Max,
+
-
  item_header(N, ItemHeader),
+
-
  write(' '), write(ItemHeader), write(') '),
+
-
  item_line(N, [], ItemLine),
+
-
  write(ItemLine),
+
-
  nl,
+
-
  !,
+
-
  Next is (N+1),
+
-
  inv_item(Next).
+
-
 
+
-
 
+
-
% pretty-print inventory.
+
-
inv :-
+
-
  maxitemid(Max),
+
-
  ItemCount is (Max-1),
+
-
  write('Current inventory'),
+
-
  write(' ('), write(ItemCount), write(' items)'),
+
-
  write(':'), nl,
+
-
  inv_item(1);
+
-
  write('(end)\
+
-
'),
+
-
  true.
+
-
 
+
-
 
+
-
% Old inventory listing.
+
-
inv0 :- listing(item), listing(blame).
+
-
 
+
-
 
+
-
 
+
-
% blamelist
+
-
blame_item(N) :-
+
-
  maxitemid(Max),
+
-
  N < Max,
+
-
  ts(TS, obtain(N)),
+
-
  blame(N, W),
+
-
  item(N, Item),
+
-
%  write(' '), write(N), write('. '),
+
-
  write('* '),
+
-
  write('['), write(TS), write('] '),
+
-
  write(W), write(' provided '), write(Item), nl,
+
-
  !,
+
-
  Next is (N+1),
+
-
  blame_item(Next).
+
-
 
+
-
blame :-
+
-
  write('Blame list:'), nl,
+
-
  blame_item(1);
+
-
  write('(end)\
+
-
'),
+
-
  true.
+
-
 
+
-
% Run through all transactions to update dynamic database.
+
-
:- initialization(transactions).
+
-
%:- initialization(init).
+
-
 
+
-
 
+
-
 
+
-
 
+
-
 
+
-
% Record of inventory transactions.
+
-
transactions :-
+
-
  assertz(maxitemid(1)),
+
-
 
+
-
  % First item collection
+
-
  ts('2007.08.11 05:12'),
+
-
  obtain('Tyris', 'TF Gun', [tfgun]),
+
-
  obtain('Tyris', 'Fish', [fish, dead]),
+
-
  obtain('Tyris', 'Squirrel teddy', [teddy, squirrel]),
+
-
  obtain('Tyris', 6, 'can of soda', [can, soda, unlabeled]),
+
-
  obtain('Tyris', 'red crystal inscribed with TF-gun code for Otter V1', [crystal, red, for(tfgun), tfgun('Otter V1')]),
+
-
 
+
-
  ts('2007.08.11 05:57'),
+
-
  obtain('Kalga', 'yarn ball of distraction', [ball, yarn, distraction]),
+
-
 
+
-
  ts('2007.08.11 08:02'),
+
-
  obtain('Cheez', 'shiny hubcap', [hubcap, shiny]),
+
-
  obtain('Cheez', 'can of mackerel', [can, mackerel]),
+
-
  obtain('Cheez', 'bag of salt-n-glass cookies', [bag, cookie, salt_n_glass]),
+
-
 
+
-
  ts('2007.08.11 12:46'),
+
-
  obtain('littlebeast', 'Infinite Scroll of Doom-Ish', [scroll, infinite, 'doom-ish']),
+
-
  obtain('littlebeast', 'Infinite Pen of Doom-Ish', [pen, infinite, 'doom-ish']),
+
-
 
+
-
  ts('2007.08.11 16:08'),
+
-
  obtain('littlebeast', 'DD/RR mod for TF Gun', [dd_rr_mod, 'DD/RR mod', for(tfgun)]),
+
-
 
+
-
  ts('2007.08.11 18:33'),
+
-
  obtain('Jenerix525', 'mirror with silver handle', [mirror, 'silver handle', 'not magical']),
+
-
  % Add above this line.
+
-
  true.
+
-
 
+
-
 
+
-
% After consulting/loading this file:
+
-
%
+
-
% * To generate inventory list:
+
-
%| ?- inv.
+
-
%
+
-
% * To generate blame list:
+
-
%| ?- blame.
+
-
 
+
-
</pre>
+
-
 
+
= Sandbox =
= Sandbox =
[[PhaethonH/Sandbox]]
[[PhaethonH/Sandbox]]

Revision as of 03:16, 13 August 2007

Contents

ΦαεθωνΗ

Phi, alpha, epsilon, theta, omega, nu -- along the lines of "faye, tonne".

I abuse this wiki to stash stuff.

Forum-avatar stuff

Image:iJackhound3.gif

This is May from Guilty Gear. An iPod ad parody with May doing her Jackhound technique and losing her iPod mid-attack.

Image stuff

Image:PH_TG-MK1.png


Inventory

Current Inventory

Generated from the Inventory Log program.

Current inventory (18 items):
 a) TF Gun
 b) Fish (dead)
 c) Squirrel teddy (squirrel)
 d) can of soda (soda, unlabeled)
 e) can of soda (soda, unlabeled)
 f) can of soda (soda, unlabeled)
 g) can of soda (soda, unlabeled)
 h) can of soda (soda, unlabeled)
 i) can of soda (soda, unlabeled)
 j) red crystal inscribed with TF-gun code for Otter V1 (red)
 k) yarn ball of distraction (yarn, distraction)
 l) shiny hubcap (shiny)
 m) can of mackerel (mackerel)
 n) bag of salt-n-glass cookies (cookie, salt_n_glass)
 o) Infinite Scroll of Doom-Ish (infinite, doom-ish)
 p) Infinite Pen of Doom-Ish (infinite, doom-ish)
 q) DD/RR mod for TF Gun (DD/RR mod)
 r) mirror with silver handle (silver handle)
(end)


Blame List

Generated from the Inventory Log program.

Blame list:

  • [2007.08.11 05:12] Tyris provided TF Gun
  • [2007.08.11 05:12] Tyris provided Fish
  • [2007.08.11 05:12] Tyris provided Squirrel teddy
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided can of soda
  • [2007.08.11 05:12] Tyris provided red crystal inscribed with TF-gun code for Otter V1
  • [2007.08.11 05:57] Kalga provided yarn ball of distraction
  • [2007.08.11 08:02] Cheez provided shiny hubcap
  • [2007.08.11 08:02] Cheez provided can of mackerel
  • [2007.08.11 08:02] Cheez provided bag of salt-n-glass cookies
  • [2007.08.11 12:46] littlebeast provided Infinite Scroll of Doom-Ish
  • [2007.08.11 12:46] littlebeast provided Infinite Pen of Doom-Ish
  • [2007.08.11 16:08] littlebeast provided DD/RR mod for TF Gun
  • [2007.08.11 18:33] Jenerix525 provided mirror with silver handle

(end)


Inventory Log

Inventory Log program

Sandbox

PhaethonH/Sandbox

Personal tools