PhaethonH

From Egs Mayhem

(Difference between revisions)
m (Inventory Log)
m
Line 18: Line 18:
Generated from the Inventory Log program below.
Generated from the Inventory Log program below.
<pre>
<pre>
-
Current inventory:
+
Current inventory (18 items):
  a) TF Gun
  a) TF Gun
  b) Fish (dead)
  b) Fish (dead)
Line 39: Line 39:
(end)
(end)
</pre>
</pre>
 +
 +
 +
== Blame List ==
 +
Generated from the Inventory Log program below.
 +
 +
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 ==
Line 173: Line 199:
-
% prety-print inventory.
+
% pretty-print inventory.
inv :-
inv :-
-
   write('Current inventory:'), nl,
+
  maxitemid(Max),
 +
  ItemCount is (Max-1),
 +
   write('Current inventory'),
 +
  write(' ('), write(ItemCount), write(' items)'),
 +
  write(':'), nl,
   inv_item(1);
   inv_item(1);
   write('(end)\
   write('(end)\
Line 191: Line 221:
   maxitemid(Max),
   maxitemid(Max),
   N < Max,
   N < Max,
-
  write(' '),
 
   ts(TS, obtain(N)),
   ts(TS, obtain(N)),
   blame(N, W),
   blame(N, W),
   item(N, Item),
   item(N, Item),
-
  write(N), write('. '),
+
%  write(' '), write(N), write('. '),
 +
  write('* '),
   write('['), write(TS), write('] '),
   write('['), write(TS), write('] '),
   write(W), write(' provided '), write(Item), nl,
   write(W), write(' provided '), write(Item), nl,
Line 202: Line 232:
   blame_item(Next).
   blame_item(Next).
-
blamelist :-
+
blame :-
   write('Blame list:'), nl,
   write('Blame list:'), nl,
   blame_item(1);
   blame_item(1);
Line 254: Line 284:
% * To generate inventory list:
% * To generate inventory list:
%| ?- inv.
%| ?- inv.
 +
%
 +
% * To generate blame list:
 +
%| ?- blame.
</pre>
</pre>

Revision as of 08:05, 12 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 below.

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 below.

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

This is one giant Prolog program file:

%#! 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.

Personal tools